SA-MP Forums Archive
[HELP] Command - 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] Command (/showthread.php?tid=513160)



[HELP] Command - monster010 - 14.05.2014

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.


Re: [HELP] Command - Madd92 - 14.05.2014

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 ******.