TTT win round points - PS_GivePoints is a nil value
2 replies, posted
Solved, had to move it to server.
Code:
[CODE]hook.Add("TTTEndRound", "tttlvl.savestats", function(result)
local players = player.GetAll()
for _, pl in ipairs(players) do
if pl:IsTerror() then
if result == WIN_TRAITOR then
if pl:IsActiveTraitor() then
pl:PS_GivePoints(10)
end
else
if !pl:IsActiveTraitor() then
pl:PS_GivePoints(5)
end
end
end
end
end)[/CODE]
Error:
[CODE][ERROR] lua/autorun/win_points.lua:12: attempt to call method 'PS_GivePoints' (a nil value)
1. fn - lua/autorun/win_points.lua:12
[/CODE]
I'm not really a coder (I only know basic stuff) so I got it from here: [url]https://facepunch.com/showthread.php?t=1357870[/url]
It seems to all work except the pointshop thing. I checked the pointshop documentation and it's written correctly. the issue is probably pretty obvious, anyone know whats wrong?
The only thing that comes to mind is that you could try changing ipairs to pairs.
[QUOTE=Sanxy;51919088]The only thing that comes to mind is that you could try changing ipairs to pairs.[/QUOTE]
this and try enclosing your code with:
[code]
if SERVER then
-- your code here
end
[/code]
As autorun runs the code on both server and client, while PS_GetPoints does not exist on the former
Sorry, you need to Log In to post a reply to this thread.