SA-MP Forums Archive
Loop Not Occuring. - 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: Loop Not Occuring. (/showthread.php?tid=509872)



Loop Not Occuring. - Ahmad45123 - 28.04.2014

Hello,

Why In My Code, the loop isn't occuring ?

CODE :
pawn Код:
CMD:joineventb(playerid, params[])
{
    new breaks = 1;
    new idx = 0;
    if(IsEventS != 1) return SendClientMessage(playerid, COLOR_GREY, "There is no event to join.");
    PlayerEvent[playerid][Healthaa] = GetPlayerHealth(playerid);
    PlayerEvent[playerid][Armoraa] = GetPlayerArmour(playerid);
    GetPlayerPos(playerid, PlayerEvent[playerid][Lastx], PlayerEvent[playerid][Lasty], PlayerEvent[playerid][Lastz]);
    PlayerEvent[playerid][Intaa] = GetPlayerInterior(playerid);
    PlayerEvent[playerid][VWaa] = GetPlayerVirtualWorld(playerid);
    PlayerEvent[playerid][IsInside] = 1;
    PlayerEvent[playerid][Lap] = 0;
    while(idx < 32)
    {
        if(breaks == 1)
        {
            if(RaceCars[idx][1] == 0)
            {
                new Float:xxx, Float:yyy, Float:zzz;
                GetVehiclePos(RaceCars[idx][0], xxx, yyy, zzz);
                SetPlayerPos(playerid, xxx, yyy, zzz+5);
                SetPlayerInterior(playerid, 7);
                SetPlayerVirtualWorld(playerid, 0);
                PutPlayerInVehicle(playerid, RaceCars[idx][0], 0);
                RaceCars[idx][1] = 1;
                breaks = 0;
                TogglePlayerControllable(playerid, 0);
                SendClientMessage(playerid, COLOR_RED, "You have joined the event, therefore you are freezed untill the event begins.");
            }
        }
        idx++;
    }
    return 1;
}



Re: Loop Not Occuring. - Ahmad45123 - 28.04.2014

Managed to fix it...


Re: Loop Not Occuring. - Jefff - 28.04.2014

pawn Код:
new idx = -1;
while(++idx < sizeof(RaceCars))
    if(RaceCars[idx][1] == 0)
    {
        new Float:xxx, Float:yyy, Float:zzz;
        GetVehiclePos(RaceCars[idx][0], xxx, yyy, zzz);
        SetPlayerPos(playerid, xxx, yyy, zzz+5);
        SetPlayerInterior(playerid, 7);
        SetPlayerVirtualWorld(playerid, 0);
        PutPlayerInVehicle(playerid, RaceCars[idx][0], 0);
        RaceCars[idx][1] = 1;
        TogglePlayerControllable(playerid, 0);
        SendClientMessage(playerid, COLOR_RED, "You have joined the event, therefore you are freezed untill the event begins.");
        break;
    }