MySQL name change
#1

Removed
Reply
#2

DUMP
Reply
#3

Quote:
Originally Posted by The Forum Rules
You may only bump your thread after 24 hours has passed since the last reply.
Anyways, Is it a MySQL R7 or a R6 type script?
Reply
#4

I've copied this from my previous gamemodes should help you meant to be an admin command though

pawn Код:
CMD:changename(playerid,params[])
{
    new targetid,newname[24],reason[105];
    if(sscanf(params, "ds[24]s[105]",targetid,newname,reason)) return SendClientMessage(playerid,-1," /changename [ID] [New Name] [Reason]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1," Player is not online");

    new escapename[24], Query[128];
    mysql_real_escape_string(newname, escapename);
    format(Query, sizeof(Query), "SELECT `user` FROM `yourdatabase` WHERE `user` = '%s' LIMIT 1", escapename);
    mysql_query(Query);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(!rows)
    {
        format(Query, sizeof(Query), "UPDATE `yourdatabase` SET `user`= '%s' WHERE `user` ='%s'",escapename,PlayerName(targetid));
        mysql_query(Query);
        SetPlayerName(targetid,escapename);
        format(zmstring,sizeof(zmstring)," Admin %s changed your name to %s [Reason: %s]",PlayerName(playerid),newname, reason);
        SendClientMessage(targetid,-1,zmstring);
        format(zmstring,sizeof(zmstring)," You've changed ID %d name to %s [Reason: %s]",targetid, PlayerName(targetid), reason);
        SendClientMessage(playerid,-1,zmstring);
    }
    else if(rows == 1)
    {
        SendClientMessage(playerid, -1, " This name already exists!");
    }
    mysql_free_result();
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)