Jump to content
MakeWebGames

Gang Armoury


Magictallguy

Recommended Posts

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.

 

  • Like 1
Link to comment
Share on other sites

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 by Djkanna
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Magictallguy
Link to comment
Share on other sites

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 by Bennyh789
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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