30.04.2016, 21:11
Hello,
My friend and I have been brainstorming why this loop won't break at the first invalid slot (meaning empty slot, which is what we need).
This is the code:
The i4 (which is above the break shows up and it loops throught ALL MAX_PLAYER_ATTACHED_OBJECTS, even tho i: 0 shows up too, meaning 0 is empty.
The loop simply won't break after the first empty slot.
My friend and I have been brainstorming why this loop won't break at the first invalid slot (meaning empty slot, which is what we need).
This is the code:
pawn Код:
case DIALOG_CLOTHES_LIST:
{
if(response)
{
if(Player[playerid][Clothing_Menu] == C_BUY){
new Found = 0;
for(new i = 0; i < MAX_PLAYER_ATTACHED_OBJECTS; i++){
if(PClothing[playerid][i][pC_Valid] == 0){
fSendClientMessage(playerid, -1, "i: %d", i);
Found++;
new count;
for(new item; item < sizeof(ClothingObjects); item++)
{
if(ClothingObjects[item][cType] != Player[playerid][Clothing_Type]) continue;
if (count == listitem)
{
fSendClientMessage(playerid, -1, "i2: %d", i);
PClothing[playerid][i][pC_ID] = ClothingObjects[item][cObjID];
format(PClothing[playerid][i][pC_Name], 50, "%s", ClothingObjects[item][cObjectName]);
PClothing[playerid][i][pC_OffsetX] = ClothingObjects[item][cOX];
PClothing[playerid][i][pC_OffsetY] = ClothingObjects[item][cOY];
PClothing[playerid][i][pC_OffsetZ] = ClothingObjects[item][cOZ];
PClothing[playerid][i][pC_RotX] = ClothingObjects[item][cRX];
PClothing[playerid][i][pC_RotY] = ClothingObjects[item][cRY];
PClothing[playerid][i][pC_RotZ] = ClothingObjects[item][cRZ];
PClothing[playerid][i][pC_ScaleX] = 1;
PClothing[playerid][i][pC_ScaleY] = 1;
PClothing[playerid][i][pC_ScaleZ] = 1;
PClothing[playerid][i][pC_Bone] = ClothingObjects[item][cBone];
fSendClientMessage(playerid, -1, "i3: %d", i);
if(IsPlayerAttachedObjectSlotUsed(playerid, 0)) RemovePlayerAttachedObject(playerid, 0);
SetPlayerAttachedObject(playerid, 0, PClothing[playerid][i][pC_ID], ClothingObjects[item][cBone], PClothing[playerid][i][pC_OffsetX], PClothing[playerid][i][pC_OffsetY], PClothing[playerid][i][pC_OffsetZ], PClothing[playerid][i][pC_RotX], PClothing[playerid][i][pC_RotY], PClothing[playerid][i][pC_RotZ], PClothing[playerid][i][pC_ScaleX], PClothing[playerid][i][pC_ScaleY], PClothing[playerid][i][pC_ScaleZ]);
EditAttachedObject(playerid, 0);
CallRemoteFunction("StartClothing","i",playerid);
Player[playerid][Clothing_Buy] = i+1;
fSendClientMessage(playerid, -1, "i4: %d", i);
break;
}
count++;
}
}
}
if(Found == 0){
SCM(playerid, RED, "> You have 5 Clothing objects already!");
}
The loop simply won't break after the first empty slot.