Respawn
#1

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;
}
Reply
#2

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

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.
Reply
#4

I dont understand :/
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)