- Joined
- Jan 1, 2009
- Messages
- 384
- Reaction score
- 20
Now, I'll try to explain how to create your own Vote for Points system or VTP (Vote to Points) as I like to call it (or VTPS=vote to points system).
I want you to know that the system has been tested.
As I always like to say, let's stop talking and start working.
WARNING: This may not be the best way to do it but it is the way I'm doing it on my server.
So how does the vote system I made work?
A page, with as many vote buttons as wanted. Player click one and he's sended to vote.php?vote=voteoption (1,2,3,4...)
The vote.php check if there is any vote option, if there is, it redirects users to voting page and gives bonus in the same time.
BTW it also blocks player from voting a period of time. You decide the period of time.
The code has comment :w00t:. I hope some people will find it usefull :sneaky2:.
I'll give you my vote.php simple page.
PHP:
<?php
/**
* File: vote.php
* Trinity Dev - CodeShout
*/
define('INSIDE' , true);
define('INSTALL' , false);
$xnova_root_path = './';
include($xnova_root_path . 'extension.inc');
include($xnova_root_path . 'common.'.$phpEx);
//Gets the template
$body = gettemplate('vote');
$vote=$_GET['vote'];
//If user already clicked vote for vote option 1
if ($vote==1)
{
//Take time and userid
$temps = time();
$id = $user['id'];
//Add 1 RPG point / Officer point
if(isset($_POST['Vote']))
doquery("UPDATE {{table}} SET bonus_temps1=".$temps.", rpg_points=rpg_points+1 WHERE id=".$id."",'users');
//Redirect to voting page
?>
<script language="javascript" type="text/javascript">
<!--
window.location.replace("http://www.xtremetop100.com/in.php?site=1132290562");
-->
</script>
<?php
}
if ($vote==2)
{
$temps = time();
$id = $user['id'];
if(isset($_POST['Vote']))
doquery("UPDATE {{table}} SET bonus_temps2=".$temps.", rpg_points=rpg_points+1 WHERE id=".$id."",'users');
?>
<script language="javascript" type="text/javascript">
<!--
window.location.replace("http://***************/index.php?do=votes&id=22380");
-->
</script>
<?php
}
if ($vote==3)
{
$temps = time();
$id = $user['id'];
if(isset($_POST['Vote']))
doquery("UPDATE {{table}} SET bonus_temps3=".$temps.", rpg_points=rpg_points+1 WHERE id=".$id."",'users');
?>
<script language="javascript" type="text/javascript">
<!--
window.location.replace("http://www.topgamespro.com/vote.htm?server=2176");
-->
</script>
<?php
}
//Check if he hasnt clicked on a vote button
if ($vote==""){
//For vote option one, it looks in the database for the last time the user has voted
$dernier_vote = $user['bonus_temps1'];
//Takes current time
$temps = time();
//Make difference from current time and last vote
$temps_entre_les_deux_tentatives = $temps - $dernier_vote;
//Takes from database the current number of points the user has
$points_bonus = $user['points_bonus'];
//If the difference between current time and last vote is bigger than the wanted value, it promts user to vote
if ($temps_entre_les_deux_tentatives >= 43200)
//Promt user to vote
$vote = '1 Vote = 1 officer point bonus ! Only one time per day !<br><img src=images/icon_tip.png /><form action="vote.php?vote=1" method="POST"><input name="Vote" type="submit" value="Vote on XtremeTop100" /></form>';
else
//Else tell user that he can vote only 1 time per day
$vote = '1 Vote = 1 officer point bonus ! Only one time per day ! <br /> <img src=images/icon_message.png />';
//Show option vote 1 ( message that can vote and cannot vote )
$parse['vote1'] = $vote;
//FOR THE OTHER VOTE OPTIONS, THE SETTINGS ARE THE SAME
//Vote option two
$dernier_vote = $user['bonus_temps2'];
$temps = time();
$temps_entre_les_deux_tentatives = $temps - $dernier_vote;
if ($temps_entre_les_deux_tentatives >= 43200)
$vote = '1 Vote = 1 officer point bonus ! Only one time per day !<br><img src=images/icon_tip.png /><form action="vote2.php?vote=2" method="POST"><input name="Vote" type="submit" value="Vote on **********" /></form>';
else
$vote = '1 Vote = 1 officer point bonus ! Only one time per day ! <br /> <img src=images/icon_message.png />';
$parse['vote2'] = $vote;
//Vote option three
$dernier_vote = $user['bonus_temps3'];
$temps = time();
$temps_entre_les_deux_tentatives = $temps - $dernier_vote;
if ($temps_entre_les_deux_tentatives >= 43200)
$vote = ' 1 Vote = 1 officer point bonus ! Only one time per day !<br><img src=images/icon_tip.png /> <form action="vote3.php?vote=3" method="POST"><input name="Vote" type="submit" value="Vote on TopGamesPro" /></form>';
else
$vote = '1 Vote = 1 officer point bonus ! Only one time per day ! <br /> <img src=images/icon_message.png />';
$parse['vote3'] = $vote;
}
//These are some things I wanted to show in the template...
$parse['user_username']=$user['username'];
$parse['officer_points']=$user['rpg_points'];
$parse['user_id']=$user['id'];
$parse['user_email']=$user['email'];
$parse['user_server']=$game_config['game_name'];
$page = parsetemplate($body, $parse);
display($page, $lang['Chat'], false);
?>
And here is the template and image files :closedeyes:
Template vote.tpl
PHP:
<style type="text/css">
<!--
.style9 {color: #05cdff}
.style10 {color: #ff6060}
.style11 {color: #FFFFFF}
-->
</style>
<bR />
<br />
<table width="750" colspan="3">
<tr><td class="c" colspan="3"><center>
<font color=red><b>Vote TW</b></font>
</center></td></tr>
<tr>
<th colspan="3"><p><center>
You currently have {officer_points} Officer Points.
</center>
</p></th>
</tr>
<tr>
<th colspan="3"><p><br /><center>
{vote1}
</center>
<br />
</p></th>
</tr>
<tr>
<th colspan="3"><p><br />
<center>
{vote2}
</center><bR />
</p></th>
</tr>
<tr>
<th colspan="3"><p>
<center><br />
{vote3}
</center>
<br>
</p></th>
</tr>
</table>
</body>
</html>
Not a very organised template but it certanly does the job.
And some small image files that need to be in:
images/icon_tip.png
and
images/icon_message.png
The images are in attachment.
OMG - I forgot the SQL part:
PHP:
ALTER TABLE `game_users`
ADD `bonus_temps1` BIGINT(1) NOT NULL,
ADD `bonus_temps2` BIGINT(1) NOT NULL,
ADD `bonus_temps3` BIGINT(1) NOT NULL
Attachments
You must be registered for see attachments list
Last edited: