Jump to content
MakeWebGames

Recommended Posts

Posted
?php
include "globals.php";
if($r['itmname'] == 'Weed')
{
mysql_query("UPDATE users SET brave=brave+10 WHERE userid=$userid",$c);
}
print "You roll a fat blunt full of {$r['itmname']} and start to hit it. You feel a bit more focused.";


$h->endpage();
?>

It wont update the brave in the db that is what my problem is

Posted

to answer reeye yeah that is just missed it when i copyed and pasted it and danny there is no error it works fine just wont update the db to make it lets say 15/5 instead of 5/5

Posted

I see your issue.

The second number of the brave indicated the MAX value that the brave can be.

You cannot add 10 since the max is only 5 brave (which is why it is 5/5)

Posted

ok so how would i make it do that to make it so it would go 15/5 instead of 5/5 im trying to implement drugs into my game sorta like tcs drug system

Posted

Opps, i read your problem wrong. I actually cant see a problem with that script. also, Redeye, your wrong. Just becuase you have a max value (i a diff column) then you shouldnt have a problem. Unless your checking that your not over the max in your script somewhere.

Posted (edited)

yeah its no big ill fix that and define it there but as danny had said there is a check to change the vaules back as it is in the cron_fivemins.php

$query2="UPDATE users SET brave=maxbrave WHERE brave>maxbrave";

ok so to fix what Dj had said i edit the itemuse.php so i could use it even if a effect wasn't on because the effects don't up date a brave either if i do it that way the stat just wont update in the db know matter what it try

Edited by skizzy
because problem not solved as i thought it was
Posted

if($r['itmname'] == 'Weed')

{

mysql_query("UPDATE users SET brave=brave+10 WHERE userid=$userid",$c);

}

print "You roll a fat blunt full of {$r['itmname']} and start to hit it. You feel a bit more focused."; i add this into the itemuse.php as {$r['itmname']} would be defined there and it still dont update the brave

Posted
<?php
include "globals.php";
$_GET['ID'] = abs((int) $_GET['ID']);
//Food
if(!$_GET['ID'])
{
print "Invalid use of file";
}
else
{
$i=$db->query("SELECT iv.*,i.*,it.* FROM inventory iv LEFT JOIN items i ON iv.inv_itemid=i.itmid LEFT JOIN itemtypes it ON i.itmtype=it.itmtypeid WHERE iv.inv_id={$_GET['ID']} AND iv.inv_userid=$userid");
if(mysql_num_rows($i) == 0)
{
print "Invalid item ID";
}
else
{
$r=$db->fetch_row($i);

if($r['effect1_on'])
{
 $einfo=unserialize($r['effect1']);
 if($einfo['inc_type']=="percent")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {

     $inc=round($ir['max'.$einfo['stat']]/100*$einfo['inc_amount']);
   }
   else
   {
     $inc=round($ir[$einfo['stat']]/100*$einfo['inc_amount']);
   }
 }
 else
 {
   $inc=$einfo['inc_amount'];
 }
 if($einfo['dir']=="pos")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {
     $ir[$einfo['stat']]=min($ir[$einfo['stat']]+$inc, $ir['max'.$einfo['stat']]);
   }
   else
   {
     $ir[$einfo['stat']]+=$inc;
   }
 }
 else
 {

     $ir[$einfo['stat']]=max($ir[$einfo['stat']]-$inc, 0);

 }
 $upd=$ir[$einfo['stat']];
 if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ')))
 {
   $db->query("UPDATE `userstats` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
 else
 {
   $db->query("UPDATE `users` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
}
if($r['effect2_on'])
{
 $einfo=unserialize($r['effect2']);
 if($einfo['inc_type']=="percent")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {

     $inc=round($ir['max'.$einfo['stat']]/100*$einfo['inc_amount']);
   }
   else
   {
     $inc=round($ir[$einfo['stat']]/100*$einfo['inc_amount']);
   }
 }
 else
 {
   $inc=$einfo['inc_amount'];
 }
 if($einfo['dir']=="pos")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {
     $ir[$einfo['stat']]=min($ir[$einfo['stat']]+$inc, $ir['max'.$einfo['stat']]);
   }
   else
   {
     $ir[$einfo['stat']]+=$inc;
   }
 }
 else
 {

     $ir[$einfo['stat']]=max($ir[$einfo['stat']]-$inc, 0);

 }
 $upd=$ir[$einfo['stat']];
 if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ')))
 {
   $db->query("UPDATE `userstats` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
 else
 {
   $db->query("UPDATE `users` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
}
if($r['effect3_on'])
{
 $einfo=unserialize($r['effect3']);
 if($einfo['inc_type']=="percent")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {

     $inc=round($ir['max'.$einfo['stat']]/100*$einfo['inc_amount']);
   }
   else
   {
     $inc=round($ir[$einfo['stat']]/100*$einfo['inc_amount']);
   }
 }
 else
 {
   $inc=$einfo['inc_amount'];
 }
 if($einfo['dir']=="pos")
 {
   if(in_array($einfo['stat'],array('energy','will','brave','hp')))
   {
     $ir[$einfo['stat']]=min($ir[$einfo['stat']]+$inc, $ir['max'.$einfo['stat']]);
   }
   else
   {
     $ir[$einfo['stat']]+=$inc;
   }
 }
 else
 {

     $ir[$einfo['stat']]=max($ir[$einfo['stat']]-$inc, 0);

 }
 $upd=$ir[$einfo['stat']];
 if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ')))
 {
   $db->query("UPDATE `userstats` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
 else
 {
   $db->query("UPDATE `users` SET {$einfo['stat']} = '{$upd}' WHERE userid={$userid}");
 }
}

print "{$r['itmname']} used successfully!";
item_remove($userid, $r['inv_itemid'], 1);
}
}
if($r['itmname'] == 'Weed')
{
mysql_query("UPDATE users SET brave=brave+10 WHERE userid=$userid",$c);
}
print "You roll a fat blunt full of {$r['itmname']} and start to hit it. You feel a bit more focused.";
$h->endpage();
?>

here is my entire itemuse.php

Posted

Place your code above the last } so like this and give it a try....

item_remove($userid, $r['inv_itemid'], 1);

}

if($r['itmname'] == 'Weed')

{

mysql_query("UPDATE users SET brave=brave+10 WHERE userid=$userid",$c);

print "You roll a fat blunt full of {$r['itmname']} and start to hit it. You feel a bit more focused.";

}

}

$h->endpage();

Posted

it is send to call to the db as it updated my braave but did not make it go above the maxbrave i had 5/9 it updated to 9/9 but i should of had 14/9

Posted
it is send to call to the db as it updated my braave but did not make it go above the maxbrave i had 5/9 it updated to 9/9 but i should of had 14/9

Like I said, the brave is being set automatically to the maxbrave

$query2="UPDATE users SET brave=maxbrave This changes the brave to the same as the max brave WHERE brave>maxbrave but only when the brave exceeds the max brave like what you said";

Like in that code, you can see that the brave is being set to the maxbrave by the code I bolded (the red tells you what it is doing)

Posted

That would make the WHERE statement useless.

You could shorten it to

mysql_query(UPDATE users SET brave = brave + 10);

I don't know if that is correct syntax since I have only worked with C# in the last 3/4 years (and not much of that lol)

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...