mysql /changename cmd bug?
#7

pawn Код:
dcmd_changename(playerid,params[])
{
    if(Spieler[playerid][AdminLevel] > 2)
    {
        new pID,pname[24],newname[24];
        if(sscanf(params, "ds[24]",pID,newname))return SendClientMessage(playerid,0xFF0000FF,"Usage: /changename [ID][New Name]");
        if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid,0xFF0000FF,"This PlayerId is invalid!");

        GetPlayerName(pID,pname,24);
        new query1[256],escapename[24];
        mysql_real_escape_string(newname, escapename);
        format(query1, sizeof(query1), "SELECT `name` FROM `Users` WHERE `name` = '%s' LIMIT 1", escapename);
        mysql_query(query1);
        mysql_store_result();
        new rows = mysql_num_rows();
        if(!rows)
        {
            new query[256];
            format(query, sizeof(query), "UPDATE `Users` SET `name`= '%s' WHERE `name` ='%s'",escapename,pname);
            mysql_query(query);
            SetPlayerName(pID,escapename);
            new levelsetter[MAX_PLAYER_NAME],adminstring[128];
            GetPlayerName(playerid,levelsetter,sizeof(levelsetter));
            format(adminstring,sizeof(adminstring),"Admin * %s * has changed your name to %s!",levelsetter, newname);
            SendClientMessage(pID,0xFF0000FF, adminstring);
            SendClientMessage(playerid, 0xFF0000FF, "You have changed the name successfully.");
        }
        else if(rows == 1)
        {
            SendClientMessage(playerid, 0xFF0000FF, "This name already exists!");
        }
        mysql_free_result();
    }
    else return SendClientMessage(playerid, 0xFF0000FF, "You don't have permission to use this command!");
    return 1;
}
I guess this should do it.
(Fixed your indention as well^^)

Jeffry
Reply


Messages In This Thread
mysql /changename cmd bug? - by BlackWolf120 - 04.09.2011, 01:13
Re: mysql /changename cmd bug? - by [HiC]TheKiller - 04.09.2011, 01:20
Re: mysql /changename cmd bug? - by BlackWolf120 - 04.09.2011, 01:32
Re: mysql /changename cmd bug? - by =WoR=Varth - 04.09.2011, 11:30
Re: mysql /changename cmd bug? - by Hiddos - 04.09.2011, 11:35
Re: mysql /changename cmd bug? - by Vince - 04.09.2011, 11:41
Re: mysql /changename cmd bug? - by Jeffry - 04.09.2011, 16:13
Re: mysql /changename cmd bug? - by BlackWolf120 - 04.09.2011, 16:24

Forum Jump:


Users browsing this thread: 1 Guest(s)