Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix backpack #624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 37 additions & 32 deletions gamemodes/sss/core/itemtype/backpack.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ stock AddItemToPlayer(playerid, Item:itemid, useinventory = false, playeraction
new required;

if(useinventory)
{
required = AddItemToInventory(playerid, itemid);

if(required == 0)
return 0;
if(required == 0)
return 0;
}

if(!IsValidItem(bag_PlayerBagID[playerid]))
{
Expand Down Expand Up @@ -451,10 +453,6 @@ _BagEquipHandler(playerid)

return 0;
}
else
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

{
AddItemToPlayer(playerid, itemid, true);
}

return 1;
}
Expand Down Expand Up @@ -608,6 +606,8 @@ hook OnPlayerAddToInventory(playerid, Item:itemid, success)
GetInventoryFreeSlots(playerid, freeslots);

ShowActionText(playerid, sprintf(ls(playerid, "CNTEXTRASLO", true), itemsize - freeslots), 3000, 150);

AddItemToPlayer(playerid, itemid);
}

return Y_HOOKS_CONTINUE_RETURN_0;
Expand Down Expand Up @@ -697,46 +697,51 @@ hook OnPlayerSelectInvOpt(playerid, option)

hook OnPlayerViewCntOpt(playerid, Container:containerid)
{
new Container:bagcontainerid;
GetItemArrayDataAtCell(bag_PlayerBagID[playerid], _:bagcontainerid, 1);
if(IsValidItem(bag_PlayerBagID[playerid]) && containerid != bagcontainerid)
if(IsValidItem(bag_PlayerBagID[playerid]))
{
bag_InventoryOptionID[playerid] = AddContainerOption(playerid, "Move to bag");
new Container:bagcontainerid;
GetItemArrayDataAtCell(bag_PlayerBagID[playerid], _:bagcontainerid, 1);
if(containerid != bagcontainerid)
{
bag_InventoryOptionID[playerid] = AddContainerOption(playerid, "Move to bag");
}
}
}

hook OnPlayerSelectCntOpt(playerid, Container:containerid, option)
{
new Container:bagcontainerid;
GetItemArrayDataAtCell(bag_PlayerBagID[playerid], _:bagcontainerid, 1);
if(IsValidItem(bag_PlayerBagID[playerid]) && containerid != bagcontainerid)
if(IsValidItem(bag_PlayerBagID[playerid]))
{
if(option == bag_InventoryOptionID[playerid])
new Container:bagcontainerid;
GetItemArrayDataAtCell(bag_PlayerBagID[playerid], _:bagcontainerid, 1);
if(containerid != bagcontainerid)
{
new
slot,
Item:itemid;
if(option == bag_InventoryOptionID[playerid])
{
new
slot,
Item:itemid;

GetPlayerContainerSlot(playerid, slot);
GetContainerSlotItem(containerid, slot, itemid);
GetPlayerContainerSlot(playerid, slot);
GetContainerSlotItem(containerid, slot, itemid);

if(!IsValidItem(itemid))
{
DisplayContainerInventory(playerid, containerid);
return Y_HOOKS_CONTINUE_RETURN_0;
}
if(!IsValidItem(itemid))
{
DisplayContainerInventory(playerid, containerid);
return Y_HOOKS_CONTINUE_RETURN_0;
}

new required = AddItemToContainer(bagcontainerid, itemid, playerid);
new required = AddItemToContainer(bagcontainerid, itemid, playerid);

if(required > 0)
ShowActionText(playerid, sprintf(ls(playerid, "BAGEXTRASLO", true), required), 3000, 150);
else
RemoveItemFromContainer(containerid, slot, playerid);

DisplayContainerInventory(playerid, containerid);
if(required > 0)
ShowActionText(playerid, sprintf(ls(playerid, "BAGEXTRASLO", true), required), 3000, 150);
else
RemoveItemFromContainer(containerid, slot, playerid);

DisplayContainerInventory(playerid, containerid);
}
}
}

return Y_HOOKS_CONTINUE_RETURN_0;
}

Expand Down