Menu

WGD Features
Articles and Reviews
Showcase
Link to Us!
Write for Us!

WGD Resources
Blogs
Help
Polls
Search
Tools

WGD Community
Forums
Online Chat

Pages: [1]   Go Down
  Print  
Author Topic: Reward Script Tutorial for TopWebGames  (Read 1525 times)
zewlie
Global Moderator
Newbie
*
*
Offline Offline

Posts: 3


« on: June 16, 2007, 06:55:54 AM »

[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.

Quote
<?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.
Logged
renlok
WGD Enhanced
Newbie
*
Offline Offline

United Kingdom United Kingdom

Posts: 4


« Reply #1 on: June 20, 2007, 03:39:23 AM »

you should have something like

Code:
<?php
include('config.php');

$player_id $_POST['player_id'];
if(!
$player_id){$player_id '1';}

   if(
$player_id >0){
       
$sql mysql_query("SELECT * FROM players WHERE player_id='$player_id'")or die("Cannot get stuff " . @mysql_error());
      
$result mysql_fetch_array($sql);
      if(
$result['lastvote'] < (time() - (60*60*24))){
            @
mysql_query("UPDATE players SET money=money+'5000', lastvote = " time() . "WHERE player_id='$player_id' LIMIT 1")or die("Cannot update stats! " . @mysql_error());
      }
}
header('location: whereever');
?>

where lastvote is when user last voted so you can limit them to vote once a day and whereever is the location of your voting link so the user never see the voting page.

and 60*60*24 is one day i seconds if you wanna change this to a week change it to 60*60*24*7
Logged

crazyball
Administrator
Full Member
*
*
Offline Offline

Canada Canada

Posts: 145



WWW
« Reply #2 on: June 20, 2007, 05:32:10 AM »

Well done both of you!

Logged

Eye of the Beholder - Watcher of all things
zewlie
Global Moderator
Newbie
*
*
Offline Offline

Posts: 3


« Reply #3 on: June 20, 2007, 09:08:53 AM »

I think TopWebGames only allows voting once a week... for me, I added a variable 'voted' which is reset with my weekly cron that allows only people who haven't voted to see the voting link in the header.
Logged
sidneycat
WGD Enhanced
Jr. Member
*
Offline Offline

United Kingdom United Kingdom

Posts: 79


Powerful powerful Busker


WWW
« Reply #4 on: June 20, 2007, 10:47:33 AM »

It's twice a week  Cheesy
Logged

Regards,
Sidneycat

http://buskerwars.com
Pages: [1]   Go Up
  Print  
 
Jump to:  

User
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 03, 2009, 10:46:59 PM

Login with username, password and session length

WGD Friends
Social Gamer.org
Crazyball Nexus
Sticky Feet

Recent
[December 07, 2008, 05:13:58 PM]

[July 09, 2008, 04:59:13 AM]

[July 04, 2008, 09:28:31 AM]

[July 04, 2008, 09:19:49 AM]

[July 04, 2008, 01:10:44 AM]

[July 02, 2008, 05:10:38 AM]

[July 02, 2008, 05:07:05 AM]

[June 30, 2008, 11:27:54 AM]

[June 30, 2008, 11:18:24 AM]

[June 30, 2008, 10:55:27 AM]

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!


Google visited last this page July 02, 2009, 03:43:10 PM