Faction Car 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: Faction Car Respawn (
/showthread.php?tid=538828)
Faction Car Respawn -
ThomasMann - 24.09.2014
I have this command, that will respawn all the cars from a certain faction. The problem is, that it respawns the car, even if a player is driving it. What should i do, to respawn only the unused faction cars?
Код:
if(strcmp(cmd, "/fvr", true)) //Brooklyn Family
{
if(PlayerInfo[playerid][pLeader] == 6)
{
SetVehicleToRespawn(brooklyncar[0]); SetVehicleToRespawn(brooklyncar[1]); SetVehicleToRespawn(brooklyncar[2]); SetVehicleToRespawn(brooklyncar[3]); SetVehicleToRespawn(brooklyncar[4]); SetVehicleToRespawn(brooklyncar[5]); SetVehicleToRespawn(brooklyncar[6]); SetVehicleToRespawn(brooklyncar[7]); SetVehicleToRespawn(brooklyncar[8]); SetVehicleToRespawn(brooklyncar[9]);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(PlayerInfo[i][pMember] == 6 ||PlayerInfo[i][pLeader] == 6)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), " All faction cars have been respawned by Leader %s.", sendername);
SendClientMessage(i,COLOR_LIGHTBLUE,string);
}
}
}
else
{
SendClientMessage(playerid,COLOR_GREY," You are not the leader of an illegal faction !");
}
}
Re: Faction Car Respawn -
SWGamer - 24.09.2014
You could use
Код:
if(!IsPlayerInVehicle(playerid, vehicleid)
with
Case
Re: Faction Car Respawn -
MateiMatei - 11.03.2015
@SWGamer, can u be more explicit please? I have the same problem..
Re: Faction Car Respawn -
lean1337 - 12.03.2015
pawn Код:
stock IsVehicleOccupied(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return 0;
}
if(!IsVehicleOccupied(VEHID))
Re: Faction Car Respawn -
Abagail - 12.03.2015
pawn Код:
if(PlayerInfo[playerid][pLeader] == 6)
{
for(new i = 0; i < sizeof(BrooklynCars); i++)
{
if(!IsVehicleOccupied(BrooklynCars[i]))
{
SetVehicleToRespawn(BrooklynCars[i]);
}
}
This code is also much more dynamic / flexible because it will respawn cars as new ones are added. It requires an IsVehicleOccupied function such as the one above.