Before I start.. please note... TEST THIS ON A COPY OF YOUR SERVER BECAUSE IT WILL RESET PLAYER FILES!!!
Don't cry to me say omgomgom my dood iz delted (
Purpose: To determine how many minutes you've been online ever since you started! (Well, since you added this code.)
Difficulty: I'd say 3/10
Assumed Knowledge: Know how/where to add things. basic java..
Server Base: I used Testscape. Should work on all? I don't know.
Classes Modified: Client.java, PlayerSave.java
Procedure
Step 1: Open your Client.java and do a search for
Code:
playerXP = loadgame.playerXP;
You should see something like this
Code:
playerItems = loadgame.playerItem;
playerItemsN = loadgame.playerItemN;
playerEquipment = loadgame.playerEquipment;
playerEquipmentN = loadgame.playerEquipmentN;
bankItems = loadgame.bankItems;
bankItemsN = loadgame.bankItemsN;
playerLevel = loadgame.playerLevel;
playerXP = loadgame.playerXP;
... At the end of playerXP = loadgame.playerXP; put
Code:
playerGameTime = loadgame.playerGameTime;
.
Step 2: do a search for
Code:
ResetBonus();
GetBonus();
WriteBonus();
Poisoned = false;
which is basically your startup stuffs. add
Code:
GetLastLogin(playerGameTime);
after Poisoned = false;
Step 3: Declare
Code:
sendFrame126("@yel@Play Time: @whi@" +playerGameTime+ " min.", 6664);
in the boolean process ... If you have something there already, such as coords or something, you should move them to a different frame.
If you don't have any text that shows at the top of your screen, add
Code:
sendFrame126("", 6570);
sendFrame126("", 6572);
Step 4: Search for this
Code:
//GameTime
playerGameCount++;
if (playerGameCount == 120000) { //evry minute
playerGameTime++;
playerGameCount = 0;
}
.. replace it with
Code:
//GameTime
playerGameCount++;
if (playerGameCount == 180) { //every minute
playerGameTime++;
playerGameCount = 0;
}
[OPTIONAL] Step 5: Under Gametime should be something like
Code:
if ((playerGameTime % 1440) == 0) { //1440 minutes = 24 hours
for (int i = 0; i < bankItems.length; i++) {
if (bankItems[i] == 995) {
bankItemsN[i] += ((bankItemsN / 100) * 4); //increase money like in real banks (4% rente)
}
}
}
... This adds to your money in bank after 24 hours of gameTime.. I don't know if it works, but you can keep it and tell me if you want to or not .
-----Your done in Client.java-----
Now open PlayerSave.java.
Step 6: Your playerSave.java should look similar to this
Code:
import java.io.*;
public class PlayerSave implements Serializable
{
public String playerPass="";
public String playerName="";
//public String connectedFrom=""; //Don't enable this yet, or the old save-files get corrupted
public int playerPosX;
public int playerPosY;
public int playerHeight;
public int playerRights;
public int playerStatus;
public int playerHeadIcon;
public int[] playerItem;
public int[] playerItemN;
public int[] playerEquipment;
public int[] playerEquipmentN;
public int[] bankItems;
public int[] bankItemsN;
public int[] playerLevel;
public int[] playerXP;
public int[] playerQuest;
public int currentHealth;
public int maxHealth;
public PlayerSave(Player plr)
{
playerPass = plr.playerPass;
playerName = plr.playerName;
playerPosX = plr.absX;
playerPosY = plr.absY;
playerHeight = plr.heightLevel;
playerRights = plr.playerRights;
playerItem = plr.playerItems;
playerItemN = plr.playerItemsN;
bankItems = plr.bankItems;
bankItemsN = plr.bankItemsN;
playerEquipment = plr.playerEquipment;
playerEquipmentN = plr.playerEquipmentN;
playerLevel = plr.playerLevel;
maxHealth = plr.playerLevel[3];
currentHealth = plr.maxHealth;
playerXP = plr.playerXP;
//connectedFrom = plr.connectedFrom;
}
}
...
Under
Code:
public int maxHealth;
, add
Code:
public int playerGameTime;
... and under
Code:
//connectedFrom = plr.connectedFrom;
, add
Code:
playerGameTime = plr.playerGameTime;
*From there on you can do what you like with the gameTime that has been added. What I did was make a command that told everyone how long you've been playing .
When completed if should look like this below. However, your's will not say "Evilscape Server" at the top.
Credits: This was my idea!! If you claim I "leeched it" from somewhere, please provide proof.
I do NOT have a moparscape account, or anywhere else. If you see this ANYWHERE else, it was leeched!!!