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
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
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
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.
because this will move faster change faster
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.
i don't know what you are talking about?
Quote from: FinchDon on Sep 06, 2015, 10:21 AMi don't know what you are talking about?
Of course you don't...
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.
And why do u repeat the local reward 2 times?
reward? which
in ur spree shit
Blind? or what I already post this is not my spree system
Good work
But its upon you to edit it and post it.
@FinchDon - Look the spree system and just remove one local reward = GetPlayerSpree(player) * 500; since both the lines are the same then I think there will no occur in console/server.
I think it'll double the reward
updated
NOW TELL ME WHAT'S THE NEED OF UpdateTextAll
updatetextall is use for everyplayer in server not one
What's the need? You don't use any timers to update it.
If you are doing like that, then use a foreach loop to update current players
*Sorry for BUMP*
btw,
Can we do the Criminal rank system using switch-case, I think we can't
Yes you can its easy to do if you know it
Code removed..
.
Actually i could be implemented with case but it will create a huge code i would suggest you to do not use cases
I can do it that way the problem was:-
He used some symbols like <=, I was in doubt, and are u sure the function you made will work?
Me?? If Yes My Code will work 100% Then it your choice to set kills where and where and rank names
This(Getrank) system can be done with a easy and better way tho, here is a example code
function GetRank( player )
{
local kill = stats[ player.ID ].Kills,a;
if(kill<=100) return "Newbie";
else if(kill<=200) return "Adventurer";
else if(kill<=300) return "Dangerous";
else if(kill<=350) return "Fighter";
else if(kill<=400) return "Street Thug";
else if(kill<460) return "Legolas";
else if(kill<=560) return "Hustler";
else if(kill<=650) return "Bully";
else if(kill<=1000) return "Outlaw";
else if(kill<=1400) return "Assassin";
else if(kill<=1900) return "Murderous";
else if(kill<=2500) return "Psychotic";
else if(kill<=3550) return "Boss";
else if(kill<=5000) return "Don";
else if(kill<=10000) return "Godfather";
else if(kill<=20000) return "Hax0r";
}
Its tested.
[mergedate]1442670710[/mergedate]
The IncCash function u gave is wrong, its like set money because you used '=' instead of '+=', hope you understood
Here is the correct code, update it.
function IncCash( player, amount )
{
local cash = player.Cash
local add = cash + amount;
player.Cash += add;
}
And yes, use player.Cash, not everyone has the same array as u have
This one is good, add this
function onPlayerJoin( player )
{
Ranks <- CreateTextdraw("Your Rank: " + GetRank( player ),41,480,0x99990000 );
Ranks.ShowForPlayer( player );
}
Its kinda useful!
Will You Please Stop Bumping? I release full tested Snippet
I was just trying to improve it with less lines
Quote from: KAKAN on Sep 19, 2015, 01:55 PMThe IncCash function u gave is wrong, its like set money because you used '=' instead of '+=', hope you understood
Here is the correct code, update it.
function IncCash( player, amount )
{
local cash = player.Cash
local add = cash + amount;
player.Cash += add;
}
And yes, use player.Cash, not everyone has the same array as u have
That code is wrong as well, since it will increase the cash twice.
Oh, got it, Thanks Thijn, here is the corect one then :D
function IncCash( player, amount )
{
local add = amount
player.Cash += amount
}
Quote from: KAKAN on Sep 20, 2015, 04:17 AMOh, got it, Thanks Thijn, here is the corect one then :D
function IncCash( player, amount )
{
local add = amount
player.Cash += amount
}
Why did you create the 'add' variable?
I just copy pasted it and forgot to remove it, btw is it necessary?
Can't you just use switch ?
Its way better and faster.
Quote from: rObInX on Sep 20, 2015, 08:04 AMCan't you just use switch ?
Its way better and faster.
I don't get to what u mean, you mean to use switch case? If yes, then probably I have asked the question How, so tell me too if u can
Topic is Getting Out of Control