First off a
Disclaimer these are modifications of existing php stuff. I'm all right with tricking them to work in certain environments, but cannot get them to function at all with the Mys script yet.
Mod 01: Reward System
Inspired by Online Trading Card Games like MissingNO (tell them Sidiko sent you), original script from In The Cards.
So far all I'm getting are errors. I have a feeling that we'll have to add stuff into the functions of the script to get this to work.
Current Code
PHP Code:
<?php
// **********************************************************************
// Rusnak PHP Adoptables Script
// Copyright 2009 Brandon Rusnak
// For help and support: http://www.rusnakweb.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************
// Wake the sleeping giant
// **********************************************************************
// Basic Configuration Info
// **********************************************************************
include("inc/functions.php");
include("inc/config.php");
$themeurl = grabanysetting("themeurl");
// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************
$links = getlinks();
// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************
$ads = getads("any");
// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************
$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);
// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************
$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");
// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];
// **********************************************************************
// End Prepwork - Output the page to the user
// **********************************************************************
// **********************************************************************
// Let's Set up the Rewards for the games
//
// This works great when you're giving out items and such along with money
// What will you use? Please feel free to ask < enddayne > on how to
// Modify this script on the forum :)
// **********************************************************************
// First We'll Get The Money and Run...
// **********************************************************************
$query = "SELECT * FROM `adopts_users` WHERE `username`='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < 1) {
$dollar = @mysql_result($result, $i, "dollar");
// Change this number 10 to the number of currency you want users to earn on level up
$amount = rand(5, 15);
$newbalance = $dollar + $amount;
$i++;
}
mysql_query("UPDATE `adopts_users` SET `dollar`='" . $newbalance . "' WHERE `username`='$loggedinname'");
// **********************************************************************
// Let's add the items in next, may also work for decorations... eventaually
// **********************************************************************
function randomImage ( $array ) {
$total = count($array);
$call = rand(0,$total-1);
return $array[$call];
}
$items = array (
'items/bomb.png',
'items/cake.png',
'items/controller.png',
'items/guitar.png',
'items/heaphones.png'
);
// **********************************************************************
// Use the above syntax when adding more items to the script
// **********************************************************************
$article_title = $article_title."Reward";
$article_content = $article_content . "<div align='center'><br />You have earned ". $amount ." Dollars for leveling up this Adoptable. <br />You now have " . $newbalance . " Dollars.
You have also gained the following item from playing the game.<br />
<img src='".randomImage($items)." alt='Prize'></div>;"
// **********************************************************************
// Begin Template Definition
// **********************************************************************
//Define our current theme
$file = $themeurl;
// Do the template changes and echo the ready template
$template = file_get_contents($file);
$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);
//Define our links
$template = replace(':LINKSBAR:',$links,$template);
//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);
//Get the ad content...
$template = replace(':ADS:',$ads,$template);
//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);
echo $template;
// **********************************************************************
// End Template Definition
// **********************************************************************
?>
We're logging the following error at the moment:
Quote:
Parse error: syntax error, unexpected T_VARIABLE in /home/enddayne/public_html/devdemo/reward.php on line 123
|