MySQL Some Warnings
#4

Well, sure

pawn Код:
CMD:namechange(playerid,params[])
{
    if(!Logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "You need to be logged in, to use this command");
    if(IsSpawn[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You need to be spawned, to use this command");
    if(PlayerInfo[playerid][pAdminLevel] >= 9)
    {
   
        new targetid, newname[MAX_PLAYER_NAME], query[128];
        if(sscanf(params, "us[24]", targetid, newname)) return SendClientMessage(playerid,COLOR_GREY,"Syntax: /changename [playerid] [NewName]");
        mysql_format(MySQLHandle, Query, sizeof(Query), "SELECT Username FROM players WHERE Username = '%s' LIMIT 1", newname);
        mysql_tquery(MySQLHandle, Query, "ChangePlayerName", "iis", playerid, targetid, newname);
    }
    else SendClientMessage(playerid,COLOR_RED,"You do not have the right admin permissions for this command!");
    return 1;
}
       
forward ChangePlayerName(playerid, id, newplayername[]);
public ChangePlayerName(playerid, id, newplayername[])
{
    if(cache_num_rows()) return SendClientMessage(playerid, COLOR_RED, "Name is already being used!");
    new Query[128], string[128];
    mysql_format(MySQLHandle, Query, sizeof(Query), "UPDATE players SET Username  = '%e' WHERE Username  = '%s'", newplayername, PlayerName(id));
    mysql_tquery(MySQLHandle, Query);
    format(string, sizeof(string), "%s %s(%d) has changed %s(%d)'s name to %s!", AdminLevelName(playerid), PlayerName(playerid), playerid, PlayerName(id), id, newplayername);
    SendClientMessageToAll(COLOR_RED, string);
    SetPlayerName(id, newplayername);
    return 1;
}
Reply


Messages In This Thread
MySQL Some Warnings - by ReD_HunTeR - 10.02.2015, 16:46
Re: MySQL Some Warnings - by Sime30 - 10.02.2015, 17:05
Re: MySQL Some Warnings - by ReD_HunTeR - 10.02.2015, 17:53
Re: MySQL Some Warnings - by Sime30 - 10.02.2015, 18:05
Re: MySQL Some Warnings - by ReD_HunTeR - 10.02.2015, 18:17

Forum Jump:


Users browsing this thread: 1 Guest(s)