23.06.2015, 19:31
Something about this is giving me these errors:
Errors:
[21:27:58] [debug] Run time error 4: "Array index out of bounds"
[21:27:58] [debug] Accessing element at negative index -1
[21:27:58] [debug] AMX backtrace:
[21:27:58] [debug] #0 000d4f84 in ?? (0xffffffff) from rpfa.amx
[21:27:58] [debug] #1 000d8210 in public ChangeName (0x00000000, 0x00000000, 0x0126ba04) from rpfa.amx
pawn Код:
CMD:changename(playerid, params[])
{
if(PI[playerid][Admin] < 6) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Niste ovlasteni za koristenje ove komande.");
new id, ime[26], query[128];
if(sscanf(params, "us[26]", id, ime)) return SCM(playerid, WHITE, "Koristite: /changename [ID Igraca / Deo Imena] [Novo Ime]");
if(!IsPlayerConnected(id)) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Taj igrac nije online.");
if(strlen(ime) < 6 || strlen(ime) > 26) return SCM(playerid, TOMATO, "[RPF] {FFFFFF}Ime mora da sadrzi minimalno 6 a maksimalno 26 karaktera.");
format(query, sizeof(query), "SELECT `Ime` FROM `Igraci` WHERE `Ime` = '%s'", ime);
mysql_function_query(konekt, query, true, "ChangeName", "iis", playerid, id, ime);
return 1;
}
pawn Код:
public ChangeName(playerid, id, name[])
{
new szRows, szFields, query[178];
cache_get_data(szRows, szFields);
if(!szRows)
{
if(PI[playerid][Kuca] != -1) strmid(HInfo[PI[id][Kuca]][Vlasnik], name, 0, strlen(name), 255); PostaviKucneLabele(PI[id][Kuca]);
format(query, sizeof(query), "UPDATE `Igraci` SET `Ime` = '%s' WHERE `Ime` = '%s'", name, ImeIgraca(id));
mysql_function_query(konekt, query, true, "OnQueryFinish", "ii", THREAD_OSTALO, id);
format(query, sizeof(query), "UPDATE `Kuce` SET `Vlasnik` = '%s' WHERE `ID` = '%d'", name, PI[id][Kuca]);
mysql_function_query(konekt, query, true, "OnQueryFinish", "ii", THREAD_OSTALO, id);
SCMF(playerid, TOMATO, "[RPF] {FFFFFF}Ime igraca {00C0FF}%s {FFFFFF}je promenjeno u {00C0FF}%s.", ImeIgraca(id), name);
SCMF(id, YELLOW, "[RPF] {FFFFFF}Staff %s vam je promenio ime u %s.", ImeIgraca(playerid), name);
SetPlayerName(id, name);
}
else
{
SCMF(playerid, GREY, "Racun pod imenom '%s' vec postoji.", name);
}
return 1;
}
Errors:
[21:27:58] [debug] Run time error 4: "Array index out of bounds"
[21:27:58] [debug] Accessing element at negative index -1
[21:27:58] [debug] AMX backtrace:
[21:27:58] [debug] #0 000d4f84 in ?? (0xffffffff) from rpfa.amx
[21:27:58] [debug] #1 000d8210 in public ChangeName (0x00000000, 0x00000000, 0x0126ba04) from rpfa.amx