So I made Motivote 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.
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.
MAKE SURE YOU SAVE YOUR SERVER DATA CALLBACK KEY AND YOUR ADMIN CONTROL PASSWORD!
Then, for the server installation, include Motivote-(current version).jar in your build path.
For PI, here's the method I added in PlayerHandler.java: Add to PlayerHandler.java - Pastebin.com
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>
{
@Override
public void onCompletion(Reward reward)
{
// SOME OF THIS CODE WILL BE DIFFERENT FOR YOUR SERVER, CHANGE IT ACCORDINGLY. everything to do with motivote will stay the same!
int itemID = -1;
if (reward.rewardName().equalsIgnoreCase("gold"))
{
itemID = 995;
}
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(itemID, 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.");
}
}
}
}
}
}
Add where you initialize/start everything else:
Code:
new Motivote(new RewardHandler(), "http://yoursite.com/vote/", "server data callback key").start();
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!
Why do people insist on formatting their code unconventionally
if you're talking about my java, I've stopped doing that but just didn't update my settings in eclipse. my php is formatted like normal people do it now.
I used to do it for my own readability, but I realize it's not that big a deal and I should try to be conventional
Php looks nice and clean, i will install and test this when i have time.
I have some questions:
- Does this have "multi voting" checks?
- Does this require html 5?
Php looks nice and clean, i will install and test this when i have time.
I have some questions:
- Does this have "multi voting" checks?
- Does this require html 5?
Anyways nice release
what do you mean by multi-voting checks?
and no, this is meant to work an a wide range of browsers with no issue. it's possible to write an html5 theme, but the default is not formatted that way.
and no, this is meant to work an a wide range of browsers with no issue. it's possible to write an html5 theme, but the default is not formatted that way.
I believe he's askin if it supports multiple callbacks or not.
I think he means if it has proxy checks and doesn't allow users being submitted to the db more than once over 12hours.
yes, it works like this:
user clicks button, if they can vote again (time is up) => insert vote into db, but isn't counted as completed, redirect to vote site
user votes, then it's completed. vote interface checks server and server tells them how long until next vote.