MySQL Some Warnings
#1

fixxed.
Reply
#2

In your command, /changename, you need to SELECT a name from your database and specify a callback in which if cache_num_rows > 1 NAME IS REGISTERED, else the name is not registered and then you can UPDATE his name in database
Reply
#3

hmm, can't you edit my code ? pls xd :3
Reply
#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
#5

Thanks, +REP :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)