End Round Points help

I need some help with this little script I made. It halfway works. It gives the 50 points for winning the round and the 5 points for killing someone but not the 10 points for people who are dead. Here is the code:


if (SERVER) then
hook.Add("JailBreakRoundEnd", "JB_RoundEnd_Points", function(endRnd)
	for _, pl in pairs(player.GetAll()) do
		if (IsValid(pl)) then
			if (pl:Alive()) then
				if (endRnd) then
					if (pl:Alive()) then
						pl:PS_GivePoints(50)
						pl:PS_Notify("You lived and got 50 Points!")
						else
						pl:PS_GivePoints(10)
						pl:PS_Notify("You died but you still get 10 points!")
						end
					end
				end
			end
		end
	end)
end
/*
.//Shadow's Code
*/
hook.Add( "DoPlayerDeath", "JBKillPoints", function( vict, att, dmginfo )

	if not (IsValid(att) and att:IsPlayer() and att:Team() != vict:Team()) then return end

	att:PS_GivePoints(5)
	att:PS_Notify("Nice. Here's 5 points. There's more where that came from.")

end )

Try using elseif (pl:Dead()) maybe?
Idk, that’s all I got :stuck_out_tongue:

Use something like this instead.
[lua]hook.Add( “JailBreakRoundEnd”, “EndRoundPoints”, function()

for _, ply in pairs( player.GetAll() ) do

	if ply:Alive() then

		ply:PS_GivePoints( 50 )
		ply:PS_Notify( "You earned 50 points for surviving the round!" )

	else

		ply:PS_GivePoints( 10 )
		ply:PS_Notify( "You get 10 points for playing this round." )

	end

end

end )[/lua]
There’s no need to check if the player is valid and I have no idea why you’re using endRnd, but if you have to use it, put
[lua]if not endRnd then return end[/lua]
If you need to check multiple conditions you can use a single if, search up the keyword “and”.

Alright thanks and will do. If my coding is shit well you’re right. I’m still learning alot of this but thanks for the extra info and help.

[editline]31st August 2014[/editline]

Actually now the script is telling me that PS_GivePoints is a nil value but it still gives the points