Magictallguy Posted October 30, 2013 Share Posted October 30, 2013 PHP 5.6 compliant Yes, I know this has been done, but I was requested to create another one here by Bennyh789 I've tested this extensively, so far, everything works. Any bugs, post here and I'll fix 🙂 SQLs You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit yourgang.php Find: The main query that populates the $gangdata variable (default: line 6) You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: The closing brace of gang_index() Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. c Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: The anchors in the gang_staff_idx() Add into the non-presidential part: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Still in the anchors of the gang_staff_idx(), Add into the presidential part: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: The closing brace of the gang_staff_idx() Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit global_func.php At the very end, add: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit imadd.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit itembuy.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit itemsell.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit itemsend.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit global_func.php Find: The entire item_add() function Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Find: The entire item_remove() function Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit equip_weapon.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit equip_armor.php *Note: The edits to the equip_armor.php are exactly the same as the equip_weapon.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit unequip.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Replace with You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Edit cron_day.php Find: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Add below: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Oh, and before I forget! Here's the CSS You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. 1 Quote Link to comment Share on other sites More sharing options...
Djkanna Posted October 30, 2013 Share Posted October 30, 2013 What about edits to the equipping/unequipping to compensate for loaned items? Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted October 30, 2013 Author Share Posted October 30, 2013 What about edits to the equipping/unequipping to compensate for loaned items? I'm tired, clarify? 1 Quote Link to comment Share on other sites More sharing options...
Djkanna Posted October 31, 2013 Share Posted October 31, 2013 (edited) When items are equipped and unequiped they are removed and added respectively into the inventory table ( or at least the last time I looked they were ). So when a user equips and then unequips an item they don't have multiples of, that item is now not a loaned item, regardless of if it was or wasn't before. The result, you end up with duplicate items, due to the fact a gang can still recall an item, and the checks in place there only check if a user has an item by id, and is in that gang. ( the item_remove, has no influence over whether or not you give an item back to a gang, so if that fails it doesn't matter, the gang still gets the item back, result: A gang has lost nothing a gang member gained a free item ). Do this a few times, loan out an item, equip it, unequip it, recall the item, donate the item to gang, would result in a nice little exploit that gives the gang free items. Another problem would be, item_add() it automatically increments the qty field of the users inventory, so if they have a borrowed item, and then get the same item from a different source, both items will now be classed as 'borrowed', but if the original is reclaimed there is no way for that item to return to it's rightful status, so a user will be stuck with a borrowed item that nothing can be done with except forced removal/editing of an admin or staff member. Disclaimer: If the equip/unequip no longer works this way, then this may not actually matter however you should probably still check that the item they're trying to get back is actually borrowed and not just owned. - My bad, you check your own table which tracks the user/loaned item, so maybe actually check they have this item also rather than just call item_remove, as like I say, all it needs to be is equipped for it to no longer be in a users inventory, but the checks you have in place will still allow the gang to process the reclaim, which means the above exploit just got a whole lot easier. TL;DR: If a loaned item is equipped it is removed from the inventory and it's ID is stored in the users table, you should probably track the item's borrowed status in this instance too. Edited October 31, 2013 by Djkanna Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted October 31, 2013 Author Share Posted October 31, 2013 When items are equipped and unequiped they are removed and added respectively into the inventory table ( or at least the last time I looked they were ). So when a user equips and then unequips an item they don't have multiples of, that item is now not a loaned item, regardless of if it was or wasn't before. The result, you end up with duplicate items, due to the fact a gang can still recall an item, and the checks in place there only check if a user has an item by id, and is in that gang. ( the item_remove, has no influence over whether or not you give an item back to a gang, so if that fails it doesn't matter, the gang still gets the item back, result: A gang has lost nothing a gang member gained a free item ). Do this a few times, loan out an item, equip it, unequip it, recall the item, donate the item to gang, would result in a nice little exploit that gives the gang free items. Another problem would be, item_add() it automatically increments the qty field of the users inventory, so if they have a borrowed item, and then get the same item from a different source, both items will now be classed as 'borrowed', but if the original is reclaimed there is no way for that item to return to it's rightful status, so a user will be stuck with a borrowed item that nothing can be done with except forced removal/editing of an admin or staff member. Disclaimer: If the equip/unequip no longer works this way, then this may not actually matter however you should probably still check that the item they're trying to get back is actually borrowed and not just owned. - My bad, you check your own table which tracks the user/loaned item, so maybe actually check they have this item also rather than just call item_remove, as like I say, all it needs to be is equipped for it to no longer be in a users inventory, but the checks you have in place will still allow the gang to process the reclaim, which means the above exploit just got a whole lot easier. TL;DR: If a loaned item is equipped it is removed from the inventory and it's ID is stored in the users table, you should probably track the item's borrowed status in this instance too. View the handling for the gang_armoury_loans, that tracks the loaned items no matter what. The user can only have one of any item they borrow, and they can't buy/be sent any more. I'll add in some form of check for equipment Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted October 31, 2013 Share Posted October 31, 2013 As soon as that's been sorted MTG I will get it uploaded ASAP Quote Link to comment Share on other sites More sharing options...
Djkanna Posted October 31, 2013 Share Posted October 31, 2013 View the handling for the gang_armoury_loans, that tracks the loaned items no matter what. The user can only have one of any item they borrow, and they can't buy/be sent any more. I'll add in some form of check for equipment It doesn't track the item itself. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. The rest is fine, however with the equip/unequip it will not do much to help, as like I said the borrowed status would be "No" once an item becomes equipped. If you do add checks to equipped items, make sure to check them for when gaining a new item, as like I said the item isn't in a users inventory, so when a user gains the same item, if you add something to keep track of borrowed status when an item is unequipped, that item will then increment with the other acquired item and both will be set as 'borrowed', which as said above could be an issue. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted October 31, 2013 Author Share Posted October 31, 2013 It doesn't track the item itself. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. The rest is fine, however with the equip/unequip it will not do much to help, as like I said the borrowed status would be "No" once an item becomes equipped. If you do add checks to equipped items, make sure to check them for when gaining a new item, as like I said the item isn't in a users inventory, so when a user gains the same item, if you add something to keep track of borrowed status when an item is unequipped, that item will then increment with the other acquired item and both will be set as 'borrowed', which as said above could be an issue. Understood, I'll add in the checks shortly, just working on something at the moment Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 1, 2013 Author Share Posted November 1, 2013 Code updated, see OP Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 1, 2013 Author Share Posted November 1, 2013 Updated multiple times, tested and fully working :D Enjoy your new fully-fledged Gang Armoury! Quote Link to comment Share on other sites More sharing options...
Djkanna Posted November 2, 2013 Share Posted November 2, 2013 If I recall correctly, equip_* will also unequip a pre-existing item if there is one and add it back to the inventory, so you may want to add a check there to see if that item was a borrowed item and update the item_add and the borrowed status accordingly. Example: item 1 = borrowed; item 2 = not borrowed; Equip item 1 -> status = borrowed. equip item 2 -> item 1 returned as a borrowed item, item 2 equipped, status does not change, due to the item not being borrowed -> Status = borrowed. unequip.php, item 2 unequipped added to inventory as borrowed because of the lack of a status change. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 2, 2013 Author Share Posted November 2, 2013 If I recall correctly, equip_* will also unequip a pre-existing item if there is one and add it back to the inventory, so you may want to add a check there to see if that item was a borrowed item and update the item_add and the borrowed status accordingly. Example: item 1 = borrowed; item 2 = not borrowed; Equip item 1 -> status = borrowed. equip item 2 -> item 1 returned as a borrowed item, item 2 equipped, status does not change, due to the item not being borrowed -> Status = borrowed. unequip.php, item 2 unequipped added to inventory as borrowed because of the lack of a status change. Well spotted, I'll fix that in a moment Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 2, 2013 Author Share Posted November 2, 2013 Original post updated Quote Link to comment Share on other sites More sharing options...
Djkanna Posted November 3, 2013 Share Posted November 3, 2013 Original post updated :) Another thing before you get pissed at me, provide a dropbox or another file host mirror, because the syntax highlighter tends to screw up. ;) Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 3, 2013 Author Share Posted November 3, 2013 :) Another thing before you get pissed at me, provide a dropbox or another file host mirror, because the syntax highlighter tends to screw up. ;) Haha, 'tis not a problem. It's available on my site: http://magictallguy.tk/mods.php#armoury Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted November 3, 2013 Share Posted November 3, 2013 evening MTG, im trying to install this as we speak but ive hit a brick wall, when i try changing the item add function in global_func i get this error: Parse error: syntax error, unexpected T_STRING in /home/endoftim/public_html/global_func.php on line 429 line 429 is: $db->query("UPDATE `inventory` SET `inv_qty` = `inv_qty` + ".$qty.(($gangitem == 1) ? ', `inv_borrowed` = 'No'' : '')." WHERE `inv_id` = ".$r['inv_id']); the code around that line is: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Thanks Ben Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 4, 2013 Author Share Posted November 4, 2013 (edited) Code updated, small edits to the equip_armor/equip_weapon Also, Ben Change You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. To You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Blame the highlighter on here Original post updated Edited November 4, 2013 by Magictallguy Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted November 4, 2013 Share Posted November 4, 2013 (edited) Thanks MTG that's seemed to fix that problem However there's a couple of other things In the gang settings I changed it so users could not donate items to the armoury however it still lets them I then changed it so everything was 'yes' in settings and when you go to gang armoury it says that all of the items are locked when they shouldn't be Thanks Ben Edited November 4, 2013 by Bennyh789 Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 5, 2013 Author Share Posted November 5, 2013 Thanks MTG that's seemed to fix that problem However there's a couple of other things In the gang settings I changed it so users could not donate items to the armoury however it still lets them I then changed it so everything was 'yes' in settings and when you go to gang armoury it says that all of the items are locked when they shouldn't be Thanks Ben Whoops, looks like I left that in by mistake I switched that part directly around from how I originally had it (made more sense whilst writing it), I'll update the original code now Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted November 5, 2013 Share Posted November 5, 2013 Great thanks! Just a couple of general questions, if a gang has items loaned out and the gang gets destroyed/deleted will the items be removed from the users as well? Or are they stuck with them for eternity? Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 5, 2013 Author Share Posted November 5, 2013 Great thanks! Just a couple of general questions, if a gang has items loaned out and the gang gets destroyed/deleted will the items be removed from the users as well? Or are they stuck with them for eternity? Currently, they're stuck with them. I'll add in updates for the attack*.php and my gang_staff_delete() shortly :) Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted November 5, 2013 Share Posted November 5, 2013 Awesome thanks and one last question I promise can a function be put in so the leader can withdraw the items permanently as otherwise any weapons donated will have to stay in there forever Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted November 5, 2013 Author Share Posted November 5, 2013 Awesome thanks and one last question I promise [...] Haha, ask as many as you want :) [...] can a function be put in so the leader can withdraw the items permanently as otherwise any weapons donated will have to stay in there forever It can indeed. I'll make sure to include that with the other update :) Quote Link to comment Share on other sites More sharing options...
Bennyh789 Posted November 5, 2013 Share Posted November 5, 2013 Lovely thanks a bunch mate as soon as the update is done I promise I will buy you a beer! Quote Link to comment Share on other sites More sharing options...
dnenb Posted November 8, 2013 Share Posted November 8, 2013 (edited) Gonna buy you some beers once I get this installed as well :) A question: Is there something missing from yourgang.php that should fill $gangdata with info from the table gang_settings? Edited November 8, 2013 by dnenb Quote Link to comment Share on other sites More sharing options...
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.