SA-MP Forums Archive
vehicle choose - 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)
+--- Thread: vehicle choose (/showthread.php?tid=294922)



vehicle choose - marik1322 - 04.11.2011

how can i do that every time when i use the command it will spawn me an another type of vehicle??
PHP код:
if(!strcmp(cmdtext, "/car", true))
{
if(
IsPlayerAdmin(playerid))
{
new 
Float:x,Float:y,Float:z,Float:angle;
GetPlayerPos(playerid, x,y,z);
car = CreateVehicle(522,x,y,z,angle, 0, 1, 60);
PutPlayerInVehicle(playerid, car, 0);
}
return 
1;
} 



Respuesta: vehicle choose - Super_Panda - 04.11.2011

Which type of vehicle you want to spawn for you?


Re: vehicle choose - Gustavob - 04.11.2011

Try this one, it will randomize between every available vehicle, including (baggage/luggage) trailers and RC vehicles.

pawn Код:
if(!strcmp(cmdtext, "/car", true))
{
    if(IsPlayerAdmin(playerid))
    {
        new Float:x,Float:y,Float:z,Float:angle, thiscar, model;
        model = 400+random(611-400) //randomize between two integers: minimum + random(maximum - minimum)
        GetPlayerPos(playerid, x,y,z);
        thiscar = CreateVehicle(model,x,y,z,angle, 0, 1, 60);
        PutPlayerInVehicle(playerid, thiscar, 0);
    }
    return 1;
}



Re: vehicle choose - StuffBoy - 04.11.2011

pawn Код:
stock randvehcile()
{
   new veh = random(3);
   new model;
   switch(veh)
   {
       case 0: { model = 560; } //sultan
       case 1:  { model = 562; } // elegy
       case 2:  { model = 522; } // fcr 900 i guess
   }
   return model;
}
Use that stock instead of your model id on CreateVehicle

- Edit: Rename the stock it was supposed to be randvehicle


Re: vehicle choose - marik1322 - 04.11.2011

i have error
Quote:

D:\Marik\LV server\LV server\gamemodes\RaceSystem.pwn(51) : error 076: syntax error in the expression, or invalid function call
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Quote:

car = CreateVehicle(randvehicle,x,y,z,angle, 0, 1, 60);




Re: vehicle choose - StuffBoy - 04.11.2011

pawn Код:
car = CreateVehicle(randvehicle(),x,y,z,angle, 0, 1, 60);



Re: vehicle choose - marik1322 - 04.11.2011

tnx man you pro!!