lucky3809 Posted February 9, 2011 Posted February 9, 2011 Ok I was making a mod and was posting it on here for free but cant get the unequip page to work. This is the coding part I've added only the top works when weapon has decrease stats the else part below for increased stats is not working at all: if($r['effect1_on']) { $einfo=unserialize($r['effect1']); if($einfo['dir']=="neg") { if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $stats=$einfo['stat']; $upd=$einfo['inc_amount']; $db->query("UPDATE `userstats` SET $stats=$stats+$upd WHERE userid=$userid"); } } else { $stats=$einfo['stat']; $upd=$einfo['inc_amount']; $db->query("UPDATE `userstats` SET $stats=$stats-$upd WHERE userid=$userid"); } } Do I have one of these "}" out of place or what is making it not function the end part after else? I appreciate any help I can get :) Quote
rulerofzu Posted February 9, 2011 Posted February 9, 2011 Would have been easier to help if you had left the code up in your free mod post. Cannot remember what it is your trying to achieve. Was it if you have a item equipped then it increases the stats? Then decreases when unequipped? Quote
lucky3809 Posted February 10, 2011 Author Posted February 10, 2011 I had 3 pages equip_weapon,armour,and unequip that used the same very code, problem was when I went into staff_item and increased and decreased it had only worked while equipping the weapon and armor, but when I had unequipped them it would only add back the decrease amount of stats and not take back the increase stats... I've tried everything but seems like it's only allowing the decrease stat option to work and not the increase... For instance I set a weapon at 22 strength and have it increase the other strength stat that already been trained, I unequipped the weapon it's suppose to take the 22 back off the already trained stat which is not working, but when I decrease it 22 and unequipped the weapon it adds 22 like it suppose to back on the trained stats already. The problem is it is not taking the increase off the already train stat when the weapon has been unequipped. Quote
lucky3809 Posted February 10, 2011 Author Posted February 10, 2011 This is the equip page that works while equipping both increase and decrease stat option.... <?php include "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $id=$db->query("SELECT iv.*,it.* FROM inventory iv LEFT JOIN items 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) { print "Invalid item ID"; $h->endpage(); exit; } else { $r=$db->fetch_row($id); } if(!$r['weapon']) { print "This item cannot be equipped to this slot."; $h->endpage(); exit; } if($_GET['type']) { if(!in_array($_GET['type'], array("equip_primary", "equip_secondary"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if($r['effect1_on']) { $einfo=unserialize($r['effect1']); if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $stats=$einfo['stat']; $upd=$einfo['inc_amount']; $db->query("UPDATE `userstats` SET $stats=$stats-$upd WHERE userid=$userid"); } else { if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $stats=$einfo['stat']; $upd=$einfo['inc_amount']; $db->query("UPDATE `userstats` SET $stats=$stats+$upd WHERE userid=$userid"); } } } if($ir[$_GET['type']]) { item_add($userid, $ir[$_GET['type']], 1); } item_remove($userid, $r['itmid'], 1); $db->query("UPDATE users SET {$_GET['type']} = {$r['itmid']} WHERE userid={$userid}"); print "Item {$r['itmname']} equipped successfully."; } else { print "<h3>Equip Weapon</h3><hr /> <form action='equip_weapon.php' method='get'> <input type='hidden' name='ID' value='{$_GET['ID']}' /> Please choose the slot to equip {$r['itmname']} to, if there is already a weapon in that slot, it will be removed back to your inventory. <input type='radio' name='type' value='equip_primary' checked='checked' /> Primary <input type='radio' name='type' value='equip_secondary' /> Secondary <input type='submit' value='Equip Weapon' /></form>"; } $h->endpage(); ?> This is the unequip page that only works when you unequipped decrease stat option which it suppose to work with the increase option also. I've added the top query under globals also I doubt that is the problem I'm having... <?php include "globals.php"; $q=$db->query("SELECT * FROM items WHERE itmid IN({$ir['equip_primary']}, {$ir['equip_secondary']}, {$ir['equip_armor']})"); $r=$db->fetch_row($q); if(!in_array($_GET['type'], array("equip_primary", "equip_secondary", "equip_armor"))) { print "This slot ID is not valid."; $h->endpage(); exit; } if(!$ir[$_GET['type']]) { print "You do not have anything equipped in this slot."; $h->endpage(); exit; } if($r['effect1_on']) { $einfo=unserialize($r['effect1']); if($einfo['dir']=="neg") { if(in_array($einfo['stat'], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $stats=$einfo['stat']; $upd=$einfo['inc_amount']; $db->query("UPDATE `userstats` SET $stats=$stats+$upd WHERE userid=$userid"); } } else { if(in_array($ir[$einfo['stat']], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $einfo=unserialize($r['effect1']); $stats=$ir[$einfo['stat']]; $upd=$ir[$einfo['inc_amount']]; $db->query("UPDATE `userstats` SET $stats=$stats-$upd WHERE userid=$userid"); } } } item_add($userid, $ir[$_GET['type']], 1); $db->query("UPDATE users SET {$_GET['type']}=0 WHERE userid={$ir['userid']}"); $names=array( "equip_primary" => "Primary Weapon", "equip_secondary" => "Secondary Weapon", "equip_armor" => "Armor", ); print "The item in your {$names[$_GET['type']]} slot was successfully unequiped."; $h->endpage(); ?> Quote
rulerofzu Posted February 10, 2011 Posted February 10, 2011 Well.....if im reading your post correctly.... if(in_array($ir[$einfo['stat']], array('strength', 'agility', 'guard', 'labour', 'IQ'))) { $einfo=unserialize($r['effect1']); $stats=$ir[$einfo['stat']]; $upd=$ir[$einfo['inc_amount']]; $db->query("UPDATE `userstats` SET $stats=$stats-$upd WHERE userid=$userid"); } } } Is the area not working. I have no way to test it (cant be bothered to install mc2 default) but what strikes me is that your $einfo=unserialize($r['effect1']); when you have already done so earlier in the code if($r['effect1_on']) { $einfo=unserialize($r['effect1']); Quote
lucky3809 Posted February 10, 2011 Author Posted February 10, 2011 Thanks for the advice I figured it out its actually NOT possible to do what I was talking about, it either has to be coded for increase or just decrease alone I figured out the solution and posted it under the free mod area. You would need to add one effect for decrease and another effect for increase for it to even work... If I wanted a increase of strength I would use effect 1 and if I wanted it decrease I would use effect2 for it to properly work when unequipping the weapon.... 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.