UpdateText & Spree & Rank System

FinchDon

  • Sr. Member
  • Posts: 252
UpdateText & Spree & Rank System
« on September 6th, 2015, 07:22 AM »Last edited on September 6th, 2015, 04:52 PM
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


Code: [Select]
Code: [Select]
function onPlayerDeath( player, reason )
{
if (GetPlayerSpree(player) >= 1) DecPlayerSpree(player,GetPlayerSpree(player)); // spree system
UpdateText(player);
}
Code: [Select]
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
Code: [Select]
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

Code: [Select]
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

Code: [Select]
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

Code: [Select]
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
Code: [Select]
KillingSpree = 0;

Required Functions

Code: [Select]
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

  • Wiki Contributor
  • Posts: 3,343
Re: UpdateText & Spree & Rank System
« Reply #1, on September 6th, 2015, 07:24 AM »
The spree system has been taken from Warchiefs, anyways good work. I found nothing good in this
We can directly use
Code: [Select]
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
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

FinchDon

  • Sr. Member
  • Posts: 252
Re: UpdateText & Spree & Rank System
« Reply #2, on September 6th, 2015, 07:31 AM »
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

  • VC:MP Beta Tester
  • Posts: 1,688
Re: UpdateText & Spree & Rank System
« Reply #3, on September 6th, 2015, 10:19 AM »
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

  • Sr. Member
  • Posts: 252
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

DizzasTeR

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,168
Re: UpdateText & Spree & Rank System
« Reply #5, on September 6th, 2015, 10:43 AM »
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

  • Sr. Member
  • Posts: 252
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Thijn

  • VC:MP Beta Tester
  • Posts: 1,688

FinchDon

  • Sr. Member
  • Posts: 252
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

FinchDon

  • Sr. Member
  • Posts: 252
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

FinchDon

  • Sr. Member
  • Posts: 252
For any help and support Join #s-s at IRC for Help in Scripting
( For Newbies )

Zeeshan.Bhatti

  • Full Member
  • Posts: 213

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN