Help with respawning a particular set of vehicles.
#1

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

So what is unwanted supposed to do? I don't understand why you name your boolean like that while doing a car script.
Reply
#3

Unwanted are the vehicle(s) that don't have a driver... and the boolean is the thing that coordinates that.
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)