Hallo,
ich habe ein kleines problem mit dem Leader Respawn befehl für Fraktions Fahrzeuge,
es werden alle Fahrzeuge respawnt, auch die besetzten.
Hier der Command:
ocmd:respawnfw(playerid,params[])
{
if(SpielerInfo[playerid][Leader] == 0)
{
SendClientMessage(playerid,COLOR_WHITE,"Du bist kein Leader!");
return 1;
}
if(SpielerInfo[playerid][Leader] == 2)
{
for(new i; i < sizeof(FactionCars); i++)
{
if(FactionCars[i][fFaction][0] == GetPlayerFaction(playerid))
{
if(!IsVehicleEmpty(i))
{
continue;
}
else
{
DestroyAndCreateFactionCar(i);
}
}
}
}
return 1;
}
Funktion DestroyAndCreateFactionCar
public DestroyAndCreateFactionCar(fc)
{
if(!IsVehicleEmpty(fc))
{
return 1;
}
if(FactionCars[fc][fVehid] >= 400 && FactionCars[fc][fVehid] <= 611)
{
DestroyVehicle(FactionCars[fc][fCarid]);
FactionCars[fc][fCarid] = CreateVehicle(FactionCars[fc][fVehid],FactionCars[fc][fPos][0],FactionCars[fc][fPos][1],FactionCars[fc][fPos][2],FactionCars[fc][fPos][3],FactionCars[fc][fCol][0],FactionCars[fc][fCol][1],-255);
#if defined FACTION_CARS_TUNEABLE
if(IsAllowedFactionToTune(FactionCars[fc][fFaction][0]))
{
if(FactionCars[fc][fTuning][0] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][0]);
}
if(FactionCars[fc][fTuning][1] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][1]);
}
if(FactionCars[fc][fTuning][2] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][2]);
}
if(FactionCars[fc][fTuning][3] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][3]);
}
if(FactionCars[fc][fTuning][4] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][4]);
}
if(FactionCars[fc][fTuning][5] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][5]);
}
if(FactionCars[fc][fTuning][6] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][6]);
}
if(FactionCars[fc][fTuning][7] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][7]);
}
if(FactionCars[fc][fTuning][8] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][8]);
}
if(FactionCars[fc][fTuning][9] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][9]);
}
if(FactionCars[fc][fTuning][10] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][10]);
}
if(FactionCars[fc][fTuning][11] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][11]);
}
if(FactionCars[fc][fTuning][12] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][12]);
}
if(FactionCars[fc][fTuning][13] != 0)
{
AddVehicleComponent(FactionCars[fc][fCarid],FactionCars[fc][fTuning][13]);
}
}
#endif
motor[fc] = false;
SetVehicleHealth(fc,1500);
}
return true;
}
Funktion IsVehicleEmpty:
stock IsVehicleEmpty(vehicleid)
{
for(new i =0; i < GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerInVehicle(i,vehicleid)) return 0;
}
return 1;
}
Habe bereits alles mögliche probiert bekomme es aber nicht hin...
Währe sehr freundlich wenn mir jemand helfen würde...
//edit:
Schleife durch alle Spieler entfernt