ULX

Author Topic: Pointshop Groups aren't working!  (Read 3999 times)

0 Members and 2 Guests are viewing this topic.

Offline xSylar

  • Newbie
  • *
  • Posts: 12
  • Karma: -1
Pointshop Groups aren't working!
« 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

Quote
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

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Pointshop Groups aren't working!
« Reply #1 on: May 28, 2013, 05:12:45 AM »
Try:

Code: [Select]
ITEM.AllowedUserGroups = {"superadmin", "diamond", "admin", "hos"}
Experiencing God's grace one day at a time.

Offline xSylar

  • Newbie
  • *
  • Posts: 12
  • Karma: -1
Re: Pointshop Groups aren't working!
« Reply #2 on: May 28, 2013, 06:12:54 AM »
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!!!

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Pointshop Groups aren't working!
« Reply #3 on: May 28, 2013, 07:56:01 AM »
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
« Last Edit: May 28, 2013, 08:03:43 AM by MrPresident »