[HELP] Timer on Respawnallcars?
#1

Hello guys and girls, I need help to make a timer on /respawnallcars.

Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) 
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(PlayerInfo[playerid][Admin] < 1)
			{
			  SendClientMessage(playerid, COLOR_GREY, "	You are not authorized to use that command.");
			  return 1;
			}
			new bool:unwanted[CAR_AMOUNT];
			for(new player=0; player<MAX_PLAYERS; player++)
   		{
      	if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
   		}
			for(new car = 1; car <= 268; car++)
			{
				if(!unwanted[car]) SetVehicleToRespawn(car);
			}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "All unused cars has been respawned by administrator %s.", sendername);
			SendClientMessageToAll(COLOR_RED, string);
		}
		return 1;
	}
It should be 30 seconds and then the cars should respawn.

Thanks for all answers
Reply
#2

Do you realy want this to work with a command ? because you could use 'AddStaticVehicleEx ' and set
that to 30
Reply
#3

Quote:
Originally Posted by boelie
Do you realy want this to work with a command ? because you could use 'AddStaticVehicleEx ' and set
that to 30
When a admin types /respawnallcars it should like say "WARNING: 30 seconds before respawn"
Reply
#4

ive got a code that checks if anyones in the car but i dont think its what you want

public CarCleaner(vehicleid)
{
for(new i; i < MAX_VEHICLES; i++)
{
if(!IsVehicleInUse(vehicleid))
{
SetVehicleToRespawn(i);
}
}
printf("Cars Cleaned!");
}


IsVehicleInUse(vehicleid){
new temp;
for(new i=0;i<200;i++){
if(IsPlayerConnected(i) && IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i)==PLAYER_STATE_DRIVER){
temp++;
}
}
if(temp > 0){ return true; } else return false;
}

the function above isnt made by me.

the timer is made by me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)