• Table not acquiring values server side?
    6 replies, posted
Hey, i been trying to make a tool that makes selected entities not able to be picked up by the physgun but my efforts are pretty much exhausted. However, when i use this on my server everything works right except the values entered into the table only appear to be client side and not server side. When i click on some props to add their IDs to the table then hit reload, which for debugging is set to print the contents of the table, print(table.concat(ent_table, " , ")), only their ID's show up in the client console, in the server console it is blank as if it has no values. I've tried many, many different variations of trying to get it to work but am not successful. Code: BTW i never made anything with lua before but I'm doing my best, Thanks.
Please use lua tags, makes it nicer for others to read.
I'm sorry, [lua] TOOL.Category = "Constraints" TOOL.Name = "#Nonphysgunable" TOOL.Command = nil TOOL.ConfigName = "" if ( CLIENT ) then language.Add( "Tool_Nonphysgunable_name", "Non-Physgunable" ) language.Add( "Tool_Nonphysgunable_desc", "Make things immune to physgun." ) language.Add( "Tool_Nonphysgunable_0", "Primary: Protect Secondary: Free" ) end ent_table = {} if ( SERVER ) then function physgunPickUp( ply, ent) if (!ent:IsValid()) then return end if (ent:IsPlayer()) then return end if (ent:IsWorld()) then return end if table.HasValue( ent_table, ent:EntIndex() ) then print("false") print(ent:EntIndex()) return false else print("true") print(ent:EntIndex()) return end end hook.Add( "PhysgunPickup", "canPhysgunPickUp", physgunPickUp) end function TOOL:LeftClick( trace ) if ( CLIENT ) then return true end if (trace.Entity:IsPlayer() || trace.Entity:IsWorld()) then return false end if (ValidEntity(trace.Entity) and !table.HasValue( ent_table, trace.Entity:EntIndex())) then table.insert(ent_table,trace.Entity:EntIndex()) end return true end function TOOL:RightClick( trace ) if ( CLIENT ) then return true end local index = 1 if (trace.Entity:IsPlayer() || trace.Entity:IsWorld() || !table.HasValue( ent_table, trace.Entity:EntIndex())) then return false end if (ValidEntity(trace.Entity)) then while index <= table.Count(ent_table) do if(ent_table[index] == trace.Entity:EntIndex()) then table.remove( ent_table, index ) end index = index + 1 end end return true end function TOOL:Reload( tr ) print(table.concat(ent_table, " , ")) return true end [/lua]
What the heck? You're never adding them to the table clientside!
[QUOTE=esalaka;17495032]What the heck? You're never adding them to the table clientside![/QUOTE] Oh yeah, I've edited the code so many times to try to figure out what was wrong, I originally had the 'if ( CLIENT ) then return true end' part in the left and right click functions at the bottom of them. :P
anyone else?
How do you know it's printing them clientside? Change the prints to MsgNs and see what colours you get.
Sorry, you need to Log In to post a reply to this thread.