[Tutorial] Death and Kill Messages.
#1

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason); // Sends Death Message to evryone in server.
    GivePlayerMoney(killerid,100); // Gives killerid 100$
    GivePlayerMoney(playerid,-100); // Takes playerid which died 100$
    new string[128]; // a new string for killerid length 128.
    new diedguy[MAX_PLAYER_NAME]; // Formating name of guy which died.
    new killerguy[MAX_PLAYER_NAME]; // Formating name of guy which killed the other player.
    new gunname[32]; // variable to store weapon name.
    GetWeaponName(reason,gunname,sizeof(gunname)); // Formating reason with gunname.
    GetPlayerName(killerid,killerguy,sizeof(killerguy)); // Formating killer name.
    GetPlayerName(playerid,diedguy,sizeof(diedguy)); // Formating died guy name.
    format(string,sizeof(string),"[SERVER]:Good job on killing %s with %s you got 100$ as reward.",diedguy,gunname); // formating the string with died guy and gunname.
    format(string,sizeof(string),"[SERVER]:You were killed by %s using %s you lost 100$",killerguy,gunname); // Same as first string.
    SendClientMessage(playerid,COLOR_YELLOW,string);// String sended to guy which died.
    SendClientMessage(killerid,COLOR_YELLOW,string); // String sended to guy which got the kill.
    return 1;
}
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason); // Sends Death Message to evryone in server.
    GivePlayerMoney(killerid,100); // Gives killerid 100$
    GivePlayerMoney(playerid,-100); // Takes playerid which died 100$
    new string[128]; // a new string for killerid length 128.
    new diedguy[MAX_PLAYER_NAME]; // Formating name of guy which died.
    new killerguy[MAX_PLAYER_NAME]; // Formating name of guy which killed the other player.
    new gunname[32]; // variable to store weapon name.
    GetWeaponName(reason,gunname,sizeof(gunname)); // Formating reason with gunname.
    GetPlayerName(killerid,killerguy,sizeof(killerguy)); // Formating killer name.
    GetPlayerName(playerid,diedguy,sizeof(diedguy)); // Formating died guy name.
    format(string,sizeof(string),"[SERVER]:Good job on killing %s with %s you got 100$ as reward.",diedguy,gunname); // formating the string with died guy and gunname.
    SendClientMessage(killerid,COLOR_YELLOW,string); // String sended to guy which got the kill.
    format(string,sizeof(string),"[SERVER]:You were killed by %s using %s you lost 100$",killerguy,gunname); // Same as first string.
    SendClientMessage(playerid,COLOR_YELLOW,string);// String sended to guy which died.
    return 1;
}
more better no need for string2 only will make compiling slow (by a bit if u keep using it like that slowly slowly will effect a lot)
Reply
#3

Quote:
Originally Posted by AroseKhanNaizi
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason); // Sends Death Message to evryone in server.
    GivePlayerMoney(killerid,100); // Gives killerid 100$
    GivePlayerMoney(playerid,-100); // Takes playerid which died 100$
    new string[128]; // a new string for killerid length 128.
    new diedguy[MAX_PLAYER_NAME]; // Formating name of guy which died.
    new killerguy[MAX_PLAYER_NAME]; // Formating name of guy which killed the other player.
    new gunname[32]; // variable to store weapon name.
    GetWeaponName(reason,gunname,sizeof(gunname)); // Formating reason with gunname.
    GetPlayerName(killerid,killerguy,sizeof(killerguy)); // Formating killer name.
    GetPlayerName(playerid,diedguy,sizeof(diedguy)); // Formating died guy name.
    format(string,sizeof(string),"[SERVER]:Good job on killing %s with %s you got 100$ as reward.",diedguy,gunname); // formating the string with died guy and gunname.
    SendClientMessage(killerid,COLOR_YELLOW,string); // String sended to guy which got the kill.
    format(string,sizeof(string),"[SERVER]:You were killed by %s using %s you lost 100$",killerguy,gunname); // Same as first string.
    SendClientMessage(playerid,COLOR_YELLOW,string);// String sended to guy which died.
    return 1;
}
more better no need for string2 only will make compiling slow (by a bit if u keep using it like that slowly slowly will effect a lot)
Yeh sure dunno why i used 2 strings.
Reply
#4

nice
Reply
#5

Wrongly edited, though. I'll leave you to figure it out since it's such a short piece of code.
Reply
#6

What you did will send the message "you were killed by....." to both the killer and the player.

You should check the example, the first guy gave to figure out what mistake you did.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)