SA-MP Forums Archive
Respawn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Respawn (/showthread.php?tid=624552)



Respawn - Hunud - 18.12.2016

Hi,

How to not respawn vehicle if player is in!

Код:
CMD:respawncars(playerid,params[])
{
	if (APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 7)
	{
    	for(new i; i < MAX_VEHICLES; i++)
	{
	    SetVehicleToRespawn(i);
	}
	    SendClientMessageToAll(0xFFFFFF, "Cars respawned.");
	return 1;
	}
	return 0;
}



Re: Respawn - SyS - 18.12.2016

http://forum.sa-mp.com/showpost.php?...55&postcount=6


Re: Respawn - GoldenLion - 18.12.2016

Loop through online players and check if their vehicle ID matches with the looped vehicle ID. Also you should use GetVehiclePoolSize to loop through the vehicles and you must add IsValidVehicle check.


Re: Respawn - Hunud - 18.12.2016

I dont understand :/


Re: Respawn - 963852741 - 19.12.2016

Add this to ur script:
pawn Код:
stock IsVehicleOccupied(vehicleid) // Returns 1 if there is anyone in the vehicle
{
    foreach(new i : Player)
    {
        if(IsPlayerInAnyVehicle(i))
        {
            if(GetPlayerVehicleID(i)==vehicleid)
                return 1;
        }
    }
    return 0;
}
Then
pawn Код:
CMD:respawncars(playerid,params[])
{
    if (APlayerData[playerid][LoggedIn] == true && APlayerData[playerid][PlayerLevel] > 7)
    {
        for(new i; i < MAX_VEHICLES; i++)
    {
        if(!IsVehicleOccupied(i)) SetVehicleToRespawn(i);
    }
        SendClientMessageToAll(0xFFFFFF, "Cars respawned.");
    return 1;
    }
    return 0;
}