Jump to content

EverythingRS Auto Vote Tutorial


EverythingRS
 Share

Recommended Posts

EverythingRS - Free Voting Installation

EverythingRS is a free API system. Here's a quick tutorial on how to get started with voting.

ONk5sJY.png Support Discord

If you need more help or for some reason cannot understand the tutorial. You can post a comment on this thread or reach us at our support Discord.

https://discord.gg/rGN8zCV

Getting started

  • First off download our everythingrs-api.jar from here and include it into your project.
  •  

Registration and secret key

Your voting subdomain!

http://i.imgur.com/5PtxrJy.png

http://i.imgur.com/Y43oM58.png

Making the auto vote work with your server

This part is for PI & Ruse but can easily be changed to work with any server. If you have a request for a specific server let me know and I can add it to the tutorial.

  • Add the code below into Commands.java and you're all done!
  •  

For PI

 

            if (playerCommand.startsWith("reward")) {
                String[] args = playerCommand.split(" ");
                if (args.length == 1) {
                    c.sendMessage("Please use [::reward id], [::reward id amount], or [::reward id all].");
                    return;
                }
                final String playerName = c.playerName;
                final String id = args[1];
                final String amount = args.length == 3 ? args[2] : "1";
	                com.everythingrs.vote.Vote.service.execute(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key",
                                    playerName, id, amount);
                            if (reward[0].message != null) {
                                c.sendMessage(reward[0].message);
                                return;
                            }
                            c.getItems().addItem(reward[0].reward_id, reward[0].give_amount);
                            c.sendMessage(
                                    "Thank you for voting! You now have " + reward[0].vote_points + " vote points.");
                        } catch (Exception e) {
                            c.sendMessage("Api Services are currently offline. Please check back shortly");
                            e.printStackTrace();
                        }
                    }
	                });
            }


 


For Vencillio

 

In PlayerCommand.java under

switch (parser.getCommand()) {

Add 

    case "reward":
        if (!parser.hasNext(1)) {
            player.send(new SendMessage("Please use [::reward id], [::reward id amount], or [::reward id all]."));
            return true;
        }
        final String playerName = player.getUsername();
        final String id = parser.nextString();
        final String rewardAmount = parser.hasNext(1) ? parser.nextString() : "1";
	        com.everythingrs.vote.Vote.service.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key", playerName, id, rewardAmount);
                    if (reward[0].message != null) {
                        player.send(new SendMessage(reward[0].message));
                        return;
                    }
                    player.getInventory().add(new Item(reward[0].reward_id, reward[0].give_amount));
                    player.send(new SendMessage("Thank you for voting! You now have " + reward[0].vote_points + " vote points."));
                } catch (Exception e) {
                    player.send(new SendMessage("Api Services are currently offline. Please check back shortly"));
                    e.printStackTrace();
                }
            }
	        });
        return true;

 

For Ruse

 

In CommandPacketListener.java

under 

private static void playerCommands(final Player player, String[] command, String wholeCommand)  {

Add

Code for Ruse

 

        
        if (command[0].startsWith("reward")) {
            if (command.length == 1) {
                player.getPacketSender().sendMessage("Please use [::reward id], [::reward id amount], or [::reward id all].");
                return;
            }
            final String playerName = player.getUsername();
            final String id = command[1];
            final String amount = command.length == 3 ? command[2] : "1";
	            com.everythingrs.vote.Vote.service.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key",
                                playerName, id, amount);
                        if (reward[0].message != null) {
                            player.getPacketSender().sendMessage(reward[0].message);
                            return;
                        }
                        player.getInventory().add(reward[0].reward_id, reward[0].give_amount);
                        player.getPacketSender().sendMessage("Thank you for voting! You now have " + reward[0].vote_points + " vote points.");
                    } catch (Exception e) {
                        player.getPacketSender().sendMessage("Api Services are currently offline. Please check back shortly");
                        e.printStackTrace();
                    }
                }
	            });
        }
        

 

For Matrix

 

        case "reward":
            final String playerName = player.getUsername();
            final String id = cmd[1];
            final String rewardAmount = "1";
            com.everythingrs.vote.Vote.service.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward(
                                "secret_key", playerName,
                                id, rewardAmount);
                        if (reward[0].message != null) {
                            player.getPackets().sendGameMessage(reward[0].message);
                            return;
                        }
                        player.getInventory().addItem(new Item(reward[0].reward_id, reward[0].give_amount));
                        player.getPackets().sendGameMessage("Thank you for your support in voting! You have "
                                + reward[0].vote_points + " vote points left.");
                        player.getCompCapeManager().increaseRequirement(Requirement.VOTES, 1);
                        player.setVoteTokens(player.getVoteTokens() + 1);
                    } catch (Exception e) {
	                        player.getPackets().sendGameMessage("Voting services are currently offline, please check back shortly.");
                        e.printStackTrace();
                    }
                }
	            });
            return true;

 

For Other Servers

The script is compatible with any base, if you however need help adding it to a specific one, leave a link to the base and I'll add it to the tutorial.


Fin

You are now finished adding the auto vote onto your server. Continue if you want to learn how to add and remove items, and adding support for several toplists.


Adding and removing items

  • Adding and removing items is incredibly simple. Go to you voting dashboard at  https://everythingrs.com/account/vote/manage
  • Once there go to the "Add new reward" section, and you can proceed to enter the reward information (item id, item name, item points, item amount)
  • To remove a reward just press the red "x" button 
  • The voting script goes by a point system. So for each vote on a toplist your players will get a certain amount of points which is set by you.
  • To claim an item and use your points type ::reward x in-game
  •  

http://i.imgur.com/JZ57sU0.png

http://i.imgur.com/kTFPwRN.png

Adding several toplists

When registering onto a new toplist and asked for an optional callback use this exactly how it is. 

https://callback.everythingrs.com/process.php?i=
  • Once you enter the callback, go onto EverythingRS and in your AutoVote place your toplist id
  • If you want to only show toplists that you are registered on, check the "Do not display listings as "unregistered" if I have decided not to add it"

7mKvUks.png

Edited by EverythingRS
Link to comment
Share on other sites


  • EverythingRS changed the title to EverythingRS Auto Vote Tutorial

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share