SA-MP Forums Archive
Problem with loop. - 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: Problem with loop. (/showthread.php?tid=552246)



Problem with loop. - Baltimore - 23.12.2014

xxxxxx


Re: Problem with loop. - DavidSparks - 23.12.2014

Whats the problem?


Re : Problem with loop. - Baltimore - 23.12.2014

xxxxx


Re: Problem with loop. - DavidSparks - 23.12.2014

Would be much easier to help if you made it to english..


Re: Problem with loop. - Vince - 23.12.2014

Strcmp also returns 0 if either string is empty. Thus, you will want to check if "Proprio" contains anything before trying to compare it.


Re : Problem with loop. - Baltimore - 23.12.2014

pawn Код:
[21:44:00] [debug] Run time error 4: "Array index out of bounds"
[21:44:00] [debug]  Accessing element at index 1000 past array upper bound 999
[21:44:00] [debug] AMX backtrace:
[21:44:00] [debug] #0 00043408 in public cmd_list (0, 1357728) from GM.amx
[21:44:00] [debug] #1 native CallLocalFunction () from samp-server.exe
[21:44:00] [debug] #2 00006500 in public OnPlayerCommandText (0, 1357704) from GM.amx
[21:44:01] [debug] Run time error 4: "Array index out of bounds"
[21:44:01] [debug]  Accessing element at index 12 past array upper bound 11
[21:44:01] [debug] AMX backtrace:
[21:44:01] [debug] #0 000705f8 in ?? (2641, 1374020, 1374016, 1374012, 1374008, 1374004, 1374000, 1, 0) from GM.amx
[21:44:01] [debug] #1 00060a8c in public Itter_OnPlayerDisconnect (0, 1) from GM.amx
[21:44:01] [debug] #2 00007bec in public SSCANF_OnPlayerDisconnect (0, 1) from GM.amx
[21:44:01] [debug] #3 00000614 in public OnPlayerDisconnect (0, 1) from GM.amx
With "crashdetec" when i write /list. Can you help me


Re : Problem with loop. - Baltimore - 23.12.2014

upppp


Re : Problem with loop. - Baltimore - 24.12.2014

Can you help me please?


Re: Problem with loop. - Threshold - 24.12.2014

pawn Код:
COMMAND:list(playerid, params[])
{
    new string_total[256];
    for(new i = 1; i <= MAX_VEHICLES; i++)
    {
        printf("i = %i | proprio: %s | name: %s", i, VehInfo[(i - 1)][Proprio], NameRequete[playerid]);
        if(!strcmp(VehInfo[(i - 1)][Proprio], NameRequete[playerid], true) && strlen(VehInfo[(i - 1)][Proprio]))
        {
            printf("on a trouver ton veh: i = %i", i);
            if(!IsABike(i))
            {
                printf("et c pas un bike!");
                new stringveh[25];
                format(stringveh, sizeof(stringveh), "%s\n", GetVehicleName(i));
                strins(string_total, stringveh, strlen(string_total));
                printf("fin!");
            }
        }
    }
    return ShowPlayerDialog(playerid, 11, DIALOG_STYLE_LIST, "Veh:", string_total, "Valider", "Annuler");
}
You need to subtract 1 from vehicle IDs, because elements start at '0', however vehicle IDs start at '1'. If you don't, you will get an out of bounds error.


Re : Problem with loop. - Baltimore - 24.12.2014

When i write /list: Unknown command