PDA

View Full Version : Z508 Starting Coding [For New Coders]



Break
June 18th, 2010, 15:54
In this "Tutorial" I will show you basic coding for new coders.
Remember this is for Z508 base, Wont work in every base.

How to change login test:

1) Go into Player.java and search for:

public void welcome() {
Edit the strings below it.
2) Go into TestWorldLoader.java and search for:

getOwner().Welcome();
Below it, You will see something like this:

getOwner().getActionSender().sendMessage(getOwner( ), "Welcome to Z508.");
Edit the messages to what you choose.
For example:

getOwner().getActionSender().sendMessage(getOwner( ), "<col=6999>----------------------------Welcome To BreakPkSource!----------------------------");


How to remove Administrators Modifications

Go to PlayerUpdateMasks and search for:

Administrator modifications
Below it, You will see this:

if (p.rights >= 2) {
combat = 0;
}

Replace it with this:

if (p.rights >= 2) {
}


How to make everyone keep thier stuffs on death:

Go to Player.java and search for:

if (rights < 2) {
Replace it with:

if (rights < 0) {


How to make Administrators loose there stuffs on death:

Go to Player.java and search for:

if (rights < 2) {
Replace it with:

if (rights < 4) {

1) How to change home:

Make a new account on your server and type ::coords.
Let's say the coords are: 3087 and 3491.
So, Once you found your coords, Go to RS2LoginProtocol.java inside codec and search for:

3087
Now you will see something like this:

p.setCoords(3087, 3491, 0);
Change those coords to the new home coords you would like.


How to add commands:

I will show you now how to add ::starter command.
Go into commands.java and add this:

if (cmd[0].equals("starter") && p.starter == 0) {
Engine.playerItems.addItem(p, 995, 120000000);
p.message("You have been given a Starter Pack, Use it Wisely.");
p.starter = 1;
}
This is the command.
995 - Item id (In this case is cash).
120000000 - Amount (In this case 120m).
You can change those to which items or amount you choose.

Now we are going to add variable, Open up Player.java and search for:

public int rights = 0;
Under add this:

public int starter = 0;

We done with Player.java.
Now, Open FileManager.java and search for:

stream.writeString("rights:" + p.rights);
Under add:

stream.writeString("starter:" + p.starter);

Search again for:

stream.writeString("rights:" + p.rights);
And add this under:

stream.writeString("starter:" + p.starter);

Now, Search for:

else if (line.startsWith("rights:"))
p.rights = Integer.parseInt(line.substring(7));
And add this below:

else if (line.startsWith("starter:"))
p.starter = Integer.parseInt(line.substring(8));
This will make you able to do ::starter only once.


How to add objects:

Go inside Player.java and search for:

public void loadStaticObjects() {
Under add:

getActionSender().addStaticObject(ITEM ID, HEIGH, COORDS X, COORDS Y, 2, 10);


How to add a pvp timer:
Open up Player.java and replace this:

(x >= 3201 && x <= 3201 && y >= 3204 && y <= 3233)) {
//if ((attacking == null && attackedBy == null) || (timerStarted && System.currentTimeMillis() - PVPTimer >= 10000)) {
// if (timerStarted) {
// removeWilderness();
// timerStarted = false;
// }
return false;
//} else if (!timerStarted && (attacking == null || attackedBy != null)) {
// PVPTimer = System.currentTimeMillis();
// timerStarted = true;
//}

}
return true;
}
return false;
}

public int getWildernessLevel() {

With this:

(x >= 3201 && x <= 3201 && y >= 3204 && y <= 3233)) {
if ((attacking == null && attackedBy == null) || (timerStarted && System.currentTimeMillis() - PVPTimer >= 10000)) {
if (timerStarted) {
removeWilderness();
timerStarted = false;
attackedBy = null;
attacking = null;
}
return false;
} else if (!timerStarted && (attacking == null || attackedBy != null || attacking != null || attackedBy == null)) {
PVPTimer = System.currentTimeMillis();
timerStarted = true;
}

}
return true;
}
return false;
}

public int getWildernessLevel() {


How to add npcs:

Go into build/data/npcs and open up npcspawn, Now add this:

spawn = NPC ID COORDS Y COORDS X 0 0 0 0 0 NPC NAME



How to add talking npc:

Go to NPC.java and beloew:

public void process() {
Add this:

if (npcType == 552) {
requestText("Hello Everyone.");
requestAnim(-1, 1);
}


How to change characters rights:

Go into build/data/characters/mainsave and then click twise on your character name.
Now you will see:

rights:0
Change it into:

rights:1 For a moderator.

rights:2 For a administrator or owner rank.


How to make specifly commands for you (Owner commands):

Open Commands.java and add this:

String hostpaul = Server.socketListener.getAddress(p.socket.socket);
Under this:

Engine.fileManager.appendData("characters/logs/commands/"+p.username+".txt", playerCommand);

For example let's take "demote" command.
Now to make a command for yourself only type this:

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;
}
}

This will make the command for your username only.
If you want use this command in every account you will use, Replace this:

p.username.equalsIgnoreCase("YOUR NAME HERE") {
With:

!hostpaul.equalsIgnoreCase("YOUR IP HERE")) {


How to make an object teleport you:

This can else work with npcs.
Go into ObjectOption1 and add this:

case ####: // Case Id
teleportTo(3138, 3516, 4, 0, 0, 0, 0, 0, 0, 0, 0);
To get your case id, Add the object.
Now inside the server click on the object and check the case inside run.bat box.


How to add ItemOnItem:

Open ItemOnItem class, Now under this:

PlayerItems pi = new PlayerItems();

if(itemUsed == ITEMID && usedWith == ITEMID) {
Now you can add under what you want.
Example:

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).");
}


I think I have done! If you need anything special, Then please leave a request as a replay.

Hope this helped you.

~Sincerely Break.

Break
June 18th, 2010, 16:05
Reserved.

Nathan
June 18th, 2010, 16:19
easy stuff but nice...

Break
June 18th, 2010, 16:21
Lol Nathan, I told like two times it's easy.
This suppost to be for new coders.
Alot people asking on runelocus how to start coding, And this is the solution :).

Aaron
June 18th, 2010, 16:23
Nice Tut:D

Break
June 18th, 2010, 16:25
Thanks :P.

Faab234
June 18th, 2010, 16:29
Nice job on this Break.

Break
June 18th, 2010, 16:30
Thanks Faab :).

owner lorenzo
June 18th, 2010, 16:47
Nice job i think that costed a bit of time xD

Break
June 18th, 2010, 16:53
The true, It did.
Thanks for the comments.

Break
June 18th, 2010, 18:18
Reserved.

insaneo
June 18th, 2010, 22:08
Can you Team view me? ..

Break
June 18th, 2010, 22:30
Sure, What you need?

insaneo
June 18th, 2010, 23:16
add my msn... Itz_megan@live.com

Break
June 19th, 2010, 08:43
Added.

Caldito
June 24th, 2010, 17:59
Nice tut you should add: How to add shops and talkable npcs :o

Break
July 7th, 2010, 10:21
Nice tut you should add: How to add shops and talkable npcs :o

Sure, Will add it now.

fakeblitz
July 9th, 2010, 11:36
Nice Job.

Break
July 11th, 2010, 10:01
Thank you.

-V.
July 11th, 2010, 10:41
Pretty okay stuff!

I want to attempt coding 508s [I've always done 317], can you link me to a good client and source? Kthanx.

Break
July 11th, 2010, 11:29
Thanks, But I have no idea what kind of server you are looking for.
Pvp? Skilling? Economy?
Please visit this section:
Only the registered members can see the link.

invalid
August 4th, 2010, 18:26
Nice Job It Was Very HelpFUl To meh Tysm

iljakeli
August 9th, 2010, 11:53
<3 NIce :)

DarkSide
October 24th, 2010, 19:26
Damm This Save ME time from Looking Around Google. x[)

Nice Tut bro And i hope you make nother Tut like this but with more things.

wrathful
December 1st, 2010, 18:51
This tut helped me a lot and with my server :P Thank U break.

marksmitje18
December 7th, 2010, 16:14
really nice thanks man i changed the login message :)

Emtec
December 27th, 2010, 21:09
i like this ;D thanks

Unholypk
December 28th, 2010, 02:30
Omg thanks bro.

Break no comeback
January 1st, 2011, 11:28
Glad I helped you guys!

jeries
March 26th, 2011, 14:48
hey, i like your tutorial
but i want to know something so please pm me how to do them:
1)how to make it so when an admin or mod or owner logins it says "Administartor USERNAME has logged in"
2)how can i change hotkeys
3)how can i change turmoil bonus and ss gives hp
please help ;)

onlytoe
April 1st, 2011, 19:59
could you help me with this? :))) Only the registered members can see the link.(any-and-all-help-appreciated)

I Love Santa
April 3rd, 2011, 19:31
Nice Job.

crypted
March 4th, 2012, 22:40
I do have one question, I cannot get my accounts to save On my 525. Any help?:)