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

Hello, SA-MP community.
I'm planning on making a inventory system, due textdraws.
My question is, how do I start?

I've made an inventory textdraw 2 days ago.
(Dont mind vehicle keys etc, just typed that to check the lenght of a textdraw string without getting out the borders).





I want to make a inventory system that works as this:
Player: /i use 15 (He will use Inventory slot 15, inventory slot 15 can be everything, a wirecutter, screwdriver etc)
Example
Slot 15 is a screwdriver, when typing /i use 15 he will equip the screwdriver, (will use it for car jacker & mechanic job ).
You can do /i move either, when typing /i move 15 16, it will move the item in slot 15 to slot 16.
.
Now, I've 120 items to be scripted.
So it would be usefull to create call backs & stocks for it.

But.. I dont have any idea how to start on it.
I would really appreciate it fi someone helps me out.

Kind regards, VerticalGaming.
Reply
#2

Try this:

pawn Код:
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, InventoryName, 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;
}
I am on my Tablet, so I haven't been able to test this or even know if it works, written it all in my head atm. At least try it and add your code to it to make it work.
Reply
#3

The commands are not a problem.
But I mean, how can I script 120 items etc, and making them flexible?
So they can be stored in EACH inventory slot etc.
Reply
#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
#5

Can you add me on skype? fabio.di.cola
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)