21.07.2013, 09:36
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.
When i remove one item by removing slot 2 it needs to be like this:
But it looks like:
So what it should do is to decrease all slots by 1 that higher is then the slot that gets removed.
My Code:
Can someone correct my code?
Admigo
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
pawn Код:
slot 1|itemid 10
slot 2|itemid 30// the old slot :slot 3|itemid 30
pawn Код:
slot 1|itemid 10
slot 3|itemid 30//slot 3 should be 2
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;
}
Admigo