Tricky
April 17th, 2011, 08:35
Hello Guys. This is My 4th Tutorial I Think (Not Much) , And Today Im Going To Show You How To Add A Random loot!. :p
This Is Not Difficult In Eny Way, The Hardest Part Is Probally Finding The Files Thats About It So Lets Get Started.
This Random loot Can Be Used In All Sort Of Ways Im Not Going To Show You Wich Ones You Can Figure Out Yourself.
Base Tested - Bulby - Palidino76 (Could Use On Other Source But Will Need Converting)
Step 1: - Go To Your Player.java And Serch For
public class Player {
It Should Be Nere The Top. Right Under The Code Above Add In This.
public static int NAMEHERE[] = {3101,4151,11694,11696,11698,11700}; //Declared which job to do - 1 through 5
public static int NAMEHERE() //Generates a random number from the choices above
{
return NAMEHERE[(int)(Math.random()*NAMEHERE.length)]; //Returns that number
}
Where I Have Said NAMEHERE In Red Is The Name You Want It To Be Called Like For Example "voteprize".
Ok Now Let Me Explain Wat Is Going On.
public static int voteprize[] = {3101,4151,11694,11696,11698,11700};
Here You See All The Numbers. These Are Numbers Of Items So - D Claws - Aby Whip And So On.
public static int voteprize()
This Part Of the Code Grabs A Random Number From The Code Above So It Could Pick Dragon Claws Out Random!.
return voteprize[(int)(Math.random()*voteprize.length)];
This Code Returns The Number From The Above!.
Step 2: - Now This Bit Varies So Ill Show You In NpcOption1. This Step Can Go Eny Where Like. Commands.java Objectoption1.Java Objectoption2.java And So on!.
So Go To Npcoption1.java And Search For -
public Player p;
or
public Player player;
And Right Under That Add In This
public static int NAMEHERE[] = {3101,4151,11694,11696,11698,11700}; //Declared which job to do - 1 through 5
public static int NAMEHERE() //Generates a random number from the choices above
{
return NAMEHERE[(int)(Math.random()*NAMEHERE.length)]; //Returns that number
}
You Should Copy This Code From Player.java It Needs To Be The Same In Order To Work. After You pasted That In Add In This Dialouge!.
if(pnp.npcType == 220)
{
if (Engine.playerItems.HasItemAmount(p, 4278, 5) == false) {
p.frames.showChatboxInterface(p, 242);
p.frames.animateInterfaceId(p, 9840, 242, 2);
p.frames.setNPCId(p, 220, 242, 2);
p.frames.setString(p, "Voteing Clerk", 242, 3);
p.frames.setString(p, "Sorry "+Misc.optimizeText(p.username) + " You need 5 Tickets", 242, 4);
p.frames.setString(p, "To get a prize. You should start voteing!.", 242, 5);
} else {
Engine.playerItems.deleteItem(p, 4278, 5);
p.frames.showChatboxInterface(p, 242);
p.frames.animateInterfaceId(p, 9840, 242, 2);
p.frames.setNPCId(p, 220, 242, 2);
p.frames.setString(p, "Voteing Clerk", 242, 3);
p.frames.setString(p, "Here you go "+Misc.optimizeText(p.username) + " ", 242, 4);
p.frames.setString(p, "Hope you enjoy your prize!.", 242, 5);
p.frames.sendMessage(p, "You can go and see him again once you have 5 vote tickets again!.");
Engine.playerItems.addItem(p, NAMEHERE(), 1);
}
}
Again Where It Sais NAMEHERE In Red It Needs To Be The Same In Npcoption1.java And Player.java.
Basically This Dialouge Accepts 5 Vote Tickets You get From Voteing. If You Have 5 Vote Tickets It Will Give You A Random loot Wich You Can See Here.
Engine.playerItems.addItem(p, NAMEHERE(), 1);
If You have Less Than 5 Vote Tickets It Will Not Give You The loot And Will Ask You To vote Again. Here Is Some Pictures To Show Wat You Have Just Added!.
Only the registered members can see the link.
Only the registered members can see the link.
And Thats It. To Work For Objects You Do The Same Thing But You Move The Stuff From NpcOption1 To ObjectOption1 Or 2!.
If This Helped Please Comment And Comment For Eny Improvememnts I Can Make!
~Tricky~
This Is Not Difficult In Eny Way, The Hardest Part Is Probally Finding The Files Thats About It So Lets Get Started.
This Random loot Can Be Used In All Sort Of Ways Im Not Going To Show You Wich Ones You Can Figure Out Yourself.
Base Tested - Bulby - Palidino76 (Could Use On Other Source But Will Need Converting)
Step 1: - Go To Your Player.java And Serch For
public class Player {
It Should Be Nere The Top. Right Under The Code Above Add In This.
public static int NAMEHERE[] = {3101,4151,11694,11696,11698,11700}; //Declared which job to do - 1 through 5
public static int NAMEHERE() //Generates a random number from the choices above
{
return NAMEHERE[(int)(Math.random()*NAMEHERE.length)]; //Returns that number
}
Where I Have Said NAMEHERE In Red Is The Name You Want It To Be Called Like For Example "voteprize".
Ok Now Let Me Explain Wat Is Going On.
public static int voteprize[] = {3101,4151,11694,11696,11698,11700};
Here You See All The Numbers. These Are Numbers Of Items So - D Claws - Aby Whip And So On.
public static int voteprize()
This Part Of the Code Grabs A Random Number From The Code Above So It Could Pick Dragon Claws Out Random!.
return voteprize[(int)(Math.random()*voteprize.length)];
This Code Returns The Number From The Above!.
Step 2: - Now This Bit Varies So Ill Show You In NpcOption1. This Step Can Go Eny Where Like. Commands.java Objectoption1.Java Objectoption2.java And So on!.
So Go To Npcoption1.java And Search For -
public Player p;
or
public Player player;
And Right Under That Add In This
public static int NAMEHERE[] = {3101,4151,11694,11696,11698,11700}; //Declared which job to do - 1 through 5
public static int NAMEHERE() //Generates a random number from the choices above
{
return NAMEHERE[(int)(Math.random()*NAMEHERE.length)]; //Returns that number
}
You Should Copy This Code From Player.java It Needs To Be The Same In Order To Work. After You pasted That In Add In This Dialouge!.
if(pnp.npcType == 220)
{
if (Engine.playerItems.HasItemAmount(p, 4278, 5) == false) {
p.frames.showChatboxInterface(p, 242);
p.frames.animateInterfaceId(p, 9840, 242, 2);
p.frames.setNPCId(p, 220, 242, 2);
p.frames.setString(p, "Voteing Clerk", 242, 3);
p.frames.setString(p, "Sorry "+Misc.optimizeText(p.username) + " You need 5 Tickets", 242, 4);
p.frames.setString(p, "To get a prize. You should start voteing!.", 242, 5);
} else {
Engine.playerItems.deleteItem(p, 4278, 5);
p.frames.showChatboxInterface(p, 242);
p.frames.animateInterfaceId(p, 9840, 242, 2);
p.frames.setNPCId(p, 220, 242, 2);
p.frames.setString(p, "Voteing Clerk", 242, 3);
p.frames.setString(p, "Here you go "+Misc.optimizeText(p.username) + " ", 242, 4);
p.frames.setString(p, "Hope you enjoy your prize!.", 242, 5);
p.frames.sendMessage(p, "You can go and see him again once you have 5 vote tickets again!.");
Engine.playerItems.addItem(p, NAMEHERE(), 1);
}
}
Again Where It Sais NAMEHERE In Red It Needs To Be The Same In Npcoption1.java And Player.java.
Basically This Dialouge Accepts 5 Vote Tickets You get From Voteing. If You Have 5 Vote Tickets It Will Give You A Random loot Wich You Can See Here.
Engine.playerItems.addItem(p, NAMEHERE(), 1);
If You have Less Than 5 Vote Tickets It Will Not Give You The loot And Will Ask You To vote Again. Here Is Some Pictures To Show Wat You Have Just Added!.
Only the registered members can see the link.
Only the registered members can see the link.
And Thats It. To Work For Objects You Do The Same Thing But You Move The Stuff From NpcOption1 To ObjectOption1 Or 2!.
If This Helped Please Comment And Comment For Eny Improvememnts I Can Make!
~Tricky~