Respawn Empty Cars
#1

Hey guys just having a problem with this code when i enter the command it does respawn the cars just it also returns SERVER :UNKOWN COMMAND any ideas?

Код:
if(strcmp(cmd, "/respawncars", true) == 0)
  {
		if (PlayerInfo[playerid][pAdmin] == 0)
		{
			format(string,sizeof(string),"* The Command (%s) Is Unknown, Use '/help' For Commands.",cmdtext);
			SendClientMessage(playerid,COLOR_WHITE, string);
			return 1;
		}
		SendClientMessage(playerid,COLOR_WHITE,"* All Empty Cars Have Been Respawned");
		RespawnEmptyCars();
		return 1;
	}

public RespawnEmptyCars()
{
	for(new d = 0; d < MAX_VEHICLES; d++)
	{
	  if(IsVehicleEmpty(d))
	  {
	    SetVehicleToRespawn(d);
			VehicleInfo[d][gas] = 100;
	    ModVehicle(d);
	  }
	}
}

IsVehicleEmpty(vehicleid)
{
  for(new i = 0, j = GetMaxPlayers(); i < j; i++)
  {
    if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) && IsPlayerInVehicle(i,vehicleid)) return false;
  }
  return true;
}
Reply
#2

I'm just making a wild guess here, but try this:

pawn Код:
public RespawnEmptyCars()
{
    for(new d = 0; d < MAX_VEHICLES; d++)
    {
      if(IsVehicleEmpty(d))
      {
        SetVehicleToRespawn(d);
            VehicleInfo[d][gas] = 100;
        ModVehicle(d);
      }
    }
    return 1;
}
Reply
#3

pawn Код:
public RespawnEmptyCars()
{
        for(new i=0; i<MAX_VEHICLES; i++)
        {
            for(new pl = 0; pl<MAX_PLAYERS; pl++)
            {
                if(IsPlayerConnected(pl))
                {
                    if(!IsPlayerInVehicle(pl, i))
                    {
                        SetVehicleToRespawn(i);
                    }
                }
            }
        }
}
Reply
#4

thanks for quick response just used

Quote:
Originally Posted by //exora
pawn Код:
public RespawnEmptyCars()
{
        for(new i=0; i<MAX_VEHICLES; i++)
        {
            for(new pl = 0; pl<MAX_PLAYERS; pl++)
            {
                if(IsPlayerConnected(pl))
                {
                    if(!IsPlayerInVehicle(pl, i))
                    {
                        SetVehicleToRespawn(i);
                    }
                }
            }
        }
}
saved me a few lines and a headache thanks
Reply
#5

Or you can use...

pawn Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) // by TyreXel
    {
      if(IsPlayerConnected(playerid))
      {
        if(PlayerInfo[playerid][pAdmin] < 1337)
            {
              SendClientMessage(playerid, COLOR_GRAD1, "  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 <= 500; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), " All unused cars have been respawned by administrator %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
        return 1;
    }
Reply
#6

Quote:
Originally Posted by tunetu
Or you can use...

pawn Код:
if(strcmp(cmd, "/respawnallcars", true) == 0 || strcmp(cmd, "/rac", true) == 0) // by TyreXel
    {
      if(IsPlayerConnected(playerid))
      {
        if(PlayerInfo[playerid][pAdmin] < 1337)
            {
              SendClientMessage(playerid, COLOR_GRAD1, " 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 <= 500; car++)
            {
                if(!unwanted[car]) SetVehicleToRespawn(car);
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            format(string, sizeof(string), " All unused cars have been respawned by administrator %s.", sendername);
            BroadCast(COLOR_WHITE,string);
        }
        return 1;
    }
Not necessarily, he's not looking for a command to do it, he was looking for someone to fix his public, which I failed at, and //exora did.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)