[Tutorial] Death and Kill Messages. - 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: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Death and Kill Messages. (
/showthread.php?tid=538583)
Death and Kill Messages. -
Gogeta101 - 22.09.2014
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;
}
Re: Death and Kill Messages. -
AroseKhanNiazi - 22.09.2014
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)
Re: Death and Kill Messages. -
Gogeta101 - 22.09.2014
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.
Re: Death and Kill Messages. -
KayJ - 23.09.2014
nice
Re: Death and Kill Messages. -
Vince - 23.09.2014
Wrongly edited, though. I'll leave you to figure it out since it's such a short piece of code.
Re: Death and Kill Messages. -
DavidBilla - 23.09.2014
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.