SA-MP Forums Archive
Spawn In Random Car! - 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: Spawn In Random Car! (/showthread.php?tid=157847)



Spawn In Random Car! - ColdXX - 07.07.2010

Hey!
I have 1 question!
How can i do something like when someone uses a command like /derby ,puts that player into a random car?

Thanks!


Re: Spawn In Random Car! - CAR - 08.07.2010

TOP:
pawn Код:
new Derby[5]; // don't know how much derby cars you got, but if you got 4 put in here 5
OnGameModeInit
pawn Код:
Derby[1] = AddStaticVehicle(...); // put in here your vehicles
Derby[2] = AddStaticVehicle(...);
Derby[3] = AddStaticVehicle(...);
Derby[4] = AddStaticVehicle(...);
/* if they are in a Interior your need to: LinkVehicleToInterior(Derby[1], Interior); for all vehicles */
OnPlayerCommandText
pawn Код:
new cmd[256], idx;
if(!strcmp(cmd, "/derby"))
{
   for(new i; i<MAX_PLAYERS; i++)
   {
      new rand=random(5); // or 4 don't know anymore :P
      if(!IsPlayerInVehicle(i, Derby[rand])) return PutPlayerInVehicle(playerid, Derby[rand], 0);
      else return SendClientMessage(playerid, 0xFF0000, "Retry the command, please!"); // don't know something else
   }
}



Re: Spawn In Random Car! - dice7 - 08.07.2010

pawn Код:
new Derby[5];

Derby[0] = AddStaticVehicle(...);
Derby[1] = AddStaticVehicle(...);
Derby[2] = AddStaticVehicle(...);
Derby[3] = AddStaticVehicle(...);
Derby[4] = AddStaticVehicle(...);



Re: Spawn In Random Car! - ColdXX - 08.07.2010

Thanks!
I was thinking at something like this but wasnt really sure how to do it !

Once again thanks!