Detect all slots if they have the same value.
#1

Hello ,

I have a problem with detect all slots if they have the same value.
I have made a command that shows you a menu what items you can wear.
This menu is controlled by onplayertext with a number. Like [1]Red Phone [2]Blue Phone etc.
My problem is to detect if you already wearing the item.
My code:

pawn Код:
//Onplayerspawn Just for example
ClothesItems[playerid][1]=10;//i own item 10 in slot 1
ClothesItems[playerid][2]=20;//i own item 20 in slot 2
ClothesItems[playerid][3]=30;//i own item 30 in slot 3
ClothesItems[playerid][4]=40;
ClothesItems[playerid][5]=50;
ClothesItems[playerid][6]=60;
ClothesItems[playerid][7]=70;
ClothesItems[playerid][8]=80;
ClothesItems[playerid][9]=90;
ClothesItems[playerid][10]=100;

//OnPlayerText. It shows a menu with 10 items that you can wear.
//this is to wear the clothes and number is the number that you are typing.
for(new i=0; i < MAX_SLOTS; i++)
            {
                if(WearClothesItems[playerid][i]==ClothesItems[playerid][number])
                {
                    SendClientMessage(playerid,COLOR_RED,"You already wearing this clothes");
                    return 0;
                }
                else
                {
                    ClothesID[playerid]=ClothesItems[playerid][number];
                    GetClothesID(playerid);
                    SetPlayerAttachedObject(playerid, GetFreeClothesSlot[playerid], GetClothesID(playerid), GetClothesBoneID(playerid));
                    EditAttachedObject(playerid, GetFreeClothesSlot[playerid]);
                    WearClothesItems[playerid][GetFreeClothesSlot[playerid]] = ClothesItems[playerid][number];//This will store the item ids and on what attachmentslot the wearing it.
                    format(globalstring,sizeof(globalstring),"WearClothesItem[playerid][%d]=%d;",GetFreeClothesSlot[playerid],WearClothesItems[playerid][GetFreeClothesSlot[playerid]]);
                    SendClientMessage(playerid,-1,globalstring);
                    GetFreeClothesSlot[playerid]++;
                    return 0;
               
                }
            }
When i am wearing item 10 and 20 and when i am trying to wear item 20 again its not return the message.
Debug:
pawn Код:
WearClothesItem[playerid][0]=10;
WearClothesItem[playerid][1]=20;
//When i wear item 20 while i am already wearing it its skipping the error code and just wears it on the next slot
WearClothesItem[playerid][2]=20;
Can someone correct my code please?

Admigo
Reply


Messages In This Thread
Detect all slots if they have the same value. - by Admigo - 13.08.2013, 23:24
Re: Detect all slots if they have the same value. - by Jefff - 14.08.2013, 00:45
Re: Detect all slots if they have the same value. - by Admigo - 14.08.2013, 01:18

Forum Jump:


Users browsing this thread: 1 Guest(s)