PDA

View Full Version : Have no clue why it won't work!


GXLZPGX
06-27-2010, 10:17
These two should work fine together:

RegisterHam( Ham_Killed, "player", "player_killed", 1 )

+

public player_killed( iVictim, iAttacker )
{
new iAttacker = read_data(1)
new iVictim = read_data(2)

if( iVictim == iAttacker )
return PLUGIN_HANDLED

if( cs_get_user_team( iVictim ) == CS_TEAM_CT )
{
gShouldSwitch[iVictim] = true
gShouldSwitch[iAttacker] = true
iPoints[iAttacker] += 35
client_print_color( iAttacker, Blue, "^4[DoA] You gained^3 35 iPoints!" )
client_print_color( iVictim, Red, "^4[DoA] You have been killed, and will spawn as a ^3zombie^4 next round." )
}
else if( cs_get_user_team( iVictim ) == CS_TEAM_T )
{
iPoints[iAttacker] += 35
client_print_color( iAttacker, Red, "^4[DoA] You gained^3 35 iPoints!" )
client_print_color( iVictim, Red, "^4[DoA]^3 I trust you will do better next time.." )
}

return PLUGIN_HANDLED;
}

It won't display the message or add the points. Should I register a death message like this?

register_event("DeathMsg", "EventDeathMsg", "a");

public EventDeathMsg()
{
new iAttacker = read_data(1)
new iVictim = read_data(2)

if( iVictim == iAttacker )
return PLUGIN_HANDLED

if( cs_get_user_team( iVictim ) == CS_TEAM_CT )
{
gShouldSwitch[iVictim] = true
gShouldSwitch[iAttacker] = true
iPoints[iAttacker] += 35
client_print_color( iAttacker, Blue, "^4[DoA] You gained^3 35 iPoints!" )
client_print_color( iVictim, Red, "^4[DoA] You have been killed, and will spawn as a ^3zombie^4 next round." )
}
else if( cs_get_user_team( iVictim ) == CS_TEAM_T )
{
iPoints[iAttacker] += 35
client_print_color( iAttacker, Red, "^4[DoA] You gained^3 35 iPoints!" )
client_print_color( iVictim, Red, "^4[DoA]^3 I trust you will do better next time.." )
}

return PLUGIN_HANDLED;
}

EDIT: WHEN I REGISTERED A DEATH MESSAGE IT WORKED

drekes
06-27-2010, 11:07
Don't use read_data in Ham_Killed, use params instead.

Alucard^
06-27-2010, 11:11
Like drekes said, Ham_Killed detect automatically the killer and the victim... just here:

( iVictim, iAttacker )

You only have to use as you want...

read_data( ) is for events.