• Setting a value to a player serverside
    2 replies, posted
Hey!, so I am making this addon where the client sends a number to the server and I need to keep that number saved to the player serverside, This is my code that I'm using for it, from the wiki [CODE] ply = FindMetaTable( "Player" ); function ply:SetupDataTables() self:NetworkVar( "Int", 0, "FNumber" ); end function Test(ply, text, public) print("Number: "..ply:GetFNumber()); end hook.Add("PlayerSay", "TestyWesty", Test); [/CODE] it prints [CODE] [ERROR] addons/darkrptests/lua/sv_test.lua:23: attempt to call method 'GetFNumber' (a nil value) 1. fn - addons/darkrptests/lua/sv_test.lua:23 2. unknown - addons/ulib/lua/ulib/shared/hook.lua:183 [/CODE] Wiki link: [url]http://wiki.garrysmod.com/page/Networking_Entities[/url] [editline]1st April 2014[/editline] SetFNumber( 0 ) doesn't work aswell
If you only need to have the number serverside, there's no need to network it.
[QUOTE=ms333;44417515]If you only need to have the number serverside, there's no need to network it.[/QUOTE] No, this is just an example, in my code the client selects something from a derma list, then it sends to the server what value that specific player selected, and I need to store it for that specific player [editline]1st April 2014[/editline] I forgot to call the SetupDataTables function on the player -.-
Sorry, you need to Log In to post a reply to this thread.