Weird behaviour of loops i guess
#1

Okay so im trying to get a command called /getcar to run. Now this is my code:
pawn Код:
Dialog_GetCarSelectHouse(playerid, response, listitem)
{
    // Just close the dialog if the player clicked "Cancel"
    if(!response) return 1;

    // Get the houseid based on the chosen listitem
    new HouseID = APlayerData[playerid][Houses][listitem], modelid;

    // Check if it was a valid house
    if (HouseID != 0)
    {
        // Setup local variables
        new VehicleList[500], bool:HouseHasCars = false, CarSlot;

        // Store the HouseID, otherwise the next dialog won't be able to get a car from the chosen house
        APlayerData[playerid][DialogGetCarHouseID] = HouseID;

        // Check if the house has any cars assigned to it
        for (CarSlot = 0; CarSlot < 20; CarSlot++)
            if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
                HouseHasCars = true;

        // Check if the house has any cars assigned to it
        if (HouseHasCars == true)
        {
            // Add all vehicles to the list
            for (CarSlot = 0; CarSlot < 20; CarSlot++)
            {
                // Check if the carslot has a vehicle in it
                if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
                {
                    modelid = GetVehicleModel(AHouseData[HouseID][VehicleIDs][CarSlot]);
                    format(VehicleList, 500, "%s{00FF00}%s\n", VehicleList, VehicleNames2[modelid-400]);
                }
                else
                    format(VehicleList, 500, "Empty car slot", VehicleList);
            }

            ShowPlayerDialog(playerid, DialogGetCarSelectCar, DIALOG_STYLE_LIST, "Select vehicle to port to your location:", VehicleList, "Select", "Cancel");
        }
        else
            SendClientMessage(playerid, 0xFFFFFFFF, "There are no vehicles assigned to this house!");
    }
    else
        SendClientMessage(playerid, 0xFFFFFFFF, "There is no house selected");

    return 1;
}
Now the problem is it only shows 1 thing in it while there are 2. Also it doesnt show the car name... Instead it shows Empty car slot. When i select that it gets my car teleported... Anyone sees something thats wrong?
Reply
#2

Код:
else
                    format(VehicleList, 500, "Empty car slot", VehicleList);
Код:
         else
                    format(VehicleList, 500, "%sEmpty car slot\n", VehicleList);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)