2kbarrows
October 9th, 2010, 00:21
Ok, well on this tutorial i'm going to show you guys how to get a few objects working, OK?
Ok so why don't you go ahead and open Object1PacketHandler.java, AKA Source>SRC>RS2HD(Emily if your using emilys source)>Packethandler...
Table of Contents
1.The Basics
2.Getting Advanced
3.Walktos
4.Double sided doors
5.Items
6.Animations and AddXP
1-Basic
case 5264:
player.tele(3654, 3519, 0);
break;
Thats a basic code, now to explain..
case 5264:
The bold code is the object that you are coding, in this case i coded a ladder...
player.tele(3654, 3519, 0);
Thats the ladder effect, which is a teleport..
break;
Which obviously ends the case, remember that you NEED a break to finish the case...
2-Starting to get advanced
Now for som more advanced stuff:
if(player.getSkills().getLevel(16) < 70) {
player.sm("You need at least level 70 of Agility to jump down.");
return;
}
That makes it so that people with agility under 70 they can't tele..
if(player.getSkills().getLevel(16) < 70) {
16 is the skill, Agility, and 70 is the level now the < is less than, so lets read the whole code...
If player has agility less than 70...Get it?
player.sm("You need at least level 70 of Agility to jump down.");
return;
}
Ok so the first line is player.send message(blah blah blah) AKA it sends that player the message...
Return is the code in which if the player has 70 agility or more its returns to origrinal code...
3-Walko
What is a walkto?
It is a code in which a player walks through a door/object...
player.WalkTo().GoTo(player, 2657, 3525);
Now here is how it works player walks to coord 2657, 3525.
Thats basicly it!
4.Double Sided Doors
if(player.getLocation().getX() == COORD HERE && player.getLocation().getY() == COORD Y HERE && player.getLocation().getZ() == HIGHT HERE) {
player.tele(3675, 9887, 1);
} else if(player.getLocation().getX() == COORD HERE && player.getLocation().getY() == COORD HERE && player.getLocation().getZ() == HIGHT HERE) {
player.tele(3683, 9888, 0);
Ok so this teleports you from both sides(not exactly because this isn't a door but you can understand)
So first
if(player.getLocation().getX() == COORD HERE
if player is it coord *add coord here*...Thats it cause it ain't the whole thing...That is for COORD X
&& player.getLocation().getY() == COORD Y HERE
And if player is at *coord here*...Thats for COORD Y
&& player.getLocation().getZ() == HIGHT HERE) {
And player is at hight *hight here*...So thats it...
NOW:
player.tele(3675, 9887, 1);
Thats the teleport..
Now at the rest of the code its like "else if player gets coord *blah blah blah*"
I think you can figure it out...
5.Items
player.getInventory().addItem(3214, 1);
player.getInventory().deleteItem(7936, 28);
Now those are item add and item delete but do i really need to read it to you?
The numbers i highlighted is the item code and the number next to it is the quantity...
if (!player.getInventory().contains(7936, 1)) {
player.sm("<col=000000>You need a pure essence to start runecrafting!.<col=000000>");
That's a start on runecrafting basicly what it says is, if players inventory doesent have *item here* at *this quantity* cancel action....
6.Animations and AddXP
player.animate(791);
player.getSkills().addXp(20, 3000);
Ok so the first one i feel that i don't need to explain...
The second one is like this, Player add xp to Skill number 20 and add 3000 xp...
So the first number is the number code and the second is XP...
Thats basicly it guys!
Also:
Tips
Never forget to add the ; at the end of each statement
Never forget breaks at the end of each case
Cases ALWAYS have the same number as the object you are coding
Always remember to add comments to mark what you are coding such as Runecrafting
/*
* Runecrafting
*/
If you are going to use signposts use this:
player.getActionSender().sendInterface(174);
player.getActionSender().sendString("wada", 174, 1);
Just change the wada to what you are doing....
Ok so why don't you go ahead and open Object1PacketHandler.java, AKA Source>SRC>RS2HD(Emily if your using emilys source)>Packethandler...
Table of Contents
1.The Basics
2.Getting Advanced
3.Walktos
4.Double sided doors
5.Items
6.Animations and AddXP
1-Basic
case 5264:
player.tele(3654, 3519, 0);
break;
Thats a basic code, now to explain..
case 5264:
The bold code is the object that you are coding, in this case i coded a ladder...
player.tele(3654, 3519, 0);
Thats the ladder effect, which is a teleport..
break;
Which obviously ends the case, remember that you NEED a break to finish the case...
2-Starting to get advanced
Now for som more advanced stuff:
if(player.getSkills().getLevel(16) < 70) {
player.sm("You need at least level 70 of Agility to jump down.");
return;
}
That makes it so that people with agility under 70 they can't tele..
if(player.getSkills().getLevel(16) < 70) {
16 is the skill, Agility, and 70 is the level now the < is less than, so lets read the whole code...
If player has agility less than 70...Get it?
player.sm("You need at least level 70 of Agility to jump down.");
return;
}
Ok so the first line is player.send message(blah blah blah) AKA it sends that player the message...
Return is the code in which if the player has 70 agility or more its returns to origrinal code...
3-Walko
What is a walkto?
It is a code in which a player walks through a door/object...
player.WalkTo().GoTo(player, 2657, 3525);
Now here is how it works player walks to coord 2657, 3525.
Thats basicly it!
4.Double Sided Doors
if(player.getLocation().getX() == COORD HERE && player.getLocation().getY() == COORD Y HERE && player.getLocation().getZ() == HIGHT HERE) {
player.tele(3675, 9887, 1);
} else if(player.getLocation().getX() == COORD HERE && player.getLocation().getY() == COORD HERE && player.getLocation().getZ() == HIGHT HERE) {
player.tele(3683, 9888, 0);
Ok so this teleports you from both sides(not exactly because this isn't a door but you can understand)
So first
if(player.getLocation().getX() == COORD HERE
if player is it coord *add coord here*...Thats it cause it ain't the whole thing...That is for COORD X
&& player.getLocation().getY() == COORD Y HERE
And if player is at *coord here*...Thats for COORD Y
&& player.getLocation().getZ() == HIGHT HERE) {
And player is at hight *hight here*...So thats it...
NOW:
player.tele(3675, 9887, 1);
Thats the teleport..
Now at the rest of the code its like "else if player gets coord *blah blah blah*"
I think you can figure it out...
5.Items
player.getInventory().addItem(3214, 1);
player.getInventory().deleteItem(7936, 28);
Now those are item add and item delete but do i really need to read it to you?
The numbers i highlighted is the item code and the number next to it is the quantity...
if (!player.getInventory().contains(7936, 1)) {
player.sm("<col=000000>You need a pure essence to start runecrafting!.<col=000000>");
That's a start on runecrafting basicly what it says is, if players inventory doesent have *item here* at *this quantity* cancel action....
6.Animations and AddXP
player.animate(791);
player.getSkills().addXp(20, 3000);
Ok so the first one i feel that i don't need to explain...
The second one is like this, Player add xp to Skill number 20 and add 3000 xp...
So the first number is the number code and the second is XP...
Thats basicly it guys!
Also:
Tips
Never forget to add the ; at the end of each statement
Never forget breaks at the end of each case
Cases ALWAYS have the same number as the object you are coding
Always remember to add comments to mark what you are coding such as Runecrafting
/*
* Runecrafting
*/
If you are going to use signposts use this:
player.getActionSender().sendInterface(174);
player.getActionSender().sendString("wada", 174, 1);
Just change the wada to what you are doing....