Help with respawning a particular set of vehicles. - 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: Help with respawning a particular set of vehicles. (
/showthread.php?tid=457038)
Help with respawning a particular set of vehicles. -
DanishHaq - 08.08.2013
Hi, so I am making a command which is /fvr, it respawns all the cars of that faction. You would probably understand it below.
pawn Код:
if(strcmp(cmd, "/fvr", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLeader] <= 0 || PlayerInfo[playerid][pRank] <= 5)
{
SendClientMessage(playerid, COLOR_WHITE, "Only leaders/sub-leaders can use this command.");
return 1;
}
if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 && PlayerInfo[playerid][pRank] >= 6)
{
new bool:unwanted[CAR_AMOUNT];
for(new player=0; player<MAX_PLAYERS; player++)
{
if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
}
new car = 17; car = 36; car = 37; car = 34; car = 35; car = 22; car = 31; car = 29; car = 30; car = 23; car = 18; car = 19; car = 20; car = 21; car = 24; car = 25; car = 26; car = 32; car = 33; car = 356; car = 357;
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
SendClientMessage(playerid, COLOR_WHITE, "Your faction cars have been respawned.");
return 1;
}
}
return 1;
}
The problem is that, when I go in game and I use /fvr, it doesn't respawn any of the cars stated, it just shows the SendClientMessage and that's all.
Any help would be appreciated.
Re: Help with respawning a particular set of vehicles. -
arjanforgames - 08.08.2013
So what is unwanted supposed to do? I don't understand why you name your boolean like that while doing a car script.
Re: Help with respawning a particular set of vehicles. -
DanishHaq - 08.08.2013
Unwanted are the vehicle(s) that don't have a driver... and the boolean is the thing that coordinates that.
Re: Help with respawning a particular set of vehicles. -
Konstantinos - 08.08.2013
pawn Код:
new car = 17; car = 36; car = 37; car = 34; car = 35; car = 22; car = 31; car = 29; car = 30; car = 23; car = 18; car = 19; car = 20; car = 21; car = 24; car = 25; car = 26; car = 32; car = 33; car = 356; car = 357;
This is really useless, I assume that you wanted to so something else because the current code checks if the vehicleid 357 is not unwanted and it respawns it.
I'd store the vehicleids to an array and then simply:
pawn Код:
// Inside the /fvr command
for( new v = 0; v < MAX_VEHICLES; v++ )
{
if( !IsVehicleOccupied( Vehicles[ v ][ PlayerInfo [playerid ][ pFaction ] ] ) ) SetVehicleToRespawn( Vehicles[ v ][ [ PlayerInfo [playerid ][ pFaction ] ] );
}
stock IsVehicleOccupied( vehicleid )
{
for( new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerInVehicle( i, vehicleid ) ) return 1;
}
return 0;
}