Samurai Legend Posted June 23, 2016 Posted June 23, 2016 So my fields are on another table which is called `user_rangers`. When users use a dexterity potions I want their dexterity which is `urDEXTERITY` in `user_rangers` to do whatever I set it as in the staff panel. In the `items` table the the `effect1` is: a:4:{s:4:"stat?;s:11:?urDEXTERITY";s:3:"dir";s:3:"pos";s:8:"inc_type";s:7:"percent";s:10:"inc_amount";i:100;} <?php define('PAGE_HEADER', 'Use Item'); require('globals.php'); $_GET['ID'] = (isset($_GET['ID']) && is_numeric($_GET['ID'])) ? abs(intval($_GET['ID'])) : ''; $_POST['qty'] = (isset($_POST['qty']) && is_numeric($_POST['qty'])) ? abs(intval($_POST['qty'])) : ''; $tresder = rand(99, 999); if (!empty($_POST['qty']) && !empty($_GET['ID'])) { $id = $db->query( "SELECT `effect1`, `effect2`, `effect3`, `effect1_on`, `effect2_on`, `effect3_on`, `inv_qty`, `itmname`, `inv_itemid`, `itmtype` FROM `inventory` AS `iv` INNER JOIN `items` AS `i` ON `iv`.`inv_itemid` = `i`.`itmid` WHERE `iv`.`inv_id` = {$_GET['ID']} AND `iv`.`inv_userid` = $userid"); if ($db->num_rows($id) == 0) { error('Invalid item ID'); } else { $r = $db->fetch_row($id); if($r['itmname'] == 'Crew Exploder') { if($ir['hospital'] > 0 || $ir['prison'] > 0) { error("This page cannot be accessed while in prison or hospital."); } echo "<h3><u>Crew Exploder</u></h3><hr width=75%> Crew Exploder Instructions:<br /> Enter the ID of a member of the Crew that you wish to use the Crew Exploder on.<br /><br /> Further Information:<br /><br /> 1) 10 - 40 minutes hospital time.<br /> 2) Crew exploders can only be used on members not in hospital or prison.<br /> 3) Hospital time is only issued to members not already in hospital or prison.<br /> 4) Crew exploders can only be used on members of a crew that you are in war with.<br /> 5) Respect is gained at a rate of 3 respect per member hospitalised.<br /> </br> <form action='crew_exploder.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> <input type='hidden' name='tresde' value='$tresder' /> User ID: <input type='text' name='userid' value='' /><br /></br> <input type='submit' value='Initiate' /></form> <hr width = '75%'><a href = 'index.php'>>Go Back</a><hr width = '75%'>"; exit($h->endpage()); } if ($_POST['qty'] > $r['inv_qty']) { error('You are trying to use more than you have!'); } else { if (!$r['effect1_on'] && !$r['effect2_on'] && !$r['effect3_on']) { error('Sorry, this item cannot be used as it has no effect.'); } for ($enum = 1; $enum <= 3; $enum++) { if ($r["effect{$enum}_on"]) { $einfo = unserialize($r["effect{$enum}"]); if ($einfo['inc_type'] == "percent") { if (in_array($einfo['stat'], array('energy', 'mood', 'courage', 'hp'))) { $inc = round( $ir['max' . $einfo['stat']] / 100 * $einfo['inc_amount']) * $_POST['qty']; } else { $inc = round( $ir[$einfo['stat']] / 100 * $einfo['inc_amount']) * $_POST['qty']; } } else { $inc = $einfo['inc_amount'] * $_POST['qty']; } if ($einfo['dir'] == "pos") { if (in_array($einfo['stat'], array('energy', 'mood', 'courage', '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 if (in_array($einfo['stat'], array('urDEXTERITY'))) { $db->query( "UPDATE `user_rangers` SET `{$einfo['stat']}` = '{$upd}' WHERE `userid` = {$userid}"); } else { $db->query( "UPDATE `users` SET `{$einfo['stat']}` = '{$upd}' WHERE `userid` = {$userid}"); } } } $qty = $r['inv_qty'] - $_POST['qty']; item_remove($userid, $r['inv_itemid'], $_POST['qty']); confirmation("<font colot='yellow'>x{$_POST['qty']}</font> {$r['itmname']} used successfully!<br/>You have <font color='yellow'>x{$qty}</font> {$r['itmname']} remaining."); } } } else if (!empty($_GET['ID']) && empty($_POST['qty'])) { $id = $db->query( "SELECT `itmid`, `inv_qty`, `itmname`, `itmtype` FROM `inventory` AS `iv` INNER JOIN `items` AS `it` ON `iv`.`inv_itemid` = `it`.`itmid` WHERE `iv`.`inv_id` = {$_GET['ID']} AND `iv`.`inv_userid` = {$userid} LIMIT 1"); if ($db->num_rows($id) == 0) { error('Invalid item ID'); } else { $itemid = abs((int) $_GET['ID'])+0; $r = $db->fetch_row($id); /*if($r['itmid'] == 7){ echo "<h3><u>Item Use</u></h3> <hr/><b>Enter how many {$r['itmname']} you want to use. You have {$r['inv_qty']} to use.</b> <hr/> <form action='itemuse.php?ID={$_GET['ID']}' method='post'> <input type='hidden' name='verf' /> Quantity: <input type='text' name='qty' value='' /> <br /> <input type='submit' value='Use Items (no prompt so be sure!)' /> </form><hr/><a href = 'index.php'>>Go Back</a><hr/> "; } else*/ if($r['itmtype'] == 1){ echo "<h3><u>Item Use</u></h3><hr width = '75%'><table width='75%' class='table' border='0' cellspacing='1' cellpadding='1'> <tr><th colspan = '3'>Multi Use</th></tr> <tr> <th>Item</th> <th>Qty</th> <th>Use</th> </tr> <tr> <th>{$r['itmname']}</th> <td><font color='yellow'>x{$r['inv_qty']}</font></td> <form action='itemuse.php?ID={$_GET['ID']}' method='post'> <input type='hidden' name='verf' /> <td><input type='text' name='qty' value='' /></td> </tr> <tr><th colspan='3'><input type='submit' value='Use Item' /></th></tr> </form></table><hr width = '75%'> "; } else { echo "<h3><u>Item Use</u></h3> <hr/><b>Are you sure you want to use one ".$r['itmname']."?</b> <hr/> <form action='itemuse.php?ID={$_GET['ID']}' method='post'> <input type='hidden' name='verf' /> <input type='hidden' name='qty' value='1' /> <br /> <input type='submit' value='Use Item' /> </form><hr/><a href = 'index.php'>>Go Back</a><hr/> "; } } $db->free_result($id); } else { error('Invalid use of file.'); } $h->endpage(); I can't seem to get it to work. Quote
TheMasterGeneral Posted June 23, 2016 Posted June 23, 2016 What have you attempted to diagnose this? Quote
Samurai Legend Posted June 23, 2016 Author Posted June 23, 2016 I attempted to to copy how the ones in the user field coding is to make it update the user_rangers table however, I came across many errors Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.