Z508 | How To Code | For New Coders

Maxie

Onyx user!
Reputation
0
Code:
rights:0
Change the rights above, to:
Code:
rights:1
or:
Code:
rights:2
Rights 0 is for regular players.
Rights 1 is for moderators.
Rights 2 is for administrators.



How to add owner commands:

Open Commands.java and add this:
Code:
String hostpaul = Server.socketListener.getAddress(p.socket.socket);
Under the following:
Code:
Engine.fileManager.appendData("characters/logs/commands/"+p.username+".txt", playerCommand);

For an example, I will use the demote command.
Code:
if (cmd[0].equalsIgnoreCase("demote") && p.username.equalsIgnoreCase("YOUR NAME HERE"))) {
String person = playerCommand.substring((playerCommand.indexOf(" ") + 1));
Player p2 = Engine.players[Engine.getIdFromName(person)];
if (p2 != null) {
p2.disconnected[0] = false;
p2.rights = 0;
p2.hidden = 0; // Only if you got a hidden rank
p2.getActionSender().sendMessage(p2, "You have been demoted to a regular player! " +p.username+ " certainly didn't do it!");
You have demoted "+p2.username+" to a regular player!");
p2.updateReq = true;
p2.appearanceUpdateReq = true;
}
	}

If you want to use this command for ALL of your accounts, replace this:
Code:
p.username.equalsIgnoreCase("YOUR NAME HERE") {
With:
Code:
!hostpaul.equalsIgnoreCase("YOUR IP HERE")) {

Make sure to add this string at the top of Commands.java:
Code:
String hostpaul = Server.socketListener.getAddress(p.socket.socket);

How to make an object teleport you:

This can also work with npcs.
At ObjectOption1.java, add this:
Code:
case ####: // Case id here
teleportTo(3138, 3516, 4, 0, 0, 0, 0, 0, 0, 0, 0);


How to add the uses of item on item:

Open the ItemOnItem class, and then add:
Code:
PlayerItems pi = new PlayerItems();
Code:
if(itemUsed == ITEMID && usedWith == ITEMID) {

An example for simple fletching:
Code:
		if(itemUsed == 1747 && usedWith == 1747) {
		player.appendExperience(300 ,15);
	* * * * * * *pi.deleteItem(player, 1747, pi.getItemSlot(player, 1747), 1); 
 	* * * * * * *pi.deleteItem(player, 1747, pi.getItemSlot(player, 1747), 1); 
* * * * * * * * * * * * * pi.addItem(player, 5853, 1);
* * * * * * * * * * * * * player.getActionSender().sendMessage(player, "You have made a Dwarven stout(m2)."); 
* * * * * * * * * * * * * *}


A Z508 Source Link


Credits:
My friend - @"I barrage k0". 100 %
He made the tutorial, thought about posting it here to make the section more popular.
 
I'm Break on runelocus, I can send you a pm to confirm it if you want.
He gave me 100% credits and I told him he can post it.
 
wale said:
Oh shit. Both threads look very similar. If you did steal this guide then your low as hell... do you have anything to say in your defense?

Check post above yours.
 
Guys, regardless.
He have credits and he is helping you guys out. Stop being so damn' negative.
 
Guys, he has been given permission to post the guide. No need to continue this discussion. Back on topic. I've cleaned a few posts that aren't contributing, just accusing him of copying.
 
Thanks for the two posts above me.
I might make some guides by myself, or give Maxie the codes after I'm done coding.
 
Back
Top