Vehicle command dont work
#1

pawn Код:
COMMAND:cars(playerid, params[])
{
    new Count = 0, string[128];
    for(new v = 0; v < MAX_OWNED_VEHICLES; v++)
    {
        if(strmatch(CarData[v][CarOwner], PlayerName(playerid)))
        {
            Format(string, "%d - %d \n", Count, CarData[v][CarModel]);
            Count ++;
        }
    }
    if(Count != 0)
    {
        ShowPlayerDialog(playerid, 158, DIALOG_STYLE_LIST, "cars", string, "Select", "Cancel");
    }else{
        ShowPlayerDialog(playerid, 158, DIALOG_STYLE_LIST, "cars", "0 - none", "Select", "Cancel");
    }
    return 1;
}
if i have 1 car then it sais

0 - 411 //wich is correct

but if i have 2 cars it sais

1 - 411

but i want it to say (when i have 2cars)

0 - 411
1 - 411
Reply
#2

Hello there!
You need to replace this line:
pawn Код:
Format(string, "%d - %d \n", Count, CarData[v][CarModel]);
to something like this:
pawn Код:
format(string, "%s%d - %d \n", string, Count, CarData[v][CarModel]);
Before, it was always replacing the contents of 'string', meaning it would always display the last line. The above suggestion should retain the data previous stored into the variable.

Hope that helps!
Reply
#3

Tanx works fine!

EDIT:

But how to teleport to the selected vehicle? like how to save the vehicle id for each car i own?
so i can use GetVehiclePos and yeah.. you know..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)