What's the best way to do this?
#4

Hold on I added this, try it:

pawn Код:
#define MAX_INVENTORY_SLOTS 20

enum pInventory
{
    pID,
    pSlot[20],
    pName[128]
}
new PlayerInventory[MAX_PLAYERS][pInventory];

CMD:i(playerid, params[])
{
    new item;
    if(strcmp(params[0], "use"){
        if(sscanf(params[1],"i", item)) return SendClientMessage(playerid, SERVER_USAGE, "Correct Usage: /i use [Inventory Item]");
            if(pInfo[playerid][pJob] = 12) // Made Up Number, Should Represent The Job ID //
            {
                // Use a function that will get all inventory and check if the id in "item" is in it
                if(CheckItemInInventory(playerid, item)) // If returns true
                {
                    // Do Action or Give Player Weapon or what ever you wanna do with it
                }
                else
                {
                    SendClientMessage(playerid, COLOR_ORANGE, "You do not have this item!");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_ORANGE, "You need to be a Car Jacker / Mechanic");
            }
        }
    }
    return 1;
}

stock CheckItemInInventory(playerid, item)
{
    for(new x=0;x<MAX_INVENTORY_SLOTS;x++)
    {
        if((PlayerInventory[playerid][pSlot][x]) == item) return true;
    }
    return 0;
}
Tell me if this works or not, and if you need help ask me.
Reply


Messages In This Thread
What's the best way to do this? - by VerticalGaming - 08.04.2014, 15:25
Re: What's the best way to do this? - by azzerking - 08.04.2014, 17:13
Re: What's the best way to do this? - by VerticalGaming - 08.04.2014, 17:18
Re: What's the best way to do this? - by azzerking - 08.04.2014, 17:25
Re: What's the best way to do this? - by VerticalGaming - 08.04.2014, 17:28

Forum Jump:


Users browsing this thread: 1 Guest(s)