Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

reward players automaticly after they buy gold

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jan 27, 2012
Messages
39
Reaction score
4
you can use superrewards so your players will get points automaticly after paying and aswell you can get money from ppl that can't pay while they doing surveys for gold

Register an account at srpoints.com

than add an application to your srpoints account

add the postback.php to your game server

PHP:
<?php
// +---------------------------------------------+
// | Super Rewards Call back script WITH loging  |
// +---------------------------------------------+
// | DONOT REMOVE THIS                           |
// +---------------------------------------------+
// | Copyright Rodney Cheney 2011-2015           |
// +---------------------------------------------+
include("GameEngine/Database.php");

    $SECRET = "APP KEY";   ///this is you apps secret key get this from app info
    $snuid = $_REQUEST['uid'];      // this grabs the snuid from the url
    $currency = $_REQUEST['new'];   // this grabs amount of points to award user
    $total= $_REQUEST['total'];     // this grabs total points super rewards has ever sent user
    $offerwallID = $_REQUEST['oid'];// this grabs the offer walls offer ID
    $transactionID = $_REQUEST['id'];//this grabs the taransaction id from super rewards
    $sidverify = $_REQUEST['sig'];  // this grabs the hashed info for you to authenticate with
   
    // make  a hash of our own to verify authenicc transaction
    $sig = md5($_REQUEST['id'] . ':' . $_REQUEST['new'] . ':' . $_REQUEST['uid'] . ':' . $SECRET);
    
    //here we are gonna count the total points loged each time user has recived points
    $sql = "SELECT SUM(`points`) as `DeadWeight` FROM `sr_log` WHERE `userID`='$snuid'";

    if( !($result = mysql_query($sql)) ) 
        {
            die('Failed to query database. srlogs.');
        }
 
 $row = mysql_fetch_array($result);
 $DeadWeight = $row['DeadWeight']; 
 
    

// You may want to add other checks to ensure that the user exists in your system

//Check if hashed info is same as hashed info from superrewards if not do nothing.
if  ($sidverify == $sig)
    {
        //Insert Super Rewards transaction info into your database
        mysql_query("INSERT INTO sr_log SET points=$currency,total=$total,oid=$offerwallID,userID=$snuid, transID=$transactionID");
        //Check if the total amount of points awarded to users is less then or the same as total from super rewards
        //This will make sure you dont give more then you should.
        if  ($DeadWeight <= $total)
            {
                //If all is good Update the user with there points from the url request.
mysql_query("UPDATE ".TB_PREFIX."users SET gold = gold + ".$currency." WHERE id = '".$snuid."'");
  
            }
      echo "1";
    }else{
        echo "0";     
    }
    

  
?>
change APP KEY to yours
add to your database:
PHP:
DROP TABLE IF EXISTS `sr_log`;
CREATE TABLE IF NOT EXISTS `sr_log` (
  `transID` int(11) NOT NULL,
  `userID` int(11) NOT NULL,
  `Points` int(11) NOT NULL,
  `oid` varchar(255) NOT NULL,
  `total` int(11) NOT NULL,
  PRIMARY KEY (`transID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
and add the iframe to templates/plus/1.tpl
and change uid=<[USER ID]> to uid=<?php echo $session->uid; ?>
and than go to the tarrifs and test the postback
hope it helps and sorry for my bad english :thumbup1:
and thanks to advo for the postback script
 
Last edited:
Working in iZariam v0.1.0
Loyal Member
Joined
Feb 3, 2011
Messages
772
Reaction score
74
Good work advocaite and thanks sat132 for release
 
Joined
May 15, 2009
Messages
799
Reaction score
558
SUM(`points`) as `DeadWeight` means the sum of the points will be used as var deadweight meaning when i use $Row[DeadWeight] that var will return the sum of points notice the 'as' just dont do anything other then what the poster said and it will work fine
 
Initiate Mage
Joined
Apr 15, 2012
Messages
1
Reaction score
0
no need it works 100% i know i created it lol can also be used in any site you like that has user ids as numbers

Hey advocaite how can i get it to work with my site? My site user id's are not numbers there just the user names.

Regards
Hackz0
 
Status
Not open for further replies.
Back
Top