[HELP] Command
#1

I tried to make an command, when leader type /lcr to respawn the cars faction.


pawn Код:
if(strcmp(cmd, "/lcncarrespawn", true) == 0 || strcmp(cmd, "/lcr", true) == 0)
    {
        if (PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pRank] == 6)
        {
            new tmpcar = GetPlayerVehicleID(playerid);
            if(IsAlcnCar(tmpcar))
            {
                for(new player=0; player<MAX_PLAYERS; player++)
                {
                    if(!IsVehicleOccupied(player)) SetVehicleToRespawn(player);
                }
            }
        }
        return 1;
    }
I put this line "IsAlcnCar", but he respawn all cars on server.
Reply
#2

That doesn't make sense at all. With your design you'd have to check for every vehicle id if it is an LCN vehicle. That doesn't have to do anything with the players. Also the tmpcar is completely useless.
You could do it like this:
pawn Код:
if (strcmp(cmd, "/lcncarrespawn", true) == 0 || strcmp(cmd, "/lcr", true) == 0)
    {
        if (PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pRank] == 6)
        {
            for (new tmpcar = 1; tmpcar <= MAX_VEHICLES; tmpcar++)
            {
                if (!IsVehicleOccupied(tmpcar) && IsAlcnCar(tmpcar))
                    SetVehicleToRespawn(tmpcar);
            }
        }
        return 1;
    }
But there are better possibilities for example the foreach solution by ******.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)