• Global variable
    4 replies, posted
Hello, I'm trying to set a global variable on a player, and then check if the player has it in another file. ( Setting this variable from a ULX command ) [CODE]local affected_plys = {} for i=1, #target_plys do local v = target_plys[ i ] --[[ if not v:IsValid() then return end ]] if not should_revoke then v.vanish = true // This is the variable else v.vanish = false // This is the variable end table.insert( affected_plys, v ) end [/CODE] And here I try to check if it's set, however I get nothing: [CODE]ply = LocalPlayer() if ply.vanish == true then // Stuff here end[/CODE] Am I doing something wrong? As I don't really see what's the mistake.
You are trying to access a serverside variable on the client, send the variable using net message, or take a look at [URL="http://wiki.garrysmod.com/page/Entity/SetNWBool"]SetNWBool()[/URL]
The variable on a player will stay in the realm they were set in. If you are setting it serverside and want to access it clientside, you'll have to network it. [editline]13th June 2014[/editline] ninja'd. I recommend against SetNWBool though.
I totally agree with you Bo, I highly discourage using Garry's NW library.
Ah okay, I had no idea that the variable would stay on the current realm. I'll network it over then, thanks :v:
Sorry, you need to Log In to post a reply to this thread.