Respawn all cars
#1

I want to make so all cars in in the server respawns how do i change that?

Код:
CMD:respawncars(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 3)
	{
		new string[128], radius;
		if(sscanf(params, "d", radius)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /respawncars [radius]");

		if(radius < 1 || radius > 40)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 41!");
			return 1;
		}
		RespawnNearbyVehicles(playerid, radius);
		format(string, sizeof(string), "You have respawned all vehicles within a radius of %d.", radius);
		SendClientMessageEx(playerid, COLOR_GREY, string);
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#2

Respawn ALL cars or Respawn UNUSED cars ?
Reply
#3

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
Respawn ALL cars or Respawn UNUSED cars ?
Respawn ALL unused cars!
Reply
#4

Use this
pawn Код:
CMD:respawnallcars(playerid)
{
    if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 3)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized!");
                return 1;
            }
            new bool:unwanted[MAX_VEHICLES];
            for(new player=0; player<MAX_PLAYERS; player++)
            {
                if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
            }
            for(new car = 1; car <= MAX_VEHICLES; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GameTextForAll("~w~Every Unused Car Has Been ~n~~g~Respawned!",5000,1);
        }
    return 1;
}
Reply
#5

here you got just edited your command a bit and made a stock for you

pawn Код:
CMD:respawncars(playerid, params[])
{
    new string[128], radius;
    if (PlayerInfo[playerid][pAdmin] < 3) return SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    if(sscanf(params, "d", radius)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /respawncars [radius]");
    if(radius < 1 || radius > 40) return endClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 41!");
   
    for(new i=0;i<MAX_VEHICLES;i++)
    {
        if(IsVehicleEmpty(i) == 1)
        {
            RespawnNearbyVehicles(playerid, radius);
            format(string, sizeof(string), "You have respawned all vehicles within a radius of %d.", radius);
            SendClientMessageEx(playerid, COLOR_GREY, string);
        }
    }
    return 1;
}

//add this where all your stock is
stock IsVehicleEmpty(vehicleid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerInVehicle(i, vehicleid)) return 0;
    }
    return 1;
}
EDIT
Im Too Slow. someone posted already on top. but give this a try if the code above won't work.
Reply
#6

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
Use this
pawn Код:
CMD:respawnallcars(playerid)
{
    if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 3)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized!");
                return 1;
            }
            new bool:unwanted[MAX_VEHICLES];
            for(new player=0; player<MAX_PLAYERS; player++)
            {
                if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
            }
            for(new car = 1; car <= MAX_VEHICLES; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GameTextForAll("~w~Every Unused Car Has Been ~n~~g~Respawned!",5000,1);
        }
    return 1;
}
Wowooo! 26 Errors something is wrong btw write that in code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)