Jump to content
Sign in to follow this  
MaxiPad

Adding extra rewards for Donators within your Vote4Rewards

Recommended Posts

Hello RuneLocus, I understand that many of you may have donators on your RSPS.
So this tutorial is mainly aimed at those who wish to give their donators extra rewards when voting.


Firstly you're going to search for your existing command, head over to Commands.java
Then search for your claim/check command using Cntrl/Control/Command + F.
My command for vote checking and giving rewards is ::claim so I'll search for " "claim" "
This pulls up:
[code]
if (playerCommand.equalsIgnoreCase("claim")) {
try {
VoteReward reward = Server.vote.hasVoted(c.playerName.replaceAll(" ", "_"));
if(reward != null){
switch(reward.getReward()){
case 0:
c.getItems().addItem(995, 1000000);
break;

default:
c.sendMessage("Reward not found.");
break;
}
c.sendMessage("Thank you for voting.");
} else {
c.sendMessage("You have no items waiting for you.");
}
} catch (Exception e){
c.sendMessage("[RuneProject] Error: #SQLvoting; contact @[email protected] Max with this error!.");
}
}[/code]
Now for creating a variable that will check for the players rank and give items accordingly.
If you look at the code you will notice the reward is working inside a case number, this specific case has the ID of 0.
[code] case 0: [/code]
Inside is the reward for all players, which will be the reward for regular players after we have finished.
I'm going to give my donators 2x the reward because I'm a nice guy.. So I'm going to create the following variable below the prementioned 'case 0'

[code] if (c.playerRights == 6) {

}[/code]
Inside of the variable is the execution if the above condition is true, as my donator rank is of the integer 6, the inside code will be executed, but there is nothing there, yet!

Inside I am going to add the double reward for donators:

[code] if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
}[/code]
Now if the client user has the player Rights/Rank of 6 which is the donator rank on my server(Yours may be different) it will get the item Item ID 995(Coins) and an amount of 2000000(2 Million) and add it to their inventory.

But wait, if we replace everything inside case 0: with what I have just written only donators will be rewarded? That's where we add the Else statement.
So we give everyone ELSE the usual reward.
[code]
if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
} else {
c.getItems().addItem(995, 1000000);
}
[/code]

To finish off, we will remove everything that was inside of Case 0, and add our new conditional code.
It should look like this.
[code]
if (playerCommand.equalsIgnoreCase("claim")) {
try {
VoteReward reward = Server.vote.hasVoted(c.playerName.replaceAll(" ", "_"));
if(reward != null){
switch(reward.getReward()){
case 0:
if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
} else {
c.getItems().addItem(995, 1000000);
}
break;

default:
c.sendMessage("Reward not found.");
break;
}
c.sendMessage("Thank you for voting.");
} else {
c.sendMessage("You have no items waiting for you.");
}
} catch (Exception e){
c.sendMessage("[RuneProject] Error: #SQLvoting; contact @[email protected] Max with this error!.");
}
}[/code]
You can also have it announced to the community by adding:
[code]
PlayerHandler.announce("[SERVER] "+c.playerName+" has voted");
[/code]
under every reward.

Thank you for reading this tutorial, if any problems occur please feel free to reply/ send me a PM for extra help or a more detailed explanation.

Share this post


Link to post
Share on other sites
Nice! Thanks for the contribution!

Share this post


Link to post
Share on other sites
Nice tutorial, we need more members like you.

Share this post


Link to post
Share on other sites
[quote name='Envo']Nice tutorial, we need more members like you.[/QUOTE]
Thank you, just happy to help.

Share this post


Link to post
Share on other sites
Nice, though I would of gone for threading stuff like this, saving having to type in the commands.

Share this post


Link to post
Share on other sites
[quote name='Daedalus']Nice, though I would of gone for threading stuff like this, saving having to type in the commands.[/QUOTE]

Why thread when the server already has a game interval loop.

Share this post


Link to post
Share on other sites
[quote name='Hope']Why thread when the server already has a game interval loop.[/QUOTE]

this ^

Share this post


Link to post
Share on other sites
[quote name='virt3x']Thanks man![/QUOTE]
You're very welcome. Expect more tutorials that will help you with the fundamentals.

[quote name='Daedalus']Nice, though I would of gone for threading stuff like this, saving having to type in the commands.[/QUOTE]
Little things help with stability. Edited by MaxiPad

Share this post


Link to post
Share on other sites
Sign in to follow this  

×