Jump to content
MakeWebGames

Need help with an incentive reward script


shaved92bravada
 Share

Recommended Posts

I was trying to make my own reward script that the voting sites could send a responce to in which that would be the only way the player would be rewarded is if they actually voted and the voting site sent their responce to my script. Well I made one and ran it manually, worked great but will not work with the voting sites that support incentive scripts, so I found an example of a reward script off of one of the voting sites and am trying to edit it to make it work correctly but so far to no avale. I will also add that I am not the greatest with programming, I am just trying to learn it on my own with help from the forums as well as other known and often posted sites lol. Anyway any help or suggestions would be greatly appreciated.

here is what I have so far. Oh and I am using V2 as you can tell by the include "globals.php"; in my version of it. Thank you in advance for your contructive critisism or suggestions in advance.

The original example script.

 

<?

// Set content type
header('Content-type: text/xml');


// Check input
if (!isset($_GET['success']) || !isset($_GET['userid'])) {
echo '<response rewarded="0" message="Invalid input." />';
die();
}


// Get data
$success = $_GET['success'];
$userID = $_GET['userid'];


// Has this user already claimed a reward today?
$alreadyRewarded = false;
if ($alreadyRewarded) {
echo '<response rewarded="0" message="You have already claimed a reward today." />';
die();
}


// Credit reward
if ($success == 1) {

// Give large reward here

echo '<response rewarded="1" message="Large reward given for your successful vote." />';
die();
}
else {

// Give small reward (or no reward) here

echo '<response rewarded="1" message="Small reward given for your attempted vote." />';
die();
}


?>

 

And after I added in a few things it needed and some I thought it needed. lol

 

<?
// Set content type
header('Content-type: text/xml');
include "globals.php";

// Check input
if (!isset($_GET['success']) || !isset($_GET['userid'])) {
echo '<response rewarded="0" message="Invalid input." />';
die();
}


// Get data
$success = $_GET['success'];
$userID = $_GET['userid'];
$q=$db->query("SELECT * FROM users WHERE userid = $userID");
while($r=$db->fetch_row($q))
// Has this user already claimed a reward today?
if ($r['rewarded']=1) {
echo '<response rewarded="0" message="You have already claimed a reward today." />';
die();
}


// Credit reward
if ($success == 1) {
$db->query("UPDATE users SET crystals=crystals+10, rewarded=1 WHERE userid=$userID");
// Give large reward here
event_add($userID, "For actually voting you have recieved 10 Crystals.", $c);
echo '<response rewarded="1" message="Large reward given for your successful vote." />';
die();
}
else if ($success == 0)

{

// Give small reward (or no reward) here
event_add($userID, "Thanks for trying to vote but it didn't count.", $c);
echo '<response rewarded="1" message="Thanks for your attempted vote." />';
die();
}


?>
Link to comment
Share on other sites

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

×
×
  • Create New...