Restrict USE vgui menu to jobs.

So I’v been really excited that I have a measurable growth in my knowledge of GLua but I am not too go at DarkRP custom functions so Im stuck on this one thing

Code:


local jsa = TEAM_GUN
net.Receive("open_vendingmachine", function( )
local ply = LocalPlayer()
	if ply:getDarkRPVar("job") == jsa then 
 
blah blah
end
 

But the menu dosnt open at all for anything and there are no errors.

use ply:Team() for the statement, and also do this kind of operations on the server, you’re asking for exploits doing it on the client :slight_smile:


[ERROR] addons/ship_shop_by_snowa/lua/autorun/client/cl_vendingmachine.lua:75: attempt to call method 'Team' (a nil value)
  1. func - addons/ship_shop_by_snowa/lua/autorun/client/cl_vendingmachine.lua:75
   2. unknown - lua/includes/extensions/net.lua:32


show code.


 local jsa = TEAM_GUN
net.Receive("open_vendingmachine", function( )
local ply = LocalPlayer()
	if ply:Team() == jsa then 
 
blah blah
end

do you even end your statement?

Yes

Assuming that you’re running this code on the clientside. (Since I think you’re trying to open GUI after Use is called on something)
Either LocalPlayer() isn’t valid or TEAM_GUN doesn’t actually exist.

PS: there’s really no need to localize that ‘jsa’ variable (atleast from the code you’ve provided)

Give this a try:



net.Receive("open_vendingmachine", function( )
        if LocalPlayer():Team() == TEAM_GUN then
             --code here
        end
end)


Thank you, this helped a lot and it now works!