[Tutorial] How to create a Killing Spree system. Best for TDM/DM servers.
#1

[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(playeridkilleridreason)
{
    
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(stringsizeof(string), "%s is on a killing spree of %d kills. Junior Killer!"Name(killerid), Spree[killerid]);
            
SendClientMessageToAll(COLOR_NAVYstring);
            
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 10 kills. +2 score");
            
GivePlayerScore(killerid2);
        }
        else if(
Spree[killerid] == 20)//For 20 kills
        
{
             
format(stringsizeof(string), "%s is on a killing spree of %d kills. Senior Killer!"Name(killerid), Spree[killerid]);
            
SendClientMessageToAll(COLOR_NAVYstring);
             
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 20 kills. +4 score");
             
GivePlayerScore(killerid4);
        }
        else if(
Spree[killerid] == 30)//30 kills
        
{
             
format(stringsizeof(string), "%s is on a killing spree of %d kills. Master Killer!"Name(killerid), Spree[killerid]);
             
SendClientMessageToAll(COLOR_NAVYstring);
               
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 30 kills. +6 score");
               
GivePlayerScore(killerid6);
        }
        else if(
Spree[killerid] == 40)//40 kills
        
{
             
format(stringsizeof(string), "%s is on a killing spree of %d kills. General Killer!"Name(killerid), Spree[killerid]);
            
SendClientMessageToAll(COLOR_NAVYstring);
            
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 40 kills. +8 score");
            
GivePlayerScore(killerid8);
        }
        else if(
Spree[killerid] == 50)//50 kills
        
{
             
format(stringsizeof(string), "%s is on a killing spree of %d kills. Insane Killer!"Name(killerid), Spree[killerid]);
            
SendClientMessageToAll(COLOR_NAVYstring);
            
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 50 kills. +10 score");
            
GivePlayerScore(killerid10);
        }
        else if(
Spree[killerid] == 60)//60 kills
        
{
             
format(stringsizeof(string), "%s is on a killing spree of %d kills. God Killer!"Name(killerid), Spree[killerid]);
            
SendClientMessageToAll(COLOR_NAVYstring);
            
SendClientMessage(killeridCOLOR_GREEN"You are on a killing spree of 60 kills. +12 score");
            
GivePlayerScore(killerid12);
        }
    }
    return 
1;
}
stock Name(playerid)
{
    new 
name[24];
    
GetPlayerName(playeridname24);
    return 
name;
}
stock GivePlayerScore(playeridscore)
{
    
SetPlayerScore(playeridGetPlayerScore(playerid)+score);
    return 
1;

Reply
#2

nice thing !
Reply
#3

Nice one bro
Reply
#4

Nice I Like it
Reply
#5

Due to this, I made a nuke system thanks dude
Reply
#6

Good, but check whether the killerid is valid player or not. It can cause crashes:
pawn Code:
Spree[killerid]++;
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.
Reply
#7

Thnaks
Reply
#8

There's an easy way to do so by using a modulo operator.
PHP Code:
if(Spree[killerid] % 10 == 0)
{
// Action

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)