[HELP] Changename with MySQL +REP1
#9

pawn Код:
CMD:changename(playerid, params[]) {
    if(isnull(params)) {
        return SendClientMessage(playerid, -1, "/changename [newname]");
    }

    if(strlen(params) > MAX_PLAYER_NAME) {
        return SendClientMessage(playerid, -1, "Your name must contain a maximum of 24 characters.");
    }

    new current[MAX_PLAYER_NAME];
    GetPlayerName(playerid, current, sizeof current);

    if(!strcmp(current, params, false)) {
        return SendClientMessage(playerid, -1, "That's already your name!");
    }

    new query[128];
    mysql_format(mysql, query, sizeof query, "SELECT * FROM `players` WHERE `Username` = '%s'", params);
    mysql_tquery(mysql, query, "ChangeName", "is", playerid, params);
    return 1;
}



forward ChangeName(playerid, newname[]);
public ChangeName(playerid, newname[]) {
    if(cache_get_row_count(mysql)) {
        return SendClientMessage(playerid, -1, "This name is already in use!");
    }

    new current[MAX_PLAYER_NAME];
    GetPlayerName(playerid, current, sizeof current);

    new query[128];
    mysql_format(mysql, query, sizeof query, "UPDATE `players` SET `Username` = '%s' WHERE `Username` = '%s'", newname, current);
    mysql_tquery(mysql, query);

    SetPlayerName(playerid, newname);
    return 1;
}
Reply


Messages In This Thread
[HELP] Changename with MySQL +REP1 - by VenomMancer - 02.02.2015, 10:35
Re: [HELP] Changename with MySQL +REP1 - by BroZeus - 02.02.2015, 11:22
Re: [HELP] Changename with MySQL +REP1 - by VenomMancer - 02.02.2015, 12:30
Re : [HELP] Changename with MySQL +REP1 - by Dutheil - 02.02.2015, 12:40
Re: [HELP] Changename with MySQL +REP1 - by VenomMancer - 02.02.2015, 14:14
Re: [HELP] Changename with MySQL +REP1 - by VenomMancer - 02.02.2015, 22:57
Re: [HELP] Changename with MySQL +REP1 - by Sime30 - 02.02.2015, 23:08
Re: [HELP] Changename with MySQL +REP1 - by VenomMancer - 02.02.2015, 23:38
Re: [HELP] Changename with MySQL +REP1 - by zPain - 03.02.2015, 01:31
Re: [HELP] Changename with MySQL +REP1 - by VenomMancer - 03.02.2015, 12:55

Forum Jump:


Users browsing this thread: 1 Guest(s)