TELEPORTING Object Cases
Here is a basic object case.
Code:
case ####:
teleportToX = XXXX;
teleportToY = YYYY;
heightLevel = #;
updateRequired = true;
appearanceUpdateRequired = true;
break;
Ok first thing to do is change the case ####:
Just change the #### to the object ID you want to teleport you somewhere.
Now change the XXXX and YYYY to the teleport coords that you want the object to teleport you to.
Now change the "#" next to heightLevel = to which height you want to be teleported to.
Example "0" is main floor.
-1 is underground so like falador mine caves.
1 is above ground so like upstairs in varrock bank.
Code:
updateRequired = true;
appearanceUpdateRequired = true;
Just put this at the end of a case like this please it might mess up your character like walking running eating or something like that won't work.
At the end of a case like a } ends the code.
There is different ways to do this like you can make it so only a admin or mod can use the object.
Or if you teleblocked you can't use the object or you have to have a certain skill lvl to use the object.
I'll be showing you some examples.
Code:
case #### Cant tel3
if(teleblock)
{
sendMessage("You are currently teleblocked!");
}
else if (!teleblock)
{
sendMessage("ENTER A MESSAGE TO THE USER HERE!");
teleportToX = XXXX
teleportToY = YYYY
heightLevel = #
updateRequired = true;
appearanceUpdateRequired = true;
}
break;
And here is for admin or mod only.
Code:
case ####
if(playerRights >= 2 {
sendMessage("You use the admin only object.");
teleportToX = XXXX
teleportToY = YYYY
heightLevel = #
updateRequired = true;
appearanceUpdateRequired = true;
break;
And here is for having a certain skill lvl to use the object.
Code:
case 0000:
if(playerLevel[1] >= 20) {
sendMessage("You use the object.");
teleportToX = 0000;
teleportToY = 0000;
heightLevel = #
updateRequired = true;
appearanceUpdateRequired = true;
break;
[TRAINING Object Cases
*NOTE* - This part assumes that you have already got the new objects that you want players to train on
I will post an easy example and break it down just like I did with the teleporting objects.
Code:
case XXXXX:
sendMessage("ENTER A MESSAGE TO THE USER HERE!");
addSkillXP((XP*playerLevel[S]), S);
updateRequired = true;
appearanceUpdateRequired = true;
break;
Ok this is just a very simple object case that would give you experience when you click on the object. Again, replace the XXXX with the object Id # that will be giving the Xp.
You already know what
does, so we'll skip over that.
So you want to adjust the Xp rate you say? Well pay attention to this part then, there are a couple of ways you can do it so if you dont feel comfortable with one way, try this way.
Code:
addSkillXP((XP*playerLevel[S], S);
Now this doesn't look like it yet, but after we explain it, i'll give you a finished example.
First off,
tells the server to give the person clicking the object Xp in a certain spot.
Here are two different examples with addSkillXP:
Code:
addSkillXP(500, 5);
This one will always add 500 Xp to Skill #5. I don't use this one much.
This next example I basically use all the time, because depending on the players level, it gives more Xp to higher levels. So therefore, once a high level, it wont be the same old slow training as when you were a lower level.
Code:
addSkillXP((XP*playerLevel[S], S);
Inside the parenthesis where it says "XP" change that to a number that you will want multiplied by the players current level.
Inside the parenthesis where is says
change the S to the skill # of the skill that will be trained. Also, change that last "S" to the same number.
We don't need to explain any of the last part, because if you read, it was explained in the Teleporting case/object.
Now for a more complex design of the Training Object:
Code:
case XXXXX:
if(actionTimer == 0) {
setAnimation(AAA);
sendMessage("ENTER A MESSAGE TO THE USER HERE!");
actionTimer = 80;
addSkillXP((XP*playerLevel[S]), S);
updateRequired = true;
appearanceUpdateRequired = true;
}
break;
This looks a little different than the other one doesn't it? Well, it's actually not too much more complex. Here is how it works:
Code:
if(actionTimer == 0) {
This means that if the players Timer has reached 0, then they will be able to click the object again.
You can choose how long the timer will be by placing
anywhere in the case AFTER
Code:
if(actionTimer == 0) {
Just change the XX's to how long you want the timer to be. 80 seems to be a good amount of time. It stops massing for the most part.
Now for the last thing that was left unexplained:
All this does is, when you click on the object, it will do a certain emote. Replace the AAA's with random numbers until you find an animation that you want. Or you could ask someone for a pre-made emote list.
Now to make it so it add items to your inventory.
Code:
case XXXX:
setAnimation(AAA);
addItem(IIII, 1);
break;
This is just another simple case, but you can work out many other things with it from what you have learned above.
This new part:
is how you add items to someones inventory. Change the IIII's to the Item Id # that would go into the persons inventory. If you want to add more than one item you would make it look like this:
Code:
case XXXX:
setAnimation(AAA);
addItem(IIII, 1);
addItem(IIII, 1);
addItem(IIII, 1);
addItem(IIII, 1);
break;
You can also add random items from your Item.java, Item2.java, or Item3.java. You would do this by replacing
with
or
Then you would go into either your Item.java or Item2.java and add:
Code:
public static int items[] = {XXXX,XXXX,XXXX};
public static int randomitem()
{
return item[(int)(Math.random()*items.length)];
}
Replace the XXXX's with the items that it will randomly give. You can add more by putting in a comma, then adding more item id #'s.
If you would like to set a certain level that the person will need, you can make the case look like this:
Code:
case XXXX:
if(playerLevel[S] >= L) {
sendMessage("You teled to.....");
teleportToX = xxxx;
teleportToY = yyyy;
heightLevel = 0;
updateRequired = true;
appearanceUpdateRequired = true;
} else {
sendMessage("You need x skill to do this.");
}
break;
What you need to do is change this:
Code:
if(playerLevel[S] >= L)
Change the "S" to the skill that will be needed, and change the "L" to the Level thats needed
This concludes your learning of Object Cases. If I should add anything else feel free to tell me, and I will update this thread. I hope you learned!