Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Specific item(array) removal

$
0
0
Hey Guys.
I've restarted pawno scripting just a couple of months ago after some years of brake. I'm using an inventory system by Ivan_Ino's ArrayList method (http://forum.sa-mp.com/showthread.php?t=608635).
How can I get and remove one specific item from the inventory? I'm thinking about making a stock with this function, I just can't find the proper way to do it.
The thing would be that if someone's in a mission, has the proper item in his inventory, in a proper distance from the NPC (actor), and presses the proper key, he would give the item to the NPC (just lose it from the inventory). I know how to solve these things, my only problem is the specific item removal

I've figured it out that I will need to make the player "in a mission", so i've created

Code:

new inmission[MAX_PLAYERS];
To make sure about the proper item removal at the proper case, i've also created

Code:

new inmission_lunchbreak[MAX_PLAYERS];
Letting known that the player has the specific item I've created

Code:

new hassandwich[MAX_PLAYERS]; // and a couple of more for ex.: haschips, hasmap etc.
It would look like this:

Code:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys && KEY_SECONDARY_ATTACK) //pressing either "F" or "ENTER"
    {
        if(IsPlayerInRangeOfPoint(playerid, "distance", "x", "y", "z"))
        {
            if(inmission[playerid] == 1)
            {
                if(inmission_lunchbreak[playerid] == 1)
                {
                    //couple of things happening
                    RemoveSpecificItemFromInventory(playerid, ?) // <-- not "slot" like the original removal function, but either item_name or idk ?
                }
            }
        }
    }
    return 1;
}

Can you help me with this one?

EDIT:

RemoveSpecificItemFromInventory(playerid, ?) //<--- the '?' should refer to the item id or what?

Code:

new ItemArray[][]=
{
    {1, "Sandwich"}
    // couple more like {id, "name"}
};


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>