SA-MP Forums Archive
OnPlayerDeath - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerDeath (/showthread.php?tid=236835)



OnPlayerDeath - yoan103 - 08.03.2011

When someone is killed i want to give the killer 1000 $ and to say this "You have killed "playername" and earned 1000 $"-that's for the killer, and for the playerid who has been killed "You have been killed by "killername". Is it possible


Re: OnPlayerDeath - Stigg - 08.03.2011

Yes it is possible and easy to impliment.


Re: OnPlayerDeath - yoan103 - 08.03.2011

Could you please write the script? , I am a little new to this!


Re: OnPlayerDeath - Roomeo - 08.03.2011

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    GivePlayerMoney(killerid, 1000);
    SendClientMessage(killerid, Here Color, "You Killed Him");
    GivePlayerMoney(playerid, -1000);
    SendClientMessage(playerid, "you Have Been Killed");
    return 1;
}



Re: OnPlayerDeath - yoan103 - 08.03.2011

I want it to say who the killerid killed, and the playerid to see who has killed him


Re: OnPlayerDeath - tuuker - 08.03.2011

use strings then
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128],killed[MAX_PLAYER_NAME],killer[MAX_PLAYER_NAME];
    GetPlayerName(playerid,killed,sizeof(killed));
    GetPlayerName(killerid,killer,sizeof(killer));
    format(string,sizeof(string),"%s has been killed by %s",killed,killer);
    SendClientMessage(playerid,0xAA3333AA,string);
    return 1;
}



Re: OnPlayerDeath - Stigg - 08.03.2011

Quote:
Originally Posted by tuuker
Посмотреть сообщение
use strings then
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[128],killed[MAX_PLAYER_NAME],killer[MAX_PLAYER_NAME];
    GetPlayerName(playerid,killed,sizeof(killed));
    GetPlayerName(killerid,killer,sizeof(killer));
    format(string,sizeof(string),"%s has been killed by %s",killed,killer);
    SendClientMessage(playerid,0xAA3333AA,string);
    return 1;
}
I totally agree. Nice and easy.
But if you have alot of players killing each other, it will spam your chatbox area abit.


Re: OnPlayerDeath - tuuker - 08.03.2011

Quote:
Originally Posted by yoan103
Посмотреть сообщение
I want it to say who the killerid killed, and the playerid to see who has killed him
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new tokiller[128],tokilled[128],killed[MAX_PLAYER_NAME],killer[MAX_PLAYER_NAME];
    GetPlayerName(playerid,killed,sizeof(killed));
    GetPlayerName(killerid,killer,sizeof(killer));
    format(tokiller,sizeof(tokiller),"You have killed %s and earned 1000$",killed);
    SendClientMessage(killerid,0xAA3333AA,tokiller);
    format(tokilled,sizeof(tokilled),"You have been killed by %s",killer);
    GivePlayerMoney(killerid,1000);
    return 1;
}



Re: OnPlayerDeath - Davz*|*Criss - 08.03.2011

Simple one lol.


Re: OnPlayerDeath - HyperZ - 08.03.2011

Quote:
Originally Posted by tuuker
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new tokiller[128],tokilled[128],killed[MAX_PLAYER_NAME],killer[MAX_PLAYER_NAME];
    GetPlayerName(playerid,killed,sizeof(killed));
    GetPlayerName(killerid,killer,sizeof(killer));
    format(tokiller,sizeof(tokiller),"You have killed %s and earned 1000$",killed);
    SendClientMessage(killerid,0xAA3333AA,tokiller);
    format(tokilled,sizeof(tokilled),"You have been killed by %s",killer);
    GivePlayerMoney(killerid,1000);
    return 1;
}
You forgot to add SendClientMessage to Playerid.

Fixed Code:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new
        tokiller[128],
        tokilled[128],
        killed[MAX_PLAYER_NAME],
        killer[MAX_PLAYER_NAME]
    ;

    GetPlayerName(playerid,killed,sizeof(killed));

    GetPlayerName(killerid,killer,sizeof(killer));
   
    format(tokiller,sizeof(tokiller),"You have killed %s and earned 1000$",killed);
    SendClientMessage(killerid,0xAA3333AA,tokiller);
   
    format(tokilled,sizeof(tokilled),"You have been killed by %s",killer);
    SendClientMessage(playerid,0xAA3333AA,tokilled);
   
    GivePlayerMoney(killerid,1000);
    return 1;
}