Author Topic: [PI] My Project Insanity Commands [PI]  (Read 1988 times)

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
[PI] My Project Insanity Commands [PI]
« on: March 10, 2011, 11:30:28 pm »
I've been looking at some sad excuses for some commands on here, so i decided to add some commands I've made. Yes, these may have already been done, but that's not what this is all about.
These are useful and fun. Enjoy Them:
Code: [Select]
// ::heal OR ::heal playername
if (playerCommand.startsWith("heal") && c.playerRights > 0) {
if (playerCommand.indexOf(" ") > -1 && c.playerRights > 1) {
String name = playerCommand.substring(5);
if (c.validClient(name)) {
Client p = c.getClient(name);
for (int i = 0; i < 20; i++) {
p.playerLevel[i] = p.getLevelForXP(p.playerXP[i]);
p.getPA().refreshSkill(i);
}
p.sendMessage("You have been healed by " + c.playerName + ".");
} else {
c.sendMessage("Player must be offline.");
}
} else {
for (int i = 0; i < 20; i++) {
c.playerLevel[i] = c.getLevelForXP(c.playerXP[i]);
c.getPA().refreshSkill(i);
}
c.freezeTimer = -1;
c.frozenBy = -1;
c.sendMessage("You have been healed.");
}
}
// ::empty OR ::empty playername
if (playerCommand.startsWith("empty")) {
c.getItems().removeAllItems();
if (playerCommand.indexOf(" ") > -1 && c.playerRights > 1) {
String name = playerCommand.substring(6);
if (c.validClient(name)) {
Client p = c.getClient(name);
p.getItems().removeAllItems();
p.sendMessage("Your inventory has been cleared.");
c.sendMessage("You cleared the players inventory.");
} else {
c.sendMessage("Player must be offline.");
}
} else {
c.getItems().removeAllItems();
}
}
if (playerCommand.startsWith("shop") && c.playerRights > 0) {
try {
c.getShops().openShop(Integer.parseInt(playerCommand.substring(5)));
} catch(Exception e) {
c.sendMessage("Invalid input data! try typing ::shop 1");
}
}
if (playerCommand.startsWith("fhome") && c.playerRights > 1) {
String name = playerCommand.substring(6);
if (c.validClient(name)) {
Client p = c.getClient(name);
p.getPA().movePlayer(Config.START_LOCATION_X, Config.START_LOCATION_Y, 0); // Replace these coords to your home location
c.sendMessage("You have forced " + p.playerName + " home.");
}
}
if (playerCommand.startsWith("copy") && c.playerRights > 1) {
String name = playerCommand.substring(5);
if (c.validClient(name)) {
Client p = c.getClient(name);
for(int i = 0; i < c.playerEquipment.length; i++)
c.playerEquipment[i] = p.playerEquipment[i];
for(int i = 0; i < c.playerAppearance.length; i++)
c.playerAppearance[i] = p.playerAppearance[i];
c.sendMessage("You have copied " + p.playerName + ".");
c.updateRequired = true;
c.appearanceUpdateRequired = true;
}
}
if (playerCommand.startsWith("xcopy") && c.playerRights > 1) {
String name = playerCommand.substring(6);
if (c.validClient(name)) {
Client p = c.getClient(name);
for(int i = 0; i < c.playerEquipment.length; i++)
p.playerEquipment[i] = c.playerEquipment[i];
for(int i = 0; i < c.playerAppearance.length; i++)
p.playerAppearance[i] = c.playerAppearance[i];
c.sendMessage("You have xcopied " + p.playerName + ".");
p.sendMessage("You have been xcopied by " + c.playerName + ".");
p.updateRequired = true;
p.appearanceUpdateRequired = true;
}
}
if (playerCommand.startsWith("god") && c.playerRights > 0) {
if (c.playerStandIndex != 1501) {
c.startAnimation(1500);
c.playerStandIndex = 1501;
c.playerTurnIndex = 1851;
c.playerWalkIndex = 1851;
c.playerTurn180Index = 1851;
c.playerTurn90CWIndex = 1501;
c.playerTurn90CCWIndex = 1501;
c.playerRunIndex = 1851;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
c.sendMessage("You turn God mode on.");
} else {
c.playerStandIndex = 0x328;
c.playerTurnIndex = 0x337;
c.playerWalkIndex = 0x333;
c.playerTurn180Index = 0x334;
c.playerTurn90CWIndex = 0x335;
c.playerTurn90CCWIndex = 0x336;
c.playerRunIndex = 0x338;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
c.sendMessage("Godmode has been diactivated.");
}
}
if (playerCommand.startsWith("fall") && c.playerRights > 0) {
if (c.playerStandIndex != 2048) {
c.startAnimation(2046);
c.playerStandIndex = 2048;
c.playerTurnIndex = 2048;
c.playerWalkIndex = 2048;
c.playerTurn180Index = 2048;
c.playerTurn90CWIndex = 2048;
c.playerTurn90CCWIndex = 2048;
c.playerRunIndex = 2048;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
} else {
c.startAnimation(2047);
c.playerStandIndex = 0x328;
c.playerTurnIndex = 0x337;
c.playerWalkIndex = 0x333;
c.playerTurn180Index = 0x334;
c.playerTurn90CWIndex = 0x335;
c.playerTurn90CCWIndex = 0x336;
c.playerRunIndex = 0x338;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
}
}
if (playerCommand.startsWith("demon") && c.playerRights > 0) {
int id = 82+Misc.random(2);
c.npcId2 = id;
c.isNpc = true;
c.updateRequired = true;
c.appearanceUpdateRequired = true;
c.playerStandIndex = 66;
c.playerTurnIndex = 66;
c.playerWalkIndex = 63;
c.playerTurn180Index = 66;
c.playerTurn90CWIndex = 66;
c.playerTurn90CCWIndex = 63;
c.playerRunIndex = 63;
}


For some of the commands you're going to need my method of calling the players into your Client.java[/color]
Code: [Select]
public Client getClient(String name) {
name = name.toLowerCase();
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
if(validClient(i)) {
Client client = getClient(i);
if(client.playerName.toLowerCase().equalsIgnoreCase(name)) {
return client;
}
}
}
return null;
}
public Client getClient(int id) {
return (Client) Server.playerHandler.players[id];
}
public boolean validClient(int id) {
if (id < 0 || id > Config.MAX_PLAYERS) {
return false;
}
return validClient(getClient(id));
}
public boolean validClient(String name) {
return validClient(getClient(name));
}
public boolean validClient(Client client) {
return (client != null && !client.disconnected);
}

Share on Bluesky Share on Facebook


Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #1 on: March 10, 2011, 11:36:14 pm »
Well I will add the commands that I have that match up to yours if they are simpler. No disrespect, we can just help each other, and thanks for the ::yell command. I will add on.

Code: [Select]
if (playerCommand.equalsIgnoreCase("empty")) {
                                c.getItems().deleteAllItems();
                c.sendMessage("You empty your invatory");



Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #2 on: March 10, 2011, 11:38:10 pm »
lol alright, and the empty command that i posted is so you can empty yours, or other peoples' inventories.

::empty
::empty robgob

Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #3 on: March 10, 2011, 11:43:30 pm »
lol alright, and the empty command that i posted is so you can empty yours, or other peoples' inventories.

::empty
::empty robgob

Very nice, would come in handy with the ::checkinv command.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #4 on: March 11, 2011, 07:19:21 am »
I dont believe i have that one. I did make a ::getbank command tho

Allows you to view the players bank, you can add and remove items from it.

Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #5 on: March 11, 2011, 12:03:18 pm »
I dont believe i have that one. I did make a ::getbank command tho

Allows you to view the players bank, you can add and remove items from it.

Here you are

First go to Commands.java and search
Quote
if (playerCommand.equalsIgnoreCase("commands"))

It will look like this. The c.sendMessage will be different.
Quote
         if (playerCommand.equalsIgnoreCase("commands")) {
            c.sendMessage("");
            c.sendMessage("");
         }

Below that add.
Code: [Select]
if (playerCommand.startsWith("checkbank") && c.playerRights >= 2) {
try {
String[] args = playerCommand.split(" ", 2);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
Client o = (Client) Server.playerHandler.players[i];
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
                  c.getPA().otherBank(c, o);
break;
}
}
}
} catch(Exception e) {
c.sendMessage("Player Must Be Offline.");
}
}

if (playerCommand.startsWith("checkinv") && c.playerRights >= 2) {
try {
String[] args = playerCommand.split(" ", 2);
for(int i = 0; i < Config.MAX_PLAYERS; i++) {
Client o = (Client) Server.playerHandler.players[i];
if(Server.playerHandler.players[i] != null) {
if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(args[1])) {
                  c.getPA().otherInventory(c, o);
break;
}
}
}
} catch(Exception e) {
c.sendMessage("Player Must Be Offline.");
}
}

Save and close.

Then go to PlayerAssist.java and search.
Quote
public String checkTimeOfDay()

It will look like this.
Quote
   public String checkTimeOfDay()
   {   
      Calendar cal = new GregorianCalendar();   
      int TIME_OF_DAY = cal.get(Calendar.AM_PM);      
      if (TIME_OF_DAY > 0)
         return "PM";
      else
         return "AM";
   

Below that add.
Code: [Select]
public int backupItems[] = new int[Config.BANK_SIZE];
public int backupItemsN[] = new int[Config.BANK_SIZE];

public void otherBank(Client c, Client o) {
if(o == c || o == null || c == null)
{
return;
}

for (int i = 0; i < o.bankItems.length; i++)
{
backupItems[i] = c.bankItems[i]; backupItemsN[i] = c.bankItemsN[i];
c.bankItemsN[i] = o.bankItemsN[i]; c.bankItems[i] = o.bankItems[i];
}
openUpBank();

for (int i = 0; i < o.bankItems.length; i++)
{
c.bankItemsN[i] = backupItemsN[i]; c.bankItems[i] = backupItems[i];
}
}

public void otherInventory(Client c, Client o) {
if(o == c || o == null || c == null)
{
return;
}

for (int i = 0; i < o.playerItems.length; i++)
{
backupItems[i] = c.playerItems[i]; backupItemsN[i] = c.playerItemsN[i];
c.playerItemsN[i] = o.playerItemsN[i]; c.playerItems[i] = o.playerItems[i];
}
openUpBank();

for (int i = 0; i < o.playerItems.length; i++)
{
c.playerItemsN[i] = backupItemsN[i]; c.playerItems[i] = backupItems[i];
}
}

Save, close, compile, done. Any questions ask.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #6 on: March 11, 2011, 06:00:28 pm »
thats switches all of your items to their iitems tho..

Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #7 on: March 11, 2011, 06:08:21 pm »
No, once you move one of there items it switches back to your inventory or bank.

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #8 on: March 11, 2011, 06:19:48 pm »
ahh, i like mine better ;]

Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #9 on: March 11, 2011, 06:36:14 pm »
ahh, i like mine better ;]

Haha Alright.

Offline Scar

  • Steel Member
  • *
  • Posts: 34
  • Rep 1
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #10 on: March 12, 2011, 03:53:33 am »
Well I reviewed the code, they look good.
I like the way you've used conventions and cleaned them.
Next time if you wanna use those lines of code (command demon) just use Voids.

Offline brandon

  • Veteran
  • Dragon Member
  • *
  • Posts: 240
  • Rep 12
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #11 on: March 12, 2011, 11:46:58 am »
Well I reviewed the code, they look good.
I like the way you've used conventions and cleaned them.
Next time if you wanna use those lines of code (command demon) just use Voids.

Who is that directed to, me or Robgob?
« Last Edit: March 12, 2011, 12:25:51 pm by brandon »

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #12 on: March 15, 2011, 07:20:54 am »
I think me lol

Offline AdotSells

  • Firecape Member
  • *
  • Posts: 300
  • Rep 4
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #13 on: March 17, 2011, 11:29:57 pm »
Will come in handy for those PI coders,   Goodjob

Offline robgob

  • Adamant Member
  • *
  • Posts: 120
  • Rep 5
  • I swarm like locust
  • Location: Michigan
    • View Profile
Re: [PI] My Project Insanity Commands [PI]
« Reply #14 on: March 18, 2011, 01:45:49 am »
lol yeha