UpdateText & Spree & Rank System

Started by FinchDon, Sep 06, 2015, 06:22 AM

Previous topic - Next topic

FinchDon

Hello i add this feature in my server since 1 week ago and i wanna share with you guys

This Text Show

Kills Deaths Spree Rank


First of all


function onPlayerDeath( player, reason )
{
if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player)); // spree system
UpdateText(player);
}
function onPlayerKill( killer, player, weapon, bodypart )
{
IncPlayerSpree(killer, 1);  //spree system
   StartKillingSpree(killer);
   EndKillingSpree(player,killer);
   if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player));
UpdateText(killer);
UpdateText(player);
}

Functions
function UpdateTextAll()
{
for (local i=0; i<GetMaxPlayers(); i++)
{
local p=FindPlayer(i);
if(p)
{
UpdateText(p);
}
}
}

function UpdateText(player)
{
local id = player.ID;
local kills = pstats[ player.ID ].Kills; // if you have different you can change
local killeds = pstats[ player.ID ].Deaths;  // if you have different you can change
local Rank = GetCriminalRank( player );
local spree = GetPlayerSpree( player );
Announce("~t~Kills:~b~["+kills+" ] ~y~Deaths:~x~["+killeds+" ] ~b~Rank:~b~["+Rank+" ] ~y~Spree:~t~["+spree+" ]",player,1);
}


Criminal Rank

function GetCriminalRank( player )
{
local kill=pstats[ player.ID ].Kills,a;
if(kill<=100)
    {
                a="Begginer";
        return a;
    }
    else if(kill<=200)
    {
        a="Adventurer";
        return a;
    }
    else if(kill<=300)
    {
        a="Dangerous";
        return a;
    }
    else if(kill<=350)
    {
        a="Fighter";
        return a;
    }
    else if(kill<=400)
    {
        a="Middle One";
        return a;
    }
    else if(kill<460)
    {
        a="Legolas";
        return a;
    }
    else if(kill<=560)
    {
                a="Hustler";
        return a;
    }
    else if(kill<=650)
    {
        a="Bully";
        return a;
    }
    else if(kill<=1000)
    {
        a="Outlaw";
        return a;
    }
    else if(kill<=1400)
    {
        a="Assassin";
        return a;
    }
    else if(kill<=1900)
    {
                a="Murderous";
        return a;
    }
    else if(kill<=2500)
    {
        a="Psychotic";
        return a;
    }
    else if(kill<=3550)
    {
        a="Boss";
        return a;
    }
        else if(kill<=5000)
    {
        a="Don";
        return a;
    }
    else if(kill<=10000)
    {
        a="Godfather";
        return a;
    }
   
        return 0;
}

Spree System

function GetPlayerSpree(player)
{
return pstats[player.ID].KillingSpree;
}
function SetPlayerSpree(player)
{
pstats[player.ID].KillingSpree = 0;
}
function IncPlayerSpree(player,amount)
{
pstats[player.ID].KillingSpree = GetPlayerSpree(player) + amount;
}
function DecPlayerSpree(player,amount)
{
pstats[player.ID].KillingSpree = GetPlayerSpree(player) - amount;
}
//==============================================================================
function SetSpree( player, amount )
{
      QuerySQL(sqliteDB, "UPDATE Spree SET Spree='" +  amount + "' WHERE Name='" + player.Name + "'");   
}

function GetSpree( player )
{
   local lvl11 =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT Spree FROM Spree WHERE Name='" + player.Name+"'" ), 0 );
   if ( lvl11 ) return lvl11;
   else return 0;
}
function StartKillingSpree( player )
{
if ( GetPlayerSpree( player ) >= 5 )
    {
local kills = GetPlayerSpree(player);
if ( kills == 5 ) Message( player + " is on a Killing Spree with " + kills + " kills in a row!  $" + reward + " " );
  else if ( kills == 10 ) Message( player + " is Dangerous!  Killing Spree with " + kills + " kills in a row!  $" + reward + "" );
  else if ( kills == 15 ) Message( player + " is Murderous!!  Deadly Killing Spree with " + kills + " kills in a row!  $" + reward + " " );
  else if ( kills == 20 ) Message( player + " is Psychotic!!!  Insane Killing Spree with " + kills + " kills in a row!  $" + reward + " " );
  else if ( kills == 25 ) Message( player + " is an Assassin!!!!  Professional Killing Spree with " + kills + " kills in a row!  $" + reward + "" );
else if ( ( kills >= 30 ) && ( kills % 5 == 0 ) ) Message( player + " is UNSTOPPABLE!!!!  Untouchable Killing Spree with " + kills + " kills in a row!  $" + reward + "" );
local reward = GetPlayerSpree(player) * 500;
MessagePlayer("Spree reward: $" + reward + " ", player );
IncCash( player, reward.tointeger() );
     }
}
//==============================================================================
function EndKillingSpree( p1, p2 )
{
if ( GetPlayerSpree( p1 ) >= 5 )
    {
    if ( p2 == 255 )
        {
                Message(" " + p1.Name + " has ended their own killing spree.");
                DecPlayerSpree(p1, GetPlayerSpree(p1));
        }
else if ( p2 != 255 )
        {
            Message( p2.Name + " ended " + p1.Name + "'s Killing Spree of " + GetPlayerSpree(p1) + " kills in a row.");
            DecPlayerSpree(p1, GetPlayerSpree(p1));
}
    }
}





Commands

else if ( cmd == "spree" )
    {
local b, plr;
    for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
if ( ( plr ) && ( pstats[ plr.ID ].Logged ) && ( pstats[ plr.ID ].KillingSpree >= 5 ) )
    {
    if ( b ) b = b + " - " + plr.Name + " (Spree: " + pstats[ plr.ID ].KillingSpree + ")";
else b = plr.Name + " (Spree: " + pstats[ plr.ID ].KillingSpree + " )";
}
    }

    if ( b ) Message( "[#FF0000]** Players on Spree:[ " + b + " ]" );
    else Message( "[#00FFFF]** No Players with Spree" );
}
if ( cmd == "stats" )
{
MessagePlayer( "[#FFFFFF]Your Stats Kills " + pstats[ player.ID ].Kills + " Deaths " + pstats[ player.ID ].Deaths Rank " + GetCriminalRank( player ) + " Spree " + GetPlayerSpree( player ) + ".", player );
}
else if ( cmd == "myspree" )
    {
if (GetPlayerSpree(player) <= 4) MessagePlayer("[#FF0000]No Have Spree",player);
else
{
MessagePlayer("[#00FFFF]Your Spree: [ Kills: " + GetPlayerSpree(player) + " ]",player);
}
}


Classes
KillingSpree = 0;

Required Functions

function IncCash( player, amount )
{
      local cash = pstats[ player.ID ].Cash;
  local add = cash + amount;
pstats[ player.ID ].Cash = add;
  player.Cash = add;
}

Note: This Text system is created by Me and Spree System has been taken from old forum

Good Luck

Updated
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

The spree system has been taken from Warchiefs, anyways good work. I found nothing good in this
We can directly use stats[player.ID].Deaths++;or anything we want
It maybe nice for VCCNR scripts but not for DM script, I'm not insulting anyone, just telling ya
oh no

FinchDon

Dude It will Announce Down Your Kills Your Deaths Rank and Spree

and I mentioned Spree system is taken from old forum btw i like that so i post
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Thijn

Why do you use a 1 second timer to keep updating the textdraw? If you arent being killed or kill someone there's no need to update it.

FinchDon

because this will move faster change faster
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

What he means is that you only need to update the text when someone kills anyone else, so running a continuous timer is not necessary.

FinchDon

i don't know what you are talking about?
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Thijn


FinchDon

Quote from: Thijn on Sep 06, 2015, 09:19 AMWhy do you use a 1 second timer to keep updating the textdraw? If you arent being killed or kill someone there's no need to update it.

Sorry Removed.
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

And why do u repeat the local reward 2 times?
oh no

FinchDon

For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

oh no

FinchDon

Blind? or what I already post this is not my spree system
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

SAzEe21


KAKAN

But its upon you to edit it and post it.
oh no