Haven't really used DataTables before but they perfectly fit what I need right here. I'm storing these on every player using a Player Class, but the problem is that PLAYER:SetupDataTables is only called on the server [I]except[/I] when it's myself who gets set as the class. The class is set in GM:PlayerInitialSpawn().
[CODE]DEFINE_BASECLASS( "player_default" )
local PLAYER = {}
function PLAYER:SetupDataTables()
print("Setting up datatables for "..self.Player:Nick())
self.Player:NetworkVar( "Bool", 0, "HasBall" )
self.Player:NetworkVar( "Int", 0, "BallID" )
self.Player:NetworkVar( "Vector", 0, "YTLColor" )
-- Setting starting variables here as these NetworkVars aren't created when the player is initially spawning
if self.Player:Team() == 2 then
self.Player:SetHasBall(true)
self.Player:GetViewModel():SetNoDraw(false)
self.Player:GetActiveWeapon():SendWeaponAnim(ACT_VM_DRAW)
else
self.Player:SetHasBall(false)
self.Player:GetViewModel():SetNoDraw(true)
self.Player:GetActiveWeapon():SendWeaponAnim(ACT_VM_THROW)
end
self.Player:SetYTLColor( self.Player:GetPlayerColor() )
self.Player.datatablesup = true
end
player_manager.RegisterClass( "ytl_playerclass", PLAYER, "player_default" )[/CODE]
Whenever I spawn, I see both the client and the server printing "Setting up data tables ...", but whenever I spawn a bot, only the server prints it. And whenever I try to access GetHasBall() on any of the bots, it is a nil method. It could be a simple thing, but what am I doing wrong here? I just need these datatables to be accessible on every player from every client.
[QUOTE=Zet0r;47990890]Haven't really used DataTables before but they perfectly fit what I need right here. I'm storing these on every player using a Player Class, but the problem is that PLAYER:SetupDataTables is only called on the server [I]except[/I] when it's myself who gets set as the class. The class is set in GM:PlayerInitialSpawn().
[CODE]DEFINE_BASECLASS( "player_default" )
local PLAYER = {}
function PLAYER:SetupDataTables()
print("Setting up datatables for "..self.Player:Nick())
self.Player:NetworkVar( "Bool", 0, "HasBall" )
self.Player:NetworkVar( "Int", 0, "BallID" )
self.Player:NetworkVar( "Vector", 0, "YTLColor" )
-- Setting starting variables here as these NetworkVars aren't created when the player is initially spawning
if self.Player:Team() == 2 then
self.Player:SetHasBall(true)
self.Player:GetViewModel():SetNoDraw(false)
self.Player:GetActiveWeapon():SendWeaponAnim(ACT_VM_DRAW)
else
self.Player:SetHasBall(false)
self.Player:GetViewModel():SetNoDraw(true)
self.Player:GetActiveWeapon():SendWeaponAnim(ACT_VM_THROW)
end
self.Player:SetYTLColor( self.Player:GetPlayerColor() )
self.Player.datatablesup = true
end
player_manager.RegisterClass( "ytl_playerclass", PLAYER, "player_default" )[/CODE]
Whenever I spawn, I see both the client and the server printing "Setting up data tables ...", but whenever I spawn a bot, only the server prints it. And whenever I try to access GetHasBall() on any of the bots, it is a nil method. It could be a simple thing, but what am I doing wrong here? I just need these datatables to be accessible on every player from every client.[/QUOTE]
-snip-
[QUOTE=Robotboy655;47990943][url]https://github.com/Facepunch/garrysmod-issues/issues/892[/url][/QUOTE]
So it just doesn't work huh. Know another way of doing it? I stored it in the weapon before, but the data would obviously be reset whenever a player died and was regiven the weapon.
EDIT: Reading your comment on that GitHub issue, is it possible to do a network message to every other player when anyone joins and have them react with a player_manager.RunClass()?
Sorry, you need to Log In to post a reply to this thread.