10.04.2011, 19:01
If he changes the name thats registered in the database, i want it to send a message saying that name is already registered!, but it wont it just says name successfuly changed. Why?
pawn Код:
if(dialogid == 4383)
{
new newname[MAX_PLAYER_NAME],oldname[MAX_PLAYER_NAME];
if(!response) return 0;
if(sscanf(inputtext,"s",newname)) return SendClientMessage(playerid,red,"Please put in a username");
GetPlayerName(playerid,oldname,sizeof(oldname));
format(Query,sizeof(Query),"SELECT FROM `Accounts` WHERE `Username` = '%s'",newname);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() >= 1)
{
SendClientMessage(playerid,red,"ERROR: "lgrey"This username is already registered!");
return 0;
}
else
{
format(Query,sizeof(Query),"UPDATE `Accounts` SET `Username` = '%s' WHERE `Username` = '%s'",newname,oldname);
SetPlayerName(playerid,newname);
SendFMessage(playerid,red,"[SERVER]"lgrey"Your name has been changed to "lgreen"%s"lgrey"!",newname);
format(string,sizeof(string),""lred"||- "lwhite"Announcement: "lgreen"%s "lred"has change his name to "lyellow"%s "lred"-||",oldname,newname);
SendAdminMessage(red,string);
SaveIn("Adminlog",string);
}
}