I’m deriving a gamemode from sandbox.
These are my spawn functions(Player spawns fine as expected):
function GM:PlayerInitialSpawn( ply ) player_manager.SetPlayerClass( ply , "player_buildtools" ) end function GM:PlayerSpawn( ply ) player_manager.OnPlayerSpawn( ply ) player_manager.RunClass( ply, "Spawn" ) player_manager.RunClass( ply, "SetModel" ) player_manager.RunClass( ply, "Loadout" ) end
This is the code im using to setup data tables:
local PLAYER = FindMetaTable("Player") function PLAYER:SetupDataTables() self:NetworkVar( "Int", 0, "Money") self:SetMoney(234) end hook.Add( "PlayerInitialSpawn" , "PlayerInitialSpawnSyncData" , function( ply ) ply:InstallDataTable() ply:SetupDataTables() print(ply:GetMoney()) --This prints "234" ply:SetMoney(4000) --No errors print(ply:GetMoney()) --This prints "4000" end)
After the previous, I have this code somewhere(serverside):
hook.Add("PlayerSay","Test1",function( ply, text, team ) if(string.StartWith(text,"!ServerGetMoney")) then print(ply:GetMoney()) --This prints nil? - when I type in chat "!ServerGetMoney" end end)
I have no idea why my tables are being reset, they clearly work during the initial spawn hook. I’m even using player_manager without referencing the baseclass, so the setupdatatables shouldnt be called from the playerclass.
I’ve tried getting a table of all the hooks, but I dont see anything obvious that would override this…I can post the table later if anyone is interested.
I’ve tried finding what exactly is resetting my datatables with no success…Any ideas would be greatly appreciated!