• Issues with meta tables
    15 replies, posted
[url]http://pastebin.com/hf9e0DD4[/url] In cl_init I call LocalPlayer():GetRace() and it returns a nil value. Why is that? Did I set up my meta tables correctly for Gmod13?
The code there is fine, post your cl_init.lua
Possibly because your not setting race. [lua] local meta = _R.Player function meta:SetRace(race) print("set race called for " .. self:Nick()) self:SetNWString("Race", race) end function meta:GetRace() print("get race called for " .. self:Nick()) return self:GetNWString("Race") or "Human" end [/lua]
I have the race being set in a file called deathknight.lua. I can confirm that SetNWString is working: [url]http://pastebin.com/aUiMU20g[/url] But calling back using GetRace just does not seem to work Here is where I SetRace: [url]http://pastebin.com/LUkmLpMj[/url] Here is where I GetRace: [url]http://pastebin.com/NPnZp78C[/url]
[QUOTE=BradenFase;37396091]I have the race being set in a file called deathknight.lua. I can confirm that SetNWString is working: [URL]http://pastebin.com/aUiMU20g[/URL] But calling back using GetRace just does not seem to work Here is where I SetRace: [URL]http://pastebin.com/LUkmLpMj[/URL] Here is where I GetRace: [URL]http://pastebin.com/NPnZp78C[/URL][/QUOTE] DONT mind the __toString() it doesnt work ;3 just some scrap i left thar.
Are you calling GetRace on SERVER or CLIENT. And where is GetRace located(SERVER CLIENT OR SHARED?)?
[QUOTE=Aide;37396224]Are you calling GetRace on SERVER or CLIENT. And where is GetRace located(SERVER CLIENT OR SHARED?)?[/QUOTE] That GetRace you saw that was commented out was from cl_init.lua
[QUOTE=shinji144;37396119]DONT mind the __toString() it doesnt work ;3 just some scrap i left thar.[/QUOTE] It doesn't work because your not using it right from what I see here in front of me.
Okay it's removed. Don't worry about the tostring crap that was there.
[QUOTE=Aide;37396245]It doesn't work because your not using it right from what I see here in front of me.[/QUOTE] I know that bit :) I had just left it there
[QUOTE=BradenFase;37396232]That GetRace you saw that was commented out was from cl_init.lua[/QUOTE] And where is GetRace function located on(in) a server (file) or on(in) client (file)
[QUOTE=Aide;37396269]And where is GetRace function located on(in) a server (file) or on(in) client (file)[/QUOTE] GetRace was created in init.lua
So what you need to do is the following. Removed it and paste it in a file that's loaded by client and server. Or just create a file thats loaded by client and server. Your trying to use a funciton that doesn't exist on the client.
[QUOTE=Aide;37396315]So what you need to do is the following. Removed it and paste it in a file that's loaded by client and server. Or just create a file thats loaded by client and server. Your trying to use a funciton that doesn't exist on the client.[/QUOTE] So I can take [url]http://pastebin.com/hf9e0DD4[/url] And put it in, say shared.lua?
Yes, but I'd leave SetRace function on server.
Alright it's all working great. Thanks for your help Aide!
Sorry, you need to Log In to post a reply to this thread.