Код:
public OnPlayerDeath(playerid,killerid,reason)
{
// sending the death message icon
if(IsPlayerConnected(killerid)) SendDeathMessage(killerid, playerid, reason);
// Getting the player's Health pickup
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
Health[playerid] = CreatePickup(1240,4,x,y,z+0.2,GetPlayerVirtualWorld(playerid));
SetTimerEx("Health_Timer", 15000, false, "i", playerid); // it's to destroy the pickup near the dead player's body if no one will take it. (15 seoncds)
// Kills Deaths & Ratio TD.
PlayerKills[killerid]++; // Addes a score to player killed.
PlayerDeaths[playerid]++; // Addes a score to player death.
new iString[100]; // string cells.
format(iString, sizeof iString, "Kills: %i", PlayerKills[killerid]); // Here we put the amout of Killed players.
TextDrawSetString(KILLS[killerid], iString);
format(iString, sizeof iString, "Deaths: %i", PlayerDeaths[playerid]); // Here we put the amout of Deaths.
TextDrawSetString(DEATHS[playerid], iString);
format( iString, sizeof( iString ), "Ratio: %.2f", floatdiv(PlayerKills[playerid], PlayerDeaths[playerid]));
TextDrawSetString(RATIO[playerid], iString);
// Killing spree system.
PlayerTotalKills[killerid]++;
PlayerTotalKills[playerid] = 0;
// Killing Spree on 2 killed players
if(PlayerTotalKills[killerid] == 2) {
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "{F5A9E1}(SIMPLE!) %s is on a killing spree with 2 killed players! and earns (+5 points, + 10 score +100 respect) !",name);
SendClientMessageToAll(-1, string);
format(iString, sizeof iString, "KillingSpree: %d", PlayerTotalKills[killerid]); // TD's format to the actual KillingSpree system.
TextDrawSetString(KILLINGSPREE[playerid], iString);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 10);
pInfo[killerid][Score] += 10;
pInfo[killerid][Points] += 5;
pInfo[killerid][Respect] += 100;
GameTextForPlayer(playerid,"~y~+5", 500,4);
}
// Killing Spree on 4 killed players
if(PlayerTotalKills[killerid] == 4) {
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "{F5A9E1}(AMAZING!) %s is on a killing spree with 2 killed players! and earns (+10 points, + 20 score +200 respect) !",name);
SendClientMessageToAll(-1, string);
format(iString, sizeof iString, "KillingSpree: %d", PlayerTotalKills[killerid]); // TD's format to the actual KillingSpree system.
TextDrawSetString(KILLINGSPREE[playerid], iString);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 20);
pInfo[killerid][Score] += 20;
pInfo[killerid][Points] += 10;
pInfo[killerid][Respect] += 200;
GameTextForPlayer(playerid,"~y~+10", 500,4);
}
// Killing Spree on 8 killed players
if(PlayerTotalKills[killerid] == 8) {
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "{F5A9E1}(JACKER!) %s is on a killing spree with 2 killed players! and earns (+15 points, + 30 score +300 respect) !",name);
SendClientMessageToAll(-1, string);
format(iString, sizeof iString, "KillingSpree: %i", PlayerTotalKills[killerid]); // TD's format to the actual KillingSpree system.
TextDrawSetString(KILLINGSPREE[killerid], iString);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 30);
pInfo[killerid][Score] += 30;
pInfo[killerid][Points] += 15;
pInfo[killerid][Respect] += 300;
GameTextForPlayer(killerid,"~y~+15", 500,4);
}
// Killing Spree on 12 killed players
if(PlayerTotalKills[killerid] == 12) {
new string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(killerid, name, sizeof(name));
format(string, sizeof(string), "{F5A9E1}(WANTED!) %s is on a killing spree with 2 killed players! and earns (+20 points, + 40 score +400 respect) !",name);
SendClientMessageToAll(-1, string);
format(iString, sizeof iString, "KillingSpree: %i", PlayerTotalKills[killerid]); // TD's format to the actual KillingSpree system.
TextDrawSetString(KILLINGSPREE[killerid], iString);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 40);
pInfo[killerid][Score] += 40;
pInfo[killerid][Points] += 20;
pInfo[killerid][Respect] += 400;
GameTextForPlayer(killerid,"~y~+20", 500,4);
}
// If player kills someone he will be awarded with +1 point level and +50 respect
SendClientMessage(killerid, -1,"{9FF781}* Player killed! and awarded with (+1 point level, +15 score and +50 respect) !");
SendClientMessage(killerid, -1,"{D8D8D8}(INFO) You earned +50 respect !");
pInfo[killerid][Points] += 1;
pInfo[killerid][Respect] += 50;
SetPlayerScore(killerid, GetPlayerScore(killerid) + 15);
pInfo[killerid][Score] += 15;
GameTextForPlayer(killerid,"~y~+15", 400,4);
// If player die he will lose -5 points and -20 respect
SendClientMessage(playerid, -1,"{FA5858}* You got killed! and suddenly lost (-3 points, -5 score and -20 respect lost) !");
SendClientMessage(playerid, -1,"{D8D8D8}(INFO) You lost -20 respect !");
pInfo[playerid][Points] -= 3;
pInfo[playerid][Respect] += -20;
SetPlayerScore(playerid, GetPlayerScore(playerid) - 5);
GameTextForPlayer(playerid,"~r~-5", 400,4);
pInfo[playerid][Score] -= 5;
// Saving kills and deaths on player's config file.
if(killerid != INVALID_PLAYER_ID) // Checking if the killer of the player is valid.
{
//Increasing the kills of the killer and the deaths of the player.
pInfo[killerid][Kills]++;
pInfo[playerid][Deaths]++;
}
if(IsBeingSpectated[playerid] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(spectarget[i] == playerid)
{
TogglePlayerSpectating(i, false);
}
}
}
return 1;
}