PDA

View Full Version : [C/P TuT]Command That Makes You Unattackable[C/P TuT]



gether
November 27th, 2010, 02:25
Difficulty:5/10(it took me about an hour creating this by myself. since this is mostly c&p should be easy.)
Purpose: This will be a command for mods+ so they can use this and be unattackable by players. They cant use it in wildy or if there under attack.
Base Tested On: Evolution pkz.
Tools/Knowledge Needed: Copy, Paste, Ctrl+f, patience, and a brain.
Files modified:Commands.java Filemanager.java Player.java Playercombat.java Playermagic.java(if you have it. i don't)

There is probably a much easier way to make this but oh well..


I Do Not Give ANYONE Permission To Post This Anywhere Else.



I Would Recommend Making Backups In case This Doesn't Work For You.



Commands.java


if(cmd[0].equals("watchwildy") && p.rights > 0) {
if (p.attackedBy != null) {
p.getActionSender().sendMessage(p, "You cannot use this command while in combat.");
p.requestGFX(1844, 0);
return;
}
if (p.wildernessZone(p.absX, p.absY)) {
p.getActionSender().sendMessage(p, "You cannot use this command in the wilderness.");
return;
}

p.uber = 1;
}
if(cmd[0].equals("watchwildyoff") && p.rights > 0) {
p.uber = 0;
}

Please note that if u save and compile u will get an error so you might want to do that last.
DO NOT HAVE TO DO THE FILEMANAGER.JAVA PARTS! I ONLY DID THEM SO IT OUTWRITTED IN THE PLAYERS FILE SO IF THEY LOGOUT THEY KEEP IT ON/OFF!
Filemanager.java
Go into your char files and find the last line and copy that name. Then go into your FileManager.java and search it..for me it was "null"(idk why but it just was..)
WHAT YOU ARE LOOKING FOR SHOULD BE LOOKING LIKE THIS:


stream.writeString("(the name of it):" + p.

you should see something like this:


stream.writeString("mute:"+p.muteType);
stream.writeString("specAmount:" + p.specAmount);
stream.writeString("spellbook:" + p.spellbook);
stream.writeString("Xlog:" + p.combatType);
stream.writeString("quests:" + p.questStage);
stream.writeString("null");
FileOutputStream out = new FileOutputStream("./data/characters/mainsave/" + p.username + ".dat");
out.write(stream.outBuffer, 0, stream.outOffset);
out.flush();
out.close();
out = null;
}

Now underneath null(or whatever ur last one was. add this:


stream.writeString("Uber:" + p.uber);

should look like this:


stream.writeString("mute:"+p.muteType);
stream.writeString("specAmount:" + p.specAmount);
stream.writeString("spellbook:" + p.spellbook);
stream.writeString("Xlog:" + p.combatType);
stream.writeString("quests:" + p.questStage);
stream.writeString("null");
stream.writeString("Uber:" + p.uber);
FileOutputStream out = new FileOutputStream("./data/characters/mainsave/" + p.username + ".dat");
out.write(stream.outBuffer, 0, stream.outOffset);
out.flush();
out.close();
out = null;
}

Now do that as many times as the that comes up


Now in the same file look for this


else if(line.startsWith("(what your last one was)")

you should see something like this:


else if (line.startsWith("tabs"))
p.tabStartSlot[Integer.parseInt(line.substring(3, line.indexOf(":")))] = Integer.parseInt(line.substring(line.indexOf(":") + 1));
else if(line.startsWith("quests:"))
p.questStage = Integer.parseInt(line.substring(7));

It should have something like "} else if" instead of just "else if" if its the last one..mine does atleast..remove the } then add this underneath the last one:


} else if (line.startsWith("Uber:")) {
p.uber = Integer.parseInt(line.substring(5));

It should look like this:



else if (line.startsWith("tab"))
p.tabStartSlot[Integer.parseInt(line.substring(3, line.indexOf(":")))] = Integer.parseInt(line.substring(line.indexOf(":") + 1));
else if(line.startsWith("quests:"))
p.questStage = Integer.parseInt(line.substring(7));;
} else if (line.startsWith("Uber:")) {
p.uber = Integer.parseInt(line.substring(5));
}


After that save your filemanager.java

Player.java
Go into your player.java and add this under any other int...


public int uber = 0;


Playercombat.java
Now in playercombat.java search for this:


public void attackPlayer() {

Now somewhere in there add this


if (p.uber == 1) {
p.getActionSender().sendMessage(p, "You cant attack while you moderate.");
p.resetAttack();
return;
}
if (opp.uber == 1) {
p.getActionSender().sendMessage(p, "You cant attack staff while they moderate.");
p.resetAttack();
return;
}

Now save+compile and it should work.



If you have a Playermagic.java just add the above step in there but make it fit..if i had one id show u how :)

100% Credits to Me

No Mercy
November 27th, 2010, 10:12
There is a easier way but never the less Good Job :).

gether
November 27th, 2010, 10:30
There is a easier way but never the less Good Job :).

yea i know..i did this when i was just learning 508s so i think i did okay :)

EDIT: lol me and you have the same amount of posts :)(random i know..lol)

No Mercy
November 27th, 2010, 10:45
yea i know..i did this when i was just learning 508s so i think i did okay :)

EDIT: lol me and you have the same amount of posts :)(random i know..lol)

Wow thats weird lmao (randomnesssss) :D.

Kurdz
November 27th, 2010, 12:09
the most obv way, admins dont loose... (which is easy to code), plus all those things just gonna take up more space = lagg... just make it so admins dont loose or something (or mods if u want, dont really care)

gether
November 27th, 2010, 23:28
the most obv way, admins dont loose... (which is easy to code), plus all those things just gonna take up more space = lagg... just make it so admins dont loose or something (or mods if u want, dont really care)

i made this so mods have the option 2 sit in wildy and not be able 2 attack or be attacked to moderate for rule breakers..but if they want they can pk and lose items..admins cant pk on there admin accounts on my server..lol

and making admins not loose items isnt really smart if they can still attack...they'll just abuse it at points..

jente400
December 11th, 2010, 14:25
Whats the easier whay to do this?

Unholypk
December 25th, 2010, 19:32
thanks gonna add this for my admins so my economy isn't ruined :p