attempt to call global 'PrintMessage' (a nil value)
6 replies, posted
Im getting this error and i tryed to fix it,
But i cant get it to work.
I got more of this timers with the same error.
This is the error:
[CODE][ERROR] gamemodes/laststand/gamemode/shared.lua:130: attempt to call global 'PrintMessage' (a nil value)
1. unknown - gamemodes/laststand/gamemode/shared.lua:130[/CODE]
The code where the error begins:
[LUA]timer.Create( "hthm", 60, 1, function()
PrintMessage(HUD_PRINTTALK, "Type ls_helpmenu in console to access the help menu.") -- The error is from this line.
end )[/LUA]
I hope someone can help.
I'm going to guess that your code ran on both the client and the server and PrintMessage doesn't exist on the client. Not entirely sure, but if this is true then you could try LocalPlayer():PrintMessage( if you want it to work on the client.
It prints the message now but i got a new error:
[CODE]
[ERROR] gamemodes/laststand/gamemode/shared.lua:130: attempt to call global 'LocalPlayer' (a nil value)
1. unknown - gamemodes/laststand/gamemode/shared.lua:130
Timer Failed! [d1start][@gamemodes/laststand/gamemode/shared.lua (line 129)][/CODE]
I got this now:
[LUA]timer.Create( "hthm", 60, 1, function()
LocalPlayer():PrintMessage(HUD_PRINTTALK, "Type ls_helpmenu in console to access the help menu.")
end )[/LUA]
LocalPlayer() is a clientside function, you need to wrap an if ( CLIENT ) statement around timer.Create so it only creates the timer on the client, not the server.
That didnt work now the zombies dont spawn and the text is not showing.
[QUOTE=maikeldoren;40421656]That didnt work now the zombies dont spawn and the text is not showing.[/QUOTE]
That [b]would[/b] have worked if you [b]knew[/b] what you were doing.
Fixed it with if (SERVER) then
Sorry, you need to Log In to post a reply to this thread.