SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong loop result. Rongvaldyr Scripting Help 2 12/02/2017 02:51 PM
Wrong loop result. Rongvaldyr Scripting Help 4 19/01/2017 04:39 AM
Wrong returns from a loop TwinkiDaBoss Scripting Help 2 20/11/2016 01:21 AM
What's wrong with this loop? Makaveli93 Scripting Help 2 22/06/2012 09:00 PM
What's wrong with this loop? Knappen Scripting Help 2 07/11/2011 03:51 PM


All times are GMT. The time now is 05:05 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.