Viewing a Page Adds and/or Takes Away Money

Forum
Last Post
Threads / Messages

Blizzard

Extreme Animal Lover
Member
Joined
Dec 23, 2011
Messages
14
Points
0
Location
Canada
Mysidian Dollar
0
First of all, I am really sorry if someone already asked this, I looked and couldn't find anything.

How can you make it so when a player views a page, a certain amount of their money is taken away or added?

I am really new to coding and trying to figure everything out. Thanks it advance. :)
 
I'm not sure if you already got an answer to this since yet since you posted this question awhile ago, but since there are no replies yet, I'll give you the most basic script I can think of.

<?php

include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("functions/functions_friends.php");
include("functions/functions_items.php");
include("inc/lang.php");
include("inc/bbcode.php");

//***************//
// START SCRIPT //
//***************//

$cashname = grabanysetting("cost");
$reward= 1;

if($isloggedin == "yes"){
changecash($reward, $GLOBALS['username'], $GLOBALS['money']);
$article_title = "Hello, {$username}!";
$article_content = "You have gained {$reward} {$cashname}.";
}
else{
$article_title = "You are not logged in!";
$article_content = "You must be logged in to view this page!";
}

//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);
?>

To change how much money they receive, just change the number after "$reward". :)
 
Well I'd say use $loggedinname instead of $GLOBALS['username'] if you can. The superglobal arrays are both insecure and slow, I've actually gotten rid of all of them in the next release. It is convenient to use though, which is why we used to be doing it this way.
 

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top