Ulysses
General => Off-Topic => Topic started by: xSylar on May 28, 2013, 04:10:58 AM
-
In the Pointshop(by unidentified) I want it so a group like Donater/Superadmin can buy them but when i add the groups i want it just does not see to want to work. It says Your not in the right group to buy this item!
Here is the Coding for the Pointshop
ITEM.Name = 'Adolf Hitler'
ITEM.Price = 750
ITEM.Model = 'models/player/hitler.mdl'
ITEM.AllowedUserGroups = { "superadmin"} - but not superadmin
ITEM.AllowedUserGroups = { "diamond"} - diamond works
ITEM.AllowedUserGroups = { "admin"} - but admin group does not work
ITEM.AllowedUserGroups = { "hos"} - this works also
something like that anyway
If anyone can help me thx
also I like the Ulysses forums more then Facepunch forums
-
Try:
ITEM.AllowedUserGroups = {"superadmin", "diamond", "admin", "hos"}
-
I tried MULTIPLE ways of doing that. I just did not add the "" wow im so angry i spent hours trying to figure it out and thats the only one that i did not use wow
THANKS anyway!!!
-
Just to go a little farther and explain to you WHY it didn't work the way you had it:
When you want to set the contents of a table in lua you put it in curly brackets.
Example:
test.table = {"hello"}
If I were to write another line defining something completely different in test.table; for example:
test.table = {"something else"}
this completely overwrites whatever was already in test.table with the new value which is "something else" in this case.
Your example basically overwrote itself 3 times until:
ITEM.AllowedUserGroups = { "hos" }
was the last thing you set that table to. Everything before it was erased.
If you want to add multiple items to a table there are two ways to do it.
You can separate each item with commas when you originally define the table, which is what Megiddo did in his example:
ITEM.AllowedUserGroups = { "superadmin", "diamond", "admin", "hos" }
Or, alternatively, you can append new data to an already existing table.
To append new data to an existing table, you would use the lua function 'table.insert'
ITEM.AllowedUserGroups = { } --This creates the table with nothing in it. Items will be added below.
table.insert( ITEM.AllowedUserGroups, "superadmin" )
table.insert( ITEM.AllowedUserGroups, "diamond" )
table.insert( ITEM.AllowedUserGroups, "admin" )
table.insert( ITEM.AllowedUserGroups, "hos" )
The reason diamond worked even though it appears to have been overwritten is because I would be willing to bet that your 'hos' group inherits from the diamond group.
I hope this has been helpful and not confusing. :D