24.07.2013, 04:29
(
Last edited by ThePhenix; 19/08/2014 at 07:17 PM.
)
[CENTER]Killing Spree system
Hello.
I'm going to explain how to create a Killing Spree system for TDM/DM servers.
Let's start.
Hello.
I'm going to explain how to create a Killing Spree system for TDM/DM servers.
Let's start.
PHP Code:
#include <a_samp>
new Spree[MAX_PLAYERS];
#define COLOR_NAVY 0x10F441AA
#define COLOR_GREEN 0x33AA33AA
public OnPlayerDeath(playerid, killerid, reason)
{
Spree[playerid] = 0;
new string[100];
if(killerid != INVALID_PLAYER_ID)//to avoid a server crash
{
Spree[killerid]++;
if(Spree[killerid] == 10)//Checking for 10 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. Junior Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 10 kills. +2 score");
GivePlayerScore(killerid, 2);
}
else if(Spree[killerid] == 20)//For 20 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. Senior Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 20 kills. +4 score");
GivePlayerScore(killerid, 4);
}
else if(Spree[killerid] == 30)//30 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. Master Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 30 kills. +6 score");
GivePlayerScore(killerid, 6);
}
else if(Spree[killerid] == 40)//40 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. General Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 40 kills. +8 score");
GivePlayerScore(killerid, 8);
}
else if(Spree[killerid] == 50)//50 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. Insane Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 50 kills. +10 score");
GivePlayerScore(killerid, 10);
}
else if(Spree[killerid] == 60)//60 kills
{
format(string, sizeof(string), "%s is on a killing spree of %d kills. God Killer!", Name(killerid), Spree[killerid]);
SendClientMessageToAll(COLOR_NAVY, string);
SendClientMessage(killerid, COLOR_GREEN, "You are on a killing spree of 60 kills. +12 score");
GivePlayerScore(killerid, 12);
}
}
return 1;
}
stock Name(playerid)
{
new name[24];
GetPlayerName(playerid, name, 24);
return name;
}
stock GivePlayerScore(playerid, score)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
return 1;
}