Jump to content
Supah Fly

Autovote - Motivote - Server and Web tutorial

Recommended Posts

[IMG]http://rspserver.com/images/motivote.png[/IMG]
Download at [URL="http://www.runelocus.com/forums/showthread.php?102928-Ultimate-Vote-Script-Motivote-(SERVER-amp-WEBSITE)"]http://www.runelocus.com/forums/showthread.php?102928-Ultimate-Vote-Script-Motivote-(SERVER-amp-WEBSITE)[/URL]

[SIZE=1]Note: This can be applied to any server, RL just forced me to use a thread prefix.[/SIZE]

So I made [URL="http://www.runelocus.com/forums/showthread.php?102928-Ultimate-Vote-Script-Motivote-(SERVER-amp-WEBSITE)"]Motivote[/URL] pretty easy to install, right off the bat. The only real tricky part is going to be writing the code that gives the user the reward, but I've made that as simple as I can make it.

[url]https://www.youtube.com/watch?v=GhOyPmwqw1s[/url]

[LIST=1]
[*]Create a MySQL database, user, and give the user as many privileges as you can.
[*]Extract Motivote-(WHATEVER CURRENT VERSION IS)-web.rar and upload the contents into a directory on your website. I'd use /vote/.
[*]Set permissions on config.php to 0777. If you don't, the script will tell you what to put in config.php by yourself.
[*]Visit [url]http://yoursite.com/vote/[/url] and enter the installation information and just follow the steps.
[*]MAKE SURE YOU SAVE YOUR [B]SERVER DATA CALLBACK KEY[/B] AND YOUR [B]ADMIN CONTROL PASSWORD[/B]!
[/LIST]

[IMG]http://i.imgur.com/pQSpAJP.png[/IMG]

[I][COLOR="#FF0000"][B]Then, for the server installation, include Motivote-(current version).jar in your build path.[/B][/COLOR][/I]
[SIZE=1]For PI, here's the method I added in PlayerHandler.java: [url=http://pastebin.com/T6Vvcvvd]Add to PlayerHandler.java - Pastebin.com[/url][/SIZE]

Create RewardHandler.java:
[CODE]import server.model.players.Client;
import server.model.players.Player;
import server.model.players.PlayerHandler;

import com.rspserver.motivote.MotivoteHandler;
import com.rspserver.motivote.Reward;

public class RewardHandler extends MotivoteHandler<Reward>
{
[MENTION=15855]Over[/MENTION]ride
public void onCompletion(Reward reward)
{
int itemID = -1;

if (reward.rewardName().equalsIgnoreCase("gold"))
{
itemID = 995;
}

// SOME OF THIS CODE WILL BE DIFFERENT FOR YOUR SERVER, CHANGE IT ACCORDINGLY. everything to do with motivote will stay the same!
if (PlayerHandler.isPlayerOn(reward.username()))
{
Player p = PlayerHandler.getPlayer(reward.username());

if (p != null && p.isActive == true) // check isActive to make sure player is active. some servers, like project insanity, need extra checks.
{
synchronized(p)
{
Client c = (Client)p;

if (c.getItems().addItem(995, reward.amount()))
{
c.sendMessage("You've received your vote reward! Congratulations!");
reward.complete();
}
else
{
c.sendMessage("Could not give you your reward item, try creating space.");
}
}
}
}
}
}[/CODE]

Add where you initialize/start everything else:
[CODE]new Motivote(new RewardHandler(), "http://yoursite.com/vote/", "server data callback key").start();[/CODE]

[IMG]http://i.imgur.com/nB5EdTn.png[/IMG]

Really, it's that easy. If you have any issues, just post a reply and I'll try and sort them out to the best of my ability. Thanks! Edited by Supah Fly

Share this post


Link to post
Share on other sites
We followed this but it doesn't update the votes when the vote is done?
What have we done wrong?

Share this post


Link to post
Share on other sites
great tut :)

Share this post


Link to post
Share on other sites

×