Hi!
ive made this code where everytime someone from team 1 kills team 0 team 1 gets a point but its throwing errors at me
Code:
[CODE]local k1 = 0 -- Team 0 Points
local k2 = 0 -- Team 1 Points
local ppk = 1 -- Points Per Kill
function roundscore( ply, victim )
if ply:IsPlayer() then
if ply:Team() == 1 then
if victim:Team() == 0 then
k2 = k2 + ppk
return k2
else
end
elseif ply:Team() == 0 then
if victim:Team() == 1 then
k1 = k1 + ppk
return k1
else
end
end
end
end[/CODE]
Errors:
[CODE]
[ERROR] gamemodes/advw/gamemode/cl_init.lua:151: 'then' expected near '='
[/CODE]
any help would be awesome, Thanks!
Proper tabbing would help, and there are no "errors" in the code you provided; if you're using /**/ comments in your code, it'll make the line number lie... Next, why did you add an else into the if-statement if it isn't being used?
You can also simplify the code quite a bit, here!
[code]// When a player dies, check to see if we need to add points
hook.Add( "PlayerDeath", "TeamScore", function( _p, _w, _attacker )
// If both player and attacker are valid, and they aren't the same player and on different teams
if ( IsValid( _p ) && IsValid( _attacker ) && _p != _attacker && _p:Team( ) != _attacker:Team( ) ) then
// Add a point to the attackers team..
team.AddScore( _attacker:Team( ), 1 );
end
end );[/code]
To get the score on the client, simply use team.GetScore( TEAM_XXX );
Sorry, you need to Log In to post a reply to this thread.