[Ajuda] Respawn veнculos sem uso
#1

Galera uso a ppc_trucking e o meu comando /respawncarros respawna todos os carros do server criados por admins,e eu gostaria que ele respawnasse apenas todos os veнculos do server SEM USO, oque jб tentei vбrias vezes e nгo consegui, serб que alguem pode me ajudar ? abaixo estб o cmd
Код:
COMMAND:respawncarros(playerid, params[])
{
	// Setup local variables
	new CarsDeleted, Msg[128];

	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Check if the player's admin-level is at least 3
		if (APlayerData[playerid][PlayerLevel] >= 3)
		{
		    // Loop through all vehicles
		    for (new vid; vid < 2000; vid++)
		    {
				// Check if this vehicle exists (check the model), otherwise all empty slots are processed as well
				if (AVehicleData[vid][Model] != 0)
				{
					// Check if the vehicle is NOT a static vehicle
					if (AVehicleData[vid][StaticVehicle] == false)
					{
						// Check if the vehicle is NOT owned by anybody (this leaves all vehicles spawned with /car, /trailer, /plane)
						if (AVehicleData[vid][Owned] == false)
						{
							// Count the cars that have been deleted
							CarsDeleted++;
							// Delete the vehicle and clear the data
							DestroyVehicle(vid);
							AVehicleData[vid][Owned] = false;
							AVehicleData[vid][Owner] = 0;
							AVehicleData[vid][Model] = 0;
							AVehicleData[vid][PaintJob] = 0;
							for (new i; i < 14; i++)
							    AVehicleData[vid][Components][i] = 0;
							AVehicleData[vid][SpawnX] = 0.0;
							AVehicleData[vid][SpawnY] = 0.0;
							AVehicleData[vid][SpawnZ] = 0.0;
							AVehicleData[vid][SpawnRot] = 0.0;
							AVehicleData[vid][BelongsToHouse] = 0;
						}
					}
				}
		    }

			// Let the player know how many vehicles have been cleaned up
			format(Msg, 128, "{00FF00}Total de veнculos respawnados: {FFFF00}%i", CarsDeleted);
			SendClientMessage(playerid, 0xFFFFFFFF, Msg);
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#2

Aqui.
Espero ter ajudado

No seu caso, retire a linha:
PHP код:
if(GetVehicleModel(i) != 435
Caso nгo a utilize, bom proveito.
Reply
#3

Quote:
Originally Posted by Ley
Посмотреть сообщение
Aqui.
Espero ter ajudado

No seu caso, retire a linha:
PHP код:
if(GetVehicleModel(i) != 435
Caso nгo a utilize, bom proveito.
O Stock eu coloco aonde amigo ?
Reply
#4

Quote:
Originally Posted by Performancetotal
Посмотреть сообщение
O Stock eu coloco aonde amigo ?
Pode coloca-la abaixo do comando .
Reply
#5

Quote:
Originally Posted by SkullGamer
Посмотреть сообщение
Pode coloca-la abaixo do comando .
Код:
CMD:respawndeso(playerid, vehicleid) 
{ 
    if(!IsPlayerAdmin(playerid)) return 0; 

    for(new i; i < MAX_VEHICLES; i++) 
    { 

        { 
            if(!IsVehicleO(i)) SetVehicleToRespawn(i); // Verificaзгo se o veнculo estб ocupado e respawn. 
        } 
    } 
    return 1; 
}  
stock IsVehicleO(vehicleid)  
{ 
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) 
    return 1; return 0;  
}
coloquei igual estavam dizendo e ao entrar no game deu server uknown comando ;/
Reply
#6

Coloca isso no ppc_playercommands
Код:
CMD:respawncarros(playerid, params[])
{
 SendAdminText(playerid, "/respawncarros", params);

 if (APlayerData[playerid][PlayerLevel] < 3) return SendClientMessageToAll(-1, "{FFFF00}[ERRO]  {FF0000}Vocк nгo tem permissгo para usar esse comando!");
 {
  
  for(new i; i < MAX_VEHICLES; i++)
  {
   if(!IsVehicleInUse(i))
   SetVehicleToRespawn(i);
  }
  SendClientMessageToAll(-1, "{FFFF00}[INFO] {00FF00}O administrador respawnou todos os veнculos desocupados!");
 }
 return 1;
}
e isso no final da gm em stock

Код:
stock IsVehicleInUse(vehicleid)
{
    new Veiculo;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerVehicleID(i) == vehicleid)
            Veiculo = vehicleid;
        if(GetVehicleTrailer(GetPlayerVehicleID(i)) == vehicleid)
            Veiculo = vehicleid;
    }
    return Veiculo;
}
pra mim deu certo ele so respawna quando n tiver em uso '-'
Reply
#7

pelo o que eu vi voce tem um post praticamente igual mas o caso й q o trailer nao respawna entao da uma olhada que ja respondi la '-' https://sampforum.blast.hk/showthread.php?tid=491197
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)