Hey guys just a quick one.
I made a custom player class, everything's was going smoothly, the player was given all the attributes I assigned it, the loadout override function worked fine, but when I add a self:NetworkVar() call to my PLAYER:SetupDataTables() hook, I get an error saying that NetworkVar() is a nil value.
Code looks like this:
[CODE]
DEFINE_BASECLASS( "player_default" )
local PLAYER = {}
PLAYER.WalkSpeed = 400
PLAYER.RunSpeed = 400
//...etc.
function PLAYER:SetupDataTables()
self:NetworkVar( "Float", 0, "Amount" );
end
player_manager.RegisterClass( "player_custom", PLAYER, "player_default" )
[/CODE]
Any ideas? This method isn't deprecated is it?
Thanks in advance!
~K
You're indexing the class, not the player. Use self.Player instead, e.g.
[code]
function PLAYER:SetupDataTables()
self.Player:NetworkVar(...)
end
[/code]
[QUOTE=bigdogmat;50759995]You're indexing the class, not the player. Use self.Player instead, e.g.
[code]
function PLAYER:SetupDataTables()
self.Player:NetworkVar(...)
end
[/code][/QUOTE]
Hilarious that the wiki made no mention of this. Kudos!
[QUOTE=KTheScientist;50760052]Hilarious that the wiki made no mention of this. Kudos![/QUOTE]
But there is!
[url]http://wiki.garrysmod.com/page/Category:PLAYER_Hooks[/url]
I also added an example to the PLAYER:SetupDataTables page.
Sorry, you need to Log In to post a reply to this thread.