29.11.2009, 07:08
Im taking a shot at this. I made 2 commands. 1 for spawning one car at random. The other to delete all cars, and spawn 10 cars at random, then drop you at the last car created. These have not been tested, but theoretically should work.
Pastebin link for code
Pastebin link for code
Код:
if(strcmp(cmd, "/randomcar", true) == 0) //Creates 1 car in random location. { new Float:vehiclex, Float:vehicley, Float:vehiclez; //declare vehicle coordinates new Float:playerx, Float:playery, Float:playerz; //declare player coordinates SetPlayerPosFindZ(playerid, float(random(660)), float(random(500)), 500.0); //place player in random location GetPlayerPos(playerid, playerx, playery, playerz); //detect where the player is new idveh = CreateVehicle(411, playerx, playery, playerz, float(random(360)), random(127), random(127), 60000); //create vehicle at that location SetPlayerPos(playerid, playerx, playery, playerz+1.0); //sets player above car so he doesnt spawn inside the car return 1; } if(strcmp(cmd, "/randomcars", true) == 0) //Destroys all cars and creates 10 in random locations, dropping you at the last one created. { new Float:vehiclex, Float:vehicley, Float:vehiclez; //declare vehicle coordinates new Float:playerx, Float:playery, Float:playerz; //declare player coordinates new CarCount; for(new c=0; c<=2000;) { DestroyVehicle©; c++; } for(new k=0; k<=10;) { SetPlayerPosFindZ(playerid, float(random(660)), float(random(500)), 500.0); //place player in random location GetPlayerPos(playerid, playerx, playery, playerz); //detect where the player is new idveh = CreateVehicle(411, playerx, playery, playerz, float(random(360)), random(127), random(127), 60000); //create vehicle at that location SetPlayerPos(playerid, playerx, playery, playerz+1.0); //sets player above car so he doesnt spawn inside the car CarCount++; //increases car count each time the loop passes k++; } new msg[48]; format(msg,sizeof(msg),"you made %d cars", CarCount); //sets message string to tell you how many cars have been created. SendClientMessage(playerid,0xFFFFFFFF,msg); //sends string that was created return 1; }