How to create a Killing Spree system. Best for TDM/DM servers. -
ThePhenix - 24.07.2013
[CENTER]
Killing Spree system
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;
}
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
kartik - 24.07.2013
nice thing !
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
qazwsx - 25.07.2013
Nice one bro
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
nrg700 - 30.07.2013
Nice I Like it
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
Calvingreen17 - 06.08.2013
Due to this, I made a nuke system
![Cheesy](images/smilies/biggrin.png)
thanks dude
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
Konstantinos - 06.08.2013
Good, but check whether the killerid is valid player or not. It can cause crashes:
Let's say, you die by falling. The killerid will be INVALID_PLAYER_ID (65535) and that's out of bounds.
The same goes for the rest if statements.
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
VenomMancer - 07.03.2014
Thnaks
Re: How to create a Killing Spree system. Best for TDM/DM servers. -
CrazyFrenzy - 07.03.2014
There's an easy way to do so by using a modulo operator.
PHP Code:
if(Spree[killerid] % 10 == 0)
{
// Action
}