29.10.2014, 12:21
Can somebody tell me what is wrong with this, i can change players name into other players name even tought that name already exist in database.
pawn Код:
CMD:changename(playerid, params[])
{
if(Ulogovan[playerid] == 0) return SCM(playerid, GREY, "Morate se prvo prijaviti.");
if(PI[playerid][Admin] < 6) return SCM(playerid, GREY, "Nemate ovlastenje za koristenje ove komande.");
new id, ime[MAX_PLAYER_NAME], query[128];
if(sscanf(params, "us[MAX_PLAYER_NAME]", id, ime)) return SCM(playerid, GREY, "Koristite: /changename [ID Igraca / Deo Imena] [Novo Ime]");
if(!IsPlayerConnected(id)) return SCM(playerid, GREY, "Taj igrac nije online.");
if(strlen(ime) < 6 || strlen(ime) > 26) return SCM(playerid, GREY, "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, "OnQueryFinish", "ii", THREAD_OSTALO, id);
new szRows, szFields;
cache_get_data(szRows, szFields);
if(!szRows)
{
format(query, sizeof(query), "UPDATE `Igraci` SET `Ime` = '%s' WHERE `Ime` = '%s'", ime, GetName(id));
mysql_function_query(konekt, query, true, "OnQueryFinish", "ii", THREAD_OSTALO, id);
SCMF(id, DBLUE, "%s has changed your name to %s.", GetName(playerid), ime);
SCMF(playerid, TOMATO, "[NAME CHANGE] You have changed %s name to %s.", GetName(id), ime);
SetPlayerName(playerid, ime);
}
else
{
SCMF(playerid, TOMATO, "[NAME CHANGE] %s user with this name already exist.", ime);
}
return 1;
}