Getting rid of unused vehicles.
#1

Is there a server command that can get rid of any unoccupied cars and respawn them to their original spawn point in a set amount of time?

Like the code executes every 5 minutes, it checks the entire server and any cars that are unoccupied, but have been moved from spawn position are
A) Destroyed
B) Respawned


----------
If that is not possible, I'll tell you what I am looking for.

Right now the server spawns all cars. When you drive a car away and park it, the car will respawn after a certain amount of time in its spawn point, BUT the parked car also remains. The server crashes when it is overloaded with cars.

Is possible to create something that deletes the parked car 1 - 5 minutes after it is parked, and respawn it?

----------
Code:
#include <a_samp>

#include <core>

#include <float>

#include "../include/gl_common.inc"

#include "../include/gl_spawns.inc"	

//add vehicles
	AddStaticVehicle(425,2735.7693,-2395.2769,13.6328,91.3478,0,0); //Hunter MILITARY
	AddStaticVehicle(432, 2785.1946,-2436.8831,13.6343,90.3143,0,0); //Tank MILTARY
	//AddStaticVehicle(432,2786.0256,-2475.0281,13.6419,91.3010,0,0); //Tank MILTARY
	AddStaticVehicle(432,1566.1920,1171.9224,10.8125,359.3973,0,0); //Tank airport 2
	AddStaticVehicle(432,1595.3130,1186.8004,10.8125,3.2972,0,0); //Tank airport 3
 	AddStaticVehicle(470,178.4142,1932.9073,18.0535,180.4405,6,101);// patriot area69
 	AddStaticVehicle(470,169.9842,1932.4008,18.3811,185.9241,6,101);// patriot area69
 	AddStaticVehicle(470,171.2247,1905.1343,18.3632,266.3452,6,101);// patriot area 69
	AddStaticVehicle(520,1289.3530,1397.8961,10.8203,249.3196,0,1);// hydra
	AddStaticVehicle(520,-2227.4072,2326.7725,7.5469,94.0051,1,1);// HYDRA
	AddStaticVehicle(520,2763.9556,-2396.6501,13.6328,2.0469,0,0); //Hyrda MILITARY
	AddStaticVehicle(520,1299.4154,1406.0792,10.8203,189.8212,0,0); //Hyrda airport
	AddStaticVehicle(470,-1110.9086,-1637.0076,76.3604,268.1148,6,65); //Patriot
	

	// SPECIAL
	total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt");
	total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt");

  	// LAS VENTURAS
   total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt");

  // SAN FIERRO
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt");

  // LOS SANTOS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt");

  // OTHER AREAS
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt");
  total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt");



	//SetTimer("GameModeExitFunc", gRoundTime, 0);

	return 1;

 }
That is the code we currently use to spawn cars!

Thank you!
Reply
#2

I was also thinking of that, but you would have to make an array with all vehicles in it -> DestroyVehicle so it would respawn.

If there is another way, I would like to know.
Reply
#3

Of course there is. Use AddStaticVehicleEx instead of AddStaticVehicle, so you can set the respawn time of vehicle in the function.
Reply
#4

Quote:
Originally Posted by kLx
Of course there is. Use AddStaticVehicleEx instead of AddStaticVehicle, so you can set the respawn time of vehicle in the function.
Well, I was talking about using a respawn cmd.
Reply
#5

Quote:
Originally Posted by kLx
Of course there is. Use AddStaticVehicleEx instead of AddStaticVehicle, so you can set the respawn time of vehicle in the function.
Check out my code. I spawn vehicles from text files. That code is basically copied from Grand Larceny. How exactly do I add in the AddStaticVehicleEx to my code then!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)