• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[TUT][508/317]Kill counter

Junior Spellweaver
Joined
Nov 25, 2008
Messages
180
Reaction score
2
Ok, well this tutorial will show you how to make a simple kill counter.

Firstly we will need to make an int, I will call it deathCount.
Code:
public static int deathCount = 0;
This integer is public, so anything we add to it will change for the whole server. We do not need to add saving as this is for how many kills happend on the server from when it restarted (Per day or what ever).

So, then we need to add the code to +1 for each death, so you will need to find your death process then add the following code to it
Code:
p.deathCount = +1;
That is the code for 508, for 317 I think you just take off the 'p.'

Now we need to display the message to the server (in a command or when you click on an interface, I will show you how to do it when you click on an interface.

508:
Code:
case #;
p.frames.sendMessage(p, "So far today " +p.deathCount+ " players have died on SERVERNAME";
break;

317:
Code:
case #;
sendMessage("So far today " +deathCount+ " players have died on SERVERNAME";
break;
 
right + down + X
Loyal Member
Joined
May 25, 2006
Messages
1,688
Reaction score
298
Not bad... I'd use this in combination with a pvp-type minigame... But have it player based, and have like a top 5 or w/e. Good to see a new post by you :3
 
Junior Spellweaver
Joined
Nov 25, 2008
Messages
180
Reaction score
2
Hmmm, well in EvolutionScape we are using this for a public kill counter (see how many players have died obviosly).

You can also use this method in a death process, say you wanted a player kill count for how many men they have killed you would simply do:
int playerManKillcount = 1;

then in the NPC death process (making sure your NPC methods read p.) you would add:
if (npcID = 1) {
p.playerManKillcount = +1;
}

It's easy to apply this code to a range of different games, minigames whatever throughout the server.
 
Back
Top