Random Vehicle from the server?
#1

Hello Guys,
I was thinking is it possible to select any random vehicle that is ALREADY spawned in the server and after selecting if we can add the objective marker on it.
Is it possible?
Thank You
Please don't reply saying use the random command and stuff.
Reply
#2

pawn Код:
new gSpawnedCars[MAX_VEHICLES];

CMD:randcar(playerid, params[])
{
    for(new i=0, increment = 0; i<MAX_VEHICLES; i++) {
        if(GetVehicleModel(i) != -1) {
            gSpawnedCars[increment] = i;
            increment++;
        }
    }
   
    new
        randcar = random(sizeof(gSpawnedCars)),
        Float:vPos[3];
       
    GetVehiclePos(gSpawnedCars[randcar], vPos[0], vPos[1], vPos[2]);
   
    SetPlayerCheckpoint(playerid, vPos[0], vPos[1], vPos[2], 5.0);
    return 1;
}
It compiled, but not sure if it works.
Reply
#3

That is fine but instead of SetPlayerCheckpoint if i wanna use SetVehicleParamsEx what should i put in the vehicleid const?
Should it gSpawnedCars[randcar] ??
Reply
#4

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1/0, lights,alarm, doors, bonnet, boot, objective);
1 equal on 0 equal off u can do this for anyone
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
https://sampwiki.blast.hk/wiki/GetVehicleParamsEx
Reply
#5

@trapstar i know that..read my question..what to put in vehicleid..dont post for increasing post count
Reply
#6

Bump..
Reply
#7

i guess this would do better the job.

pawn Код:
native IsValidVehicle(vehicleid);


CMD:randcar(playerid, params[])
{
   new carid;
   while(!IsValidVehicle((carid = random(MAX_VEHICLES)))){}
   new
        Float:vPos[3];
   GetVehiclePos(carid, vPos[0], vPos[1], vPos[2]);
   SetPlayerCheckpoint(playerid, vPos[0], vPos[1], vPos[2], 5.0);
   return 1;
}
By the way, vehicleid is the ID of the vehicle. you can use the to get the vehicleid that the player is in.

https://sampwiki.blast.hk/wiki/GetPlayerVehicleID
Reply
#8

Quote:
Originally Posted by [HK]Ryder[AN]
Посмотреть сообщение
That is fine but instead of SetPlayerCheckpoint if i wanna use SetVehicleParamsEx what should i put in the vehicleid const?
Should it gSpawnedCars[randcar] ??
SetVehicleParamsEx(randcar, bla bla bla);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)