[HELP]Random Vehicle type.
#8

It's pretty easy, I suppose I'll go ahead and make a script that randomizes vehicles after they spawn
pawn Код:
//At the top of your FS or GM

new Float:RandVehicles[3][4]; //X,Y,Z,A -- change [x] to the amount of random vehicles you have
new RandVehicleID[3]; // Change[x] to be the same as the previous one
new RandVAmount;

new RandVehicleModels[3] = { //Change [x] to be the amount of models you have
400,
401, //Vehicle models, all but last one has a ','
402
};

CreateRandomVehicle(Float:X,Float:Y,Float:Z,Float:A,ID)
{
  new tmp;
  if(ID==-1)tmp=RandVAmount; else tmp = ID;
  RandVehicles[tmp][0]=X;
  RandVehicles[tmp][1]=Y;
  RandVehicles[tmp][2]=Z;
  RandVehicles[tmp][3]=A;
  new rand=random(sizeof(RandVehicleModels));
  RandVehicleID[tmp]=CreateVehicle(RandVehicleModels[rand],X,Y,Z,A,-1,-1,60000);
  if(ID==-1)RandVAmount++;
}

//Inside of OnGameModeInit or OnFilterScriptInit
public OnFilterScriptInit()
{
  CreateRandomVehicle(100,100,100,100,-1); //-1 means the vehicle is new
  CreateRandomVehicle(100,100,100,100,-1); //-1 means the vehicle is new
  CreateRandomVehicle(100,100,100,100,-1); //-1 means the vehicle is new
}

//Inside of OnVehicleSpawn
public OnVehicleSpawn(vehicleid)
{
  for(new o; o<RandVAmount; o++)
  {
    if(vehicleid==RandVehicleID[o])
    {
      DestroyVehicle(RandVehicleID[o]);
      CreateRandomVehicle(RandVehicles[o][0],RandVehicles[o][1],RandVehicles[o][2],RandVehicles[o][3],o);
      break;
    }
  }
}
EDIT*Just tested it, works fine now.

EDIT** I actually really like that lol, hope someone makes good use of it.
Reply


Messages In This Thread
[HELP]Random Vehicle type. - by Abernethy - 09.06.2009, 10:25
Re: [HELP]Random Vehicle type. - by Gappy - 09.06.2009, 10:43
Re: [HELP]Random Vehicle type. - by Abernethy - 09.06.2009, 11:21
Re: [HELP]Random Vehicle type. - by Gappy - 09.06.2009, 11:38
Re: [HELP]Random Vehicle type. - by MPKaboose - 09.06.2009, 11:41
Re: [HELP]Random Vehicle type. - by Abernethy - 10.06.2009, 05:14
Re: [HELP]Random Vehicle type. - by Klutty - 10.06.2009, 06:43
Re: [HELP]Random Vehicle type. - by Joe Staff - 10.06.2009, 07:15

Forum Jump:


Users browsing this thread: 1 Guest(s)