SA-MP Forums Archive
Vehicle command dont work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Vehicle command dont work (/showthread.php?tid=262192)



Vehicle command dont work - Unknown123 - 16.06.2011

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


Re: Vehicle command dont work - Benjo - 16.06.2011

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!


Re: Vehicle command dont work - Unknown123 - 16.06.2011

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..