[Pulled from my
blog]
If you have an online game, you can get a great deal of free traffic from
TopWebGames.com simply by posting a listing and asking your members to vote. If your users aren't easily persuaded, you may want to offer them an in-game reward for their time. Fortunately, TWG has a system in place that will automatically send your server each voter's ID. All you have to do is write the reward script!
Below is the script that I use for my own game. The colored phrases
must be replaced to adapt to your game! Instructions are listed below the script.
<?php
echo " ";
include('config.php');
$player_id = $_POST['player_id'];
if(!$player_id){$player_id = '1';}
if($player_id >0){
@mysql_query("UPDATE players SET money=money+'5000' WHERE player_id='$player_id' LIMIT 1")or die("Cannot update stats! " . @mysql_error());
}
echo "done!";
?>
Red: here, you must replace "config.php" with your own config file. This file contains your database details and allows the script to connect to your database. [tutorial]Blue: replace 'player_id' with the variable your game uses to identify individual users.
Green: this is the account that the reward will be sent to if no user is selected. You should put your account number/name here.Orange: replace 'players' with the name of the table in your database that stores your users' data.Purple: replace 'money' with the name of the variable your game uses for its currency/points.Teal: replace '5000' with the quantity of currency/points you want to reward your users with for voting.IMPORTANT!- Save the script as a PHP file and give it a complicated name (ex: twg83dkef80fefk9.php) so that users are unable to guess its location and abuse it.
- When adding the script to TopWebGames (Member Area -> Manage Current Listings -> Incentivizing -> Setup), make sure to set the 'Reward Script Method' to
POST.