Jump to content
MakeWebGames

Recommended Posts

Posted

i have an interactivem menu in my game, most of it works, i have recently been trying to add in a Crimes page into the menu

Below is what i have so far and need a pointer in the right direction

its the docrime.php for the menu.

the problem that is occuring is it keeps saying "You do not have enough Brave to perform this crime."

Thanks

 

<?php
$macropage="criminaldocrime.php?c={$_GET['c']}";
session_start();
if (!isset ($_SESSION['userid']) ) {
   echo '<p>Not logged in.</p>';
   exit;
}
include "config.php";
global $_CONFIG,$set;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;



$userid = $db->query('SELECT `userid` FROM `users` WHERE (`userid` = '.$_SESSION['userid'].')');


$ir = $db->query('SELECT `userid`, `hospital`, `jail`, `level`, `energy`, `maxenergy`, `will`, `maxwill`, `brave`, `maxbrave`, `exp`, `hp`, `maxhp`, `gymxp`, `gexp_needed` FROM `users` WHERE (`userid` = '.$_SESSION['userid'].')');


$r = $db->query('SELECT `crimeNAME`, `crimeBRAVE`, `crimeID`, `crimePERCFORM`, `crimeITEXT`, `crimeSUCCESSMUNY`, `crimeSTEXT`, `crimeSUCCESSCRYS`, `crimeXP`, `crimeSUCCESSITEM` , `crimeFTEXT`, `crimeJAILTIME`, `crimeJREASON`, `crimeJTEXT` FROM crimes');


if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed while in jail or hospital."); }
$_GET['c']=abs((int) $_GET['c']);
if(!$_GET['c'])
{
print "Invalid crime";
}
else
{
$q=mysql_query("SELECT * FROM crimes WHERE crimeID={$_GET['c']}",$c);
$r=mysql_fetch_array($q);



if($ir['brave'] < $r['crimeBRAVE'])
{
print "You do not have enough Brave to perform this crime.";
}
else
{
$ec="\$sucrate=".str_replace(array("LEVEL","CRIMEXP","EXP","WILL","IQ"), array($ir['level'], $ir['crimexp'], $ir['exp'], $ir['will'], $ir['IQ']),$r['crimePERCFORM']).";";
eval($ec);
print $r['crimeITEXT'];
$ir['brave']-=$r['crimeBRAVE'];
mysql_query("UPDATE users SET brave={$ir['brave']} WHERE userid=$userid",$c);
if(rand(1,100) <= $sucrate)
{
print str_replace("{money}",$r['crimeSUCCESSMUNY'],$r['crimeSTEXT']);
$ir['money']+=$r['crimeSUCCESSMUNY'];
$ir['crystals']+=$r['crimeSUCCESSCRYS'];
$ir['exp']+=(int) ($r['crimeSUCCESSMUNY']/6);
mysql_query("UPDATE users SET money={$ir['money']}, crystals={$ir['crystals']}, exp={$ir['exp']},crimexp=crimexp+{$r['crimeXP']},crimesdone=crimesdone+1 WHERE userid=$userid",$c);
if($r['crimeSUCCESSITEM'])
{
 item_add($userid, $r['crimeSUCCESSITEM'], 1);
}
}
else
{
if(rand(1, 2) == 1)
{
print $r['crimeFTEXT'];
}
else
{
 print $r['crimeJTEXT'];
 $db->query("UPDATE `users` SET `jail` = '$r[crimeJAILTIME]', `jail_reason` = '$r[crimeJREASON]' WHERE `userid` = '$userid'");
}
}

print "<br /><a href='criminaldocrime.php?c={$_GET['c']}'>Try Again</a><br />
<a href='playerbars.php'>close</a>";
}
}


$h->endpage();
?>
Posted

Your queries are a bit wrong.

Line 23 your doing a query for the userid.

Then on line 26 your doing it again.

Line 26 is not actually getting a result. Your making the query but no result.

So you can get rid of one of those.

Line 29 is not required as your doing that query on line 40

Posted

query the database $db->query

fetch the results from the query $db->fetch_row

Your making the query but not fetching the results

$ir_query=$db->query('select userid from users where userid='.$_SESSION['userid'].'');

$ir=$db->fetch_row($ir_query);

This would be done already if you included the globals.php unless you cannot due to the interactive menu.

Posted

yeah, i cannot use the globals and its in the interactive menu,

I have managed to get several other pages working fine within the interactive menu which are,

Armoury,

Shortcuts,

- Basic Bank

- Credit Card

- Cyber Bank

- Point Bank

- Point Trader

- Gym

- Crimes (this is the one in question.

Player Stats,

Player Bars,

Energy Refill in tab 2,

Its Just this page is the one getting me lol, i just dont get why all these pages work and the crimes does not.

One this is compeleted and finnished totall i might release it.

Posted

its working now but i kinda got a little problem.

$_GET['c']=abs((int) $_GET['c']);

if(!$_GET['c'])

These Lines grabs the Number from the Address bar, as its in the inteactive menu how do i get the GET to collect the link from an iframe?

Posted

2 = Iframes.

Custom Criminal is in Iframe1.

In Iframe 1 is, crime Name, Crime Brave and Crime Do

Crime Do is then sent to Iframe2.

But iframe 2 just says

"You do not have enough Brave to perform this crime."

In this case its not collecting the GET c from Iframe1 for Iframe2.

How do i get the GET from Iframe2 to find the GET c from Iframe1.

Help would be alot of help. thanks

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.

×
×
  • Create New...