Need Help Figuring the hook to use!?

Hey Guys, ive been seaching through the wiki and i cant seem to find the hook to use for this, the hook need to be able to make it where if the player gets a kill then it will give the player “1” point.
Here is the code :slight_smile:
[lua]
//Saving Ranks/Loading/Opening

hook.Add( “PlayerDisconnected”, “saveranknow”, function( ply ) – Save when the player kills? Maybe?
ply:SaveRank()
MsgN( “Points Saved” )
end )
hook.Add( “PlayerSpawn”, “tiredofthis”, function( ply )
ply:LoadRank()
end )
hook.Add( “”, “Whentheygetpoints”, function( ply ) --Dont Know the Hook!?
ply:AddRank( 1 )
end )
[/lua]
Thanks Guys :slight_smile:

PlayerDeath is the hook.

The 3 arguments are victim, weapon_used ie inflictor, attacker

Ok so it should look something like this? ( btw ive had problems with attacker )

[lua]
hook.Add( “PlayerDeath”, “Hatethiscantworkwithoutthisdumbtext”, function( victim, weapon, killer, ply )
if killer:IsPlayer() and victim:IsBot() then
ply:AddRank( 1 )
end
end )
[/lua]

[editline]2nd September 2014[/editline]

Change that to “IsPlayer” not “IsBot”

There are only 3 arguments


hook.Add( "PlayerDeath", "Hatethiscantworkwithoutthisdumbtext", function( _victim, _weapon, _killer )
	if ( !IsValid( _victim ) || !IsValid( _killer ) || !_killer:IsPlayer( ) ) then return; end

	// Only give points if killer killed a bot??? Why not if they kill a player?
	if ( _victim:IsBot( ) ) then
		killer:AddRank( 1 );
	end
end );

Ok so i learn something out of this…can i be explain whats the difference between
[lua]
IsValid
[/lua]
and
[lua]
!IsValid
[/lua]
Ive never really known why? Any also why do you put underscores with the argument?

The ! Operator simply reverses the boolean. Ie !true == false. And vise versa.

He puts underscores since it’s his style. No particular reason as far as I know.

Oh ok, gotcha, and while your here can you tell me if the chat print thing looks ok?
[lua]
hook.Add( “PlayerDeath”, “Hatethiscantworkwithoutthisdumbtext”, function( victim, weapon, killer )
if ( !IsValid( victim ) || !IsValid( killer ) || !killer:IsPlayer( ) ) then return; end
if ( victim:IsBot( ) ) then
killer:AddRank( 1 )
killer:ChatPrint( Color( 255, 255, 255), “You Earned”, Color( 255, 255, 0 ), " 1", Color( 255, 255, 255 ), " EXP for killing ", Color( 255, 255, 0 ), victim:Nick(), “” );
end
end );
[/lua]

Maybe tell them what they earned instead of "You Earned 1 for killing …

No need for last , “”

Yea i edited it :stuck_out_tongue: I caught that at the last second and ok :stuck_out_tongue: :slight_smile: Thanks

[editline]2nd September 2014[/editline]

Woah hold on, says string expected not a table ( ERROR ), Thats weird because its still has a string? Maybe take away the color in the front?

EDIT: Ok for some reason the color change wont work? so would chat.AddText do ok? Or will that send to everyone.

Use networking since chat.addtext is clentside. And maybe if you read documentation for functions you would notice ChatPrint only takes a string.