30.01.2016, 07:53
Hi guys, i have this command:
so i added a debug, and in crashdetect i get this:
so script stop at: public SaveLider
here is that callback:
and here is againg code with debug:
so sometimes, my command works perfect, and sometimes i get server: unknow command,
from debug messages i see to script bugs at INI_Close so whats the problem?
Код:
CMD:makeleader(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] < 5) return NisiOvlascen(playerid); new para1, level, string[256]; new ime[MAX_PLAYER_NAME]; if(sscanf(params, "ui", para1, level)) { SCM(playerid, -1, ""SCMD"/makeleader [Korisnicki ID ili Ime igraca] [ID organizacije]"); SCM(playerid,-1,"{FFFFFF}Drzavne organizacije: {ADADAD}1. Policija| 2.FBI | 3. Taxi | 4. Bolnicari | 5. Novinari"); SCM(playerid,-1,"{FFFFFF}Bande: {ADADAD}6. Aryan Brotherhood | 7. Groove Street Families | 8. El Mexicanos"); SCM(playerid,-1,"{FFFFFF}Mafije: {ADADAD}9. Italian Syndicate | 10. Chinese Triads | 11. Bolivian Cartel"); SCM(playerid,-1,"{FFFFFF}Vlada: {ADADAD}12. Vlada |"); SCM(playerid,-1,"{FFFFFF}Podsetnik: {ADADAD}Za skidanje lidera koristiti organizaciju ID [0]."); return 1; } if(!IsPlayerConnected(para1)) return SCM(playerid, GRAD2, "Taj igrac nije na serveru!"); if(level < 0 || level > 12) return SCM(playerid, SIVA, "{07C1F5}{FFFFFF}Ne moze vise od 12 ili manje od 0!"); GetPlayerName(para1, ime, sizeof(ime)); if(level == 0) { if(PlayerInfo[para1][pLider] == 0) return SCM(playerid,GRAD2,"Taj igrac nije lider nijedne organizacije."); PlayerInfo[para1][pSkin] = 299; print("lider1"); SetPlayerSkin(para1,299); ResetPlayerWeaponsEx(para1); print("lider2"); SCMF(para1,GRAD2,"Administrator %s vam je skinuo LIDERA!",GetName(playerid)); SCM(para1,GRAD2,"Niste vise clan organizacije, sada ste civil."); SetPlayerHealth_H(para1, 0); print("lider3"); format(string,sizeof(string), "[ADMIN] ADMINISTRATOR %s je smenio igraca %s sa mesta lidera. /makeleader", GetName(playerid), GetName(para1)); ABroadCast(COLOR_YELLOW, string, 4); print("lider4"); strmid(Lider[PlayerInfo[para1][pLider]][ImeL], "Nema", 0, strlen("Nema"), 255); strmid(LiderInfo[PlayerInfo[para1][pLider]][lIme], "Nema", 0, strlen("Nema"), 255); print("lider5"); SaveLider(PlayerInfo[para1][pLider]); print("lider6"); PlayerInfo[para1][pLider] = 0; PlayerInfo[para1][pRank] = 0; PlayerInfo[para1][pClan] = 0; PlayerInfo[para1][pOrgSati] = -1; RemovePlayerAttachedObject(playerid, 7); SetPlayerColor(para1,COLOR_GRAD2); SacuvajIgraca(para1); print("lider7"); //return 1; } return 1; }
Код:
[23:56:53] lider1 [23:56:53] lider2 [23:56:53] lider3 [23:56:53] lider4 [23:56:53] lider5 [23:56:53] [debug] Run time error 4: "Array index out of bounds" [23:56:53] [debug] Accessing element at negative index -1 [23:56:53] [debug] AMX backtrace: [23:56:53] [debug] #0 000341d0 in ?? (-1) from LSRP.amx [23:56:53] [debug] #1 00526860 in ?? (2) from LSRP.amx [23:56:53] [debug] #2 004b3234 in public cmd_makeleader (0, 50578276) from LSRP.amx [23:56:53] [debug] #3 native CallLocalFunction () from samp03svr [23:56:53] [debug] #4 00037714 in ?? (0, 50578196) from LSRP.amx [23:56:53] [debug] #5 0002baf8 in public OnPlayerCommandText (0, 50578196) from LSRP.amx
here is that callback:
Код:
forward SaveLider(i); public SaveLider(i) { new textic[126]; printf("lider9"); format(textic, sizeof(textic), "organizacije/lideri/Lider_%d.ini",i); printf("lider10"); if(fexist(textic)) { printf("lider11"); new INI:File = INI_Open(textic); printf("lider12"); INI_WriteString(File, "Ime", LiderInfo[i][lIme]); printf("lider13"); INI_WriteInt(File, "ID", LiderInfo[i][lID]); printf("lider14"); INI_Close(File); printf("lider15"); } printf("lider16"); return 1; }
Код:
[01:54:19] lider9 [01:54:19] lider10 [01:54:19] lider11 [01:54:19] lider12 [01:54:19] lider13 [01:54:19] lider14 [01:54:19] [debug] Run time error 4: "Array index out of bounds" [01:54:19] [debug] Accessing element at negative index -1 [01:54:19] [debug] AMX backtrace: [01:54:19] [debug] #0 000341d0 in ?? (-1) from LSRP.amx [01:54:19] [debug] #1 00526c34 in public SaveLider (1) from LSRP.amx [01:54:19] [debug] #2 004b3e2c in public cmd_makeleader (0, 50589928) from LSRP.amx [01:54:19] [debug] #3 native CallLocalFunction () from samp03svr [01:54:19] [debug] #4 00037714 in ?? (0, 50589848) from LSRP.amx [01:54:19] [debug] #5 0002baf8 in public OnPlayerCommandText (0, 50589848) from LSRP.amx
from debug messages i see to script bugs at INI_Close so whats the problem?