Donator Only can buy on the (Pointshop) (HELP PLZZ !)

Hello Guys!

I want to make Donators only who can buy some items!

I’m using ulx, and i set up the rank: Operator = Donator

So anyone can tell me, why this code is not working? pleasee guys i beg you ! i just want that only if i make someone Operator then he can buy the model else, show a message with saying: YOU ARE NOT A DONATOR

[lua]

ITEM.Name = 'Alyx'
ITEM.Price = 50
ITEM.Model = 'models/player/alyx.mdl'
 
function ITEM:OnEquip(ply, modifications)
 
if(Ply:GetUserGroup(Operator)
 
        if not ply._OldModel then
                ply._OldModel = ply:GetModel()
        end
       
        timer.Simple(1, function() ply:SetModel(self.Model) end)
        else
        return
 
end
 
function ITEM:OnHolster(ply)
        if ply._OldModel then
                ply:SetModel(ply._OldModel)
        end
end
 
function ITEM:PlayerSetModel(ply)
        ply:SetModel(self.Model)
end

[/lua]

You’ve completely over-complicated this



ITEM.AllowedUserGroups = { "Operator" }


[lua]

ITEM.Name = 'Alyx'
ITEM.Price = 50
ITEM.Model = 'models/player/alyx.mdl'
ITEM.AllowedUserGroups = { "operator" }
 
function ITEM:OnEquip(ply, modifications)
 
if(Ply:GetUserGroup(Operator)
 
        if not ply._OldModel then
                ply._OldModel = ply:GetModel()
        end
       
        timer.Simple(1, function() ply:SetModel(self.Model) end)
        else
        return
 
end
 
function ITEM:OnHolster(ply)
        if ply._OldModel then
                ply:SetModel(ply._OldModel)
        end
end
 
function ITEM:PlayerSetModel(ply)
        ply:SetModel(self.Model)
end

[/lua]

Pointshop already has a built-in function for restricting user groups.

[editline]26th June 2014[/editline]

Ninja’d

Thanks you !! :), but how can i set if a player is not an operator then show a message saying: ONLY DONATORS CAN BUY THIS MODEL ???

[lua]

ITEM.Name = 'Alyx'
ITEM.Price = 50
ITEM.Model = 'models/player/alyx.mdl'
ITEM.AllowedUserGroups = { "operator" }
 
function ITEM:OnEquip(ply, modifications)
 
        if not ply._OldModel then
                ply._OldModel = ply:GetModel()
        end
       
        timer.Simple(1, function() ply:SetModel(self.Model) end)
        else
        return
 
end
 
function ITEM:OnHolster(ply)
        if ply._OldModel then
                ply:SetModel(ply._OldModel)
        end
end
 
function ITEM:PlayerSetModel(ply)
        ply:SetModel(self.Model)
end

[/lua]

That’d work, I guess.

In relation to your other question, You’ll have to ask someone else for that…I’ll end up pasting you a silly unnecessary method.

IIRC it already does that using ps_notify?