View Single Post
Old 29/05/2020, 12:08 PM   #1
Nexotronix
Huge Clucker
 
Nexotronix's Avatar
 
Join Date: Jan 2010
Location: Donetsk/Ukraine
Posts: 275
Reputation: 41
Thumbs up [Solved] What's wrong with the loop? [Solution at 3rd MSG]

Hello there!

I started to make inventory system for free use, and want to make some kind like a "AutoFreeSlotFinder"

to put Item automaticly to nearest avaible slot using loops.

So, what's wrong here?

Code:

pawn Code:
stock AddItemToInventory(playerid,itemid)
{
    for( new SlotID = 0; SlotID < MAX_ITEM_SLOTS; SlotID++)
    {
        if(SlotInfo[playerid][SlotID][slotUsed] == 0)
        {
            PutItemToInv(playerid,itemid,SlotID);
        }
        else if(SlotInfo[playerid][SlotID][slotUsed] == 1 && SlotInfo[playerid][SlotID][slotItemType] == ItemInfo[itemid][ITEM_TYPE])
        {
            if(SlotInfo[playerid][SlotID][slotItemAmount] < ItemInfo[itemid][ITEM_MAX_VALUE])
            {
                PlusItemToInv(playerid,itemid,SlotID);
            }
            else
            {
                return 0;
            }
        }
        else if(SlotInfo[playerid][SlotID][slotUsed] == 1)
        {
            UpdateInventory(playerid);
        }
        else
        {
            return 0;
        }
    }
    return 1;
}

Function Effects are can be seen at the screenshots:
Attached Images
File Type: jpg sa-mp-000.jpg (193.1 KB, 15 views)
File Type: jpg Снимок.JPG (60.4 KB, 13 views)
__________________
Work In Progress:
[GameMode]Stroberia RolePlay (20%) [Join My Channel to take part in Testing http://discord.gg/sBpRC5E]
Development Video: Watch Here
Serverside Map/GPS System: Watch Here
Discord: Tom_Strobe#2300

Last edited by Nexotronix; 29/05/2020 at 01:18 PM. Reason: Solved!
Nexotronix is offline   Reply With Quote