# Team dependent point payments

So im playing around and im trying to get some point payments going and want them to vary depending on the players team. Im going for something like this (which obviously wouldnt work) [LUA] if PS.Config.PointsOverTime then
timer.Create(‘PS_PointsOverTime_’ … self:UniqueID(), PS.Config.PointsOverTimeDelay * 60, 0, function()
if self:Alive() then
if self:Team() == 5 then
self:PS_GivePoints(50)
self:PS_Notify(“Hey there Superadmin! Youve been given 50 points for playing!”)
if self:Team() == 4 then
self:PS_GivePoints(20)
self:PS_Notify(“Hey there admin! Youve been given 20 points for playing and doing your job (hopefully)!”)
end
if self:Team() == 3 then
self:PS_GivePoints(10)
self:PS_Notify(“Youve been given 10 points for being a merchant!”)
end
if self:Team() == 2 then
self:PS_GivePoints(15)
self:PS_Notify(“Youve been given 15 points for being an officer of the law!”)
end
if self:Team() == 1 then
self:PS_GivePoints(5)
self:PS_Notify(“You found 5 points someone dropped on the ground!”)
end
end
end)
end[/LUA]

Any help is appreciated!

Do a table

[lua]
local pointValues = { 5, 15, 10, 20, 50 };
[/lua]

Then give them the amount of points in the table which corresponds to their team

[lua]
self:PS_GivePoints( pointValues( self:Team() ) );
[/lua]

Also, you should probably have a global timer which gives points to everyone

[lua]
if PS.Config.PointsOverTime then
timer.Create(‘PS_PointsOverTime_’, PS.Config.PointsOverTimeDelay * 60, 0, function()
for _, ply in pairs( player.GetAll() ) do
– stuff here
ply:PS_GivePoints( pointValues[ self:Team() ] );
end
end )
end
[/lua]
pseudo

I keep getting an unexpected symbol at [LUA]end )[/LUA] Why?

I think because the ) isn’t supposed to be there. Try putting it on the end above, and if not then remove it.

Moving it up didnt work and removing it wont work because it has to close the timer.Create function.

[lua]
if PS.Config.PointsOverTime then
timer.Create(‘PS_PointsOverTime_’, PS.Config.PointsOverTimeDelay * 60, 0, function()
for _, ply in pairs( player.GetAll() ) do
– stuff here
ply:PS_GivePoints( pointValues( self:Team() ) );
end
end )
end
[/lua]

are you using that exact code? because there should be no errors

I did some playing around and using that code works but putting the code for teams i had in the OP gives that error. Is there a certain way i should be doing that team check? Can someone give an example please?

For each team, do something like print(LocalPlayer():Team());
then in a table like he said,
[lua]local pointValues = {
[“1002”] = 1;
[“1001”] = 5;
}[/lua]
(1002 and 1001 would be the team value)

also, you should change pointValues( self:Team() ) to pointValues[self:Team()]
(i’m fairly certain you can’t access a tables’ keys by using brackets)