PDA

View Full Version : changecash() not working


AlexC
05-17-2012, 06:00 PM
A mod I'm using, which includes a change in cash, is reporting an error;

Fatal error: Call to undefined function changecash() in /home/u973139355/public_html/slotmachine.php on line 51

The line in question is:

changecash($reward, $GLOBALS['username'], $GLOBALS['money']);

The full page;

<?php

include("functions/functions.php");

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


if($isloggedin == "yes"){
// If we are logged in, we check if a user with our username voted for this adoptable today...




// Adoptable is not frozen, end isfrozen else check
$act = $_GET['act'];
if($act == 'confirm'){
$slot1 = rand(1,6);
$slot2 = rand(1,6);
$slot3 = rand(1,6);
$slot4 = rand(1,6);
$slot5 = rand(1,6);
$slot6 = rand(1,6);

if($slot1 == 1 && $slot2 == 1 && $slot3 == 1 && $slot4 == 1 && $slot5 == 1 && $slot6 == 1){
$reward = 10;
}elseif($slot1 == 2 && $slot2 == 2 && $slot3 == 2 && $slot4 == 1 && $slot5 == 1 && $slot6 == 1){
$reward = 20;
}elseif($slot1 == 3 && $slot2 == 3 && $slot3 == 3 && $slot4 == 1 && $slot5 == 1 && $slot6 == 1){
$reward = 30;
}elseif($slot1 == 4 && $slot2 == 4 && $slot3 == 4 && $slot4 == 4 && $slot5 == 4 && $slot6 == 4){
$reward = 40;
}elseif($slot1 == 5 && $slot2 == 5 && $slot3 == 5 && $slot4 == 5 && $slot5 == 5 && $slot6 == 5){
$reward = 50;
}elseif($slot1 == 6 && $slot2 == 6 && $slot3 == 6 && $slot4 == 6 && $slot5 == 6 && $slot6 == 6){
$reward = 60;
}elseif($slot1 == 1 && $slot2 == 2 && $slot3 == 3 && $slot4 == 4 && $slot5 == 5 && $slot6 == 6){
$reward = 100;
}else{
$reward = 0;
}


if($reward > 1){
$rewardmessage = "Congratulations, you have gained ".$reward." ". grabanysetting('cost') ."!";
}else{
$rewardmessage = "Sorry, you didnt win a prize this time, try again later.";
}

changecash($reward, $GLOBALS['username'], $GLOBALS['money']);
$article_content = $article_content . "<div align='center'><br /><img src='".$slot1.".png'><img src='".$slot2.".png'><img src='".$slot3.".png'><br />".$rewardmessage."<br />You now have {$GLOBALS['money']} ".grabanysetting('cost')."</div>";

}


else{

$article_title = "Slot Machine!";
$article_content = "Welcome at the slot machine!, here you can win various prizes!<br /><br /><a href='slotmachine.php?act=confirm'>Use the slot machine!</a>";


}




}

else{
$article_title = "Sorry!";
$article_content = "Sorry, as a guest you cant use the slotmachine!, please register or log in.";
}


// End the ID is not blank and is numeric else check


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

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

?>



This is a modified version of the script I found on here - it was for 1.2.x but I managed to get it working for 1.3.x before. Then somehow it got all messed up and now I'm not sure how to make it work again.

Hall of Famer
05-17-2012, 10:37 PM
I am pretty sure the changecash() function is located in file functions_users.php, you need to include this library file.

AlexC
05-18-2012, 05:49 AM
oohhhh... darn it, that was probably it. I'll go change that and see if it works.

EDIT: That works... thanks for your help again. D: One day I'll learn all the stupid things I do.