Respawn cars CMD help
#1

Howdy, everyone. This is my Car Respawn command:
Код:
CMD:respawncars(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 2)
	{
		new string[128], radius;
		if(sscanf(params, "d", radius)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /respawncars [radius]");

		if(radius < 1 || radius > 999999)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Radius must be higher than 0 and lower than 999999!");
			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;
}
The only problem is that it respawns EVERY cars even if there is someone driving it... I want it to respawn only cars that aren't being used, how could I do that? Thanks in advance!
Reply
#2

Hello before I post any script, what happend if you use a timers to use all cars of your gamemodes, example :
  • Each time(60minutes=1hours) all of your cars un-used will be respawn..
Reply
#3

Quote:
Originally Posted by thegreathom
Посмотреть сообщение
Hello before I post any script, what happend if you use a timers to use all cars of your gamemodes, example :
  • Each time(60minutes=1hours) all of your cars un-used will be respawn..
I prefer using a CMD to respawn all the cars
Reply
#4

pawn Код:
CMD:carr(playerid, params[])
{
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}
Reply
#5

^ Here you go.
Reply
#6

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
pawn Код:
CMD:carr(playerid, params[])
{
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}
Doesn't that respawn all cars? Including cars with drivers inside?
Reply
#7

so what do you want?

pawn Код:
CMD:carr(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            RemovePlayerFromVehicle(i);
        }
    }
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        SetVehicleToRespawn(i);
    }
    return 1;
}
Reply
#8

In your codes, I see you remove the players from the vehicules to respawn all cars, I think he want to means :
- When he use this commands it's will respawn all cars but will don't respawn USED CARS.
Reply
#9

Yes, what he said...
Reply
#10

Try this.

pawn Код:
CMD:respawncars(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
       for(new i=0; i<MAX_VEHICLES; i++)
        {
            new vehs;
            foreach(Player, x)
            {
                if(GetPlayerVehicleID(x) == i)
                {
                    vehs = 1;
                }
            }
            if(!vehs)
            {
                SetVehicleToRespawn(i);
            }
            vehs = 0;
        }
    format(string, sizeof(string), "AdmCmd: %s has respawned all unused vehicles.", RPN(playerid));
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    return 1;
}
Needed Plugins:
pawn Код:
- Scanff
- foreach
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)