I’m adding now an inventory to my RP gamemode. I already made the render ; the inventory rendering is correct. Now i want the server Player.inventory table to be sended and recieved by the client. The problem is that the client seams to never recieve any data from the server. I can send inventory 1000 times ore more (even in a for loop), nothing is recieved by the client, the net.Recieve that i put in my cl_init.lua won’t be called.
I tried sending at GM:PlayerSpawn but not working, i tried too on GM:PlayerInitialSpawn but same.
Here is the code :
InventoryManager:OnInventoryChanged(player) saves the data as file and sends data to the client
--Prepare inventory GameGlobal:PrintMessage("Saving/Reloading player's inventory...") InventoryManager:SaveInventory(ply) InventoryManager:LoadInventory(ply) InventoryManager:OnInventoryChanged(ply) GameGlobal:PrintMessage("Done !")
--Prepare inventory GameGlobal:PrintMessage("Loading player's inventory...") InventoryManager:LoadInventory(ply) InventoryManager:OnInventoryChanged(ply) GameGlobal:PrintMessage("Done !")
function InventoryManager:OnInventoryChanged(player) if (player.inventory == nil) then return false end --Save inventory InventoryManager:SaveInventory(player) --Send the complete inventory for update on client side net.Start("RealisticRoleplay_InventoryUpdater") print("test1") net.WriteTable(player.inventory) net.Send(player) end
net.Receive("RealisticRoleplay_InventoryUpdate", function(len, ply) GameGlobal:PrintMessage("Updating player inventory...") LocalPlayer().inventory = net.ReadTable() end)
The server outputs correctly “test1” and every Load/Reload messages.
That’s only the client that won’t recieve anything from server…