Inventory slots.
#1

Hi all,

I have a problem with my inventory system.
I want to make if someone destroys/sold his clothes that the slot where the clothes was into get pushed back.
Example:
I have used 3 slots with 3 different items.
pawn Код:
slot 1|itemid 10
slot 2|itemid 20
slot 3|itemid 30
When i remove one item by removing slot 2 it needs to be like this:
pawn Код:
slot 1|itemid 10
slot 2|itemid 30// the old slot :slot 3|itemid 30
But it looks like:
pawn Код:
slot 1|itemid 10
slot 3|itemid 30//slot 3 should be 2
So what it should do is to decrease all slots by 1 that higher is then the slot that gets removed.

My Code:
pawn Код:
//the items are added with this code
ClothesItems[playerid][1]=10;
ClothesItems[playerid][2]=20;
ClothesItems[playerid][3]=30;

//using this test command to show the used slots with clothesids
if(!strcmp(cmdtext, "/testclothes", true))
{  
    for(new i = 1; i < MAX_SLOTS; i++)
    {
        if(ClothesItems[playerid][i]!=0)
        {
            format( string, sizeof string, "slot %d|item id %d",i,ClothesItems[playerid][i]);
            SendClientMessage( playerid, -1, string );
        }
    }
    return 1;
}
//using this command to remove slot 2
dcmd_removeclothes(playerid,params[])
{
    new slotid;
    if(sscanf(params, "d", slotid))
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /removeclothes [slotid]");
        return 1;
    }
    if(IsSlotUsed(playerid,slotid)==0)
    {
        SendClientMessage(playerid,COLOR_RED,"You dont have any clothes in this slot");
        return 1;
    }
    format(globalstring,sizeof(globalstring),"You have removed slot:%d",slotid);
    SendClientMessage(playerid,-1,globalstring);
    RemoveClothes(playerid,slotid);
    return 1;

}

stock RemoveClothes(playerid,slotid)
{
    HasClothes[playerid]--;
    ClothesItems[playerid][slotid]=0;
    return 1;
}
Can someone correct my code?

Admigo
Reply


Messages In This Thread
Inventory slots. - by Admigo - 21.07.2013, 09:36
Re: Inventory slots. - by Misiur - 21.07.2013, 09:57
Re: Inventory slots. - by Admigo - 21.07.2013, 10:12
Re: Inventory slots. - by Misiur - 21.07.2013, 10:27
Re: Inventory slots. - by Admigo - 21.07.2013, 10:40
Re: Inventory slots. - by Misiur - 21.07.2013, 10:51
Re: Inventory slots. - by Admigo - 21.07.2013, 10:58
Re: Inventory slots. - by Misiur - 21.07.2013, 11:01
Re: Inventory slots. - by Admigo - 21.07.2013, 11:10
Re: Inventory slots. - by Misiur - 21.07.2013, 11:44

Forum Jump:


Users browsing this thread: 3 Guest(s)