Changename mysql [+REP]
#1

i make a CMD change player name but i got 2 problems

the name doesn't change ingame and doesn't save in mysql DB plz help

pawn Код:
CMD:setname(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new id, name[24], str[130], query[1200], newname[24];
        if(sscanf(params, "ds", id,newname)) return SendClientMessage(playerid,COLOR_WHITE,"/SetName [Playerid] [New Name]");
        {
        GetPlayerName(id,name,24);
        format(str,130,"You Changed %s (%d)'s Name to %s",name,id,newname);
        SendClientMessage(playerid,COLOR_BLUE,str);
        format(str,130, "Admin Changed Your Name to %s",newname);
        format(query, sizeof(query), "UPDATE 'players' SET Username='%s' WHERE Username='%s'",newname,name);
        mysql_tquery(mysql, query);
        SendClientMessage(playerid,COLOR_BLUE,str);
        SetPlayerName(id,newname,24);
        }
    } else return SendClientMessage(playerid,COLOR_RED,"Your Level Is Not High Enough To Use This Command");
    return 1;
}

sorry for my bad english
thanks
Reply
#2

help plz
Reply
#3

Quote:

format(query, sizeof(query), "UPDATE 'players' SET Username='%s' WHERE Username='%s'",newname,name);

recheck this format and when it fix it automatically save ur username
Reply
#4

Quote:
Originally Posted by Humza
Посмотреть сообщение
recheck this format and when it fix it automatically save ur username
explain more plz
Reply
#5

if(sscanf(params, "ds[24]", id,newname)) - Try that.
Reply
#6

Quote:
Originally Posted by simo0000
Посмотреть сообщение
help plz
Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
if(sscanf(params, "ds[24]", id,newname)) - Try that.
same problem :/ plz help
Reply
#7

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
if(sscanf(params, "ds[24]", id,newname)) - Try that.
and i get sscanf error: SSCANF_SetPlayerName has incorrect parameters.
Reply
#8

use mysql_format insteed of format and also you are using setplayername wrong there is 2 parameters not 3 , do not use only s in sscanf becoz it is for strings you need to define size too

pawn Код:
CMD:setname(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new id, name[24], str[130], query[200], newname[24];
        if(sscanf(params, "ds[24]", id,newname)) return     SendClientMessage(playerid,COLOR_WHITE,"/SetName [Playerid] [New Name]");
        {
            GetPlayerName(id,name,24);
        format(str,sizeof(str),"You Changed %s (%d)'s Name to %s",name,id,newname);
        SendClientMessage(playerid,COLOR_BLUE,str);
        format(str,sizeof(str), "Admin Changed Your Name to %s",newname);
        mysql_format(mysql,query, sizeof(query), "UPDATE 'players' SET Username='%s' WHERE Username='%s'",newname,name);
        mysql_tquery(mysql, query,"", "");
        SendClientMessage(playerid,COLOR_BLUE,str);
        SetPlayerName(id,newname);
        }
    } else return SendClientMessage(playerid,COLOR_RED,"Your Level Is Not High Enough To Use This Command");
    return 1;
}
Reply
#9

Quote:
Originally Posted by simo0000
Посмотреть сообщение
and i get sscanf error: SSCANF_SetPlayerName has incorrect parameters.
Currently in your code, you have 3 parmaters in "SetPlayerName" even though it only has 2 parmaters.

Example:
SetPlayerName(playerid, newname);

https://sampwiki.blast.hk/wiki/SetPlayerName

Does it save in the database now? If so, We're making progress. If not, I suggest debugging your code.
Reply
#10

Quote:
Originally Posted by Sledgehammer
Посмотреть сообщение
Currently in your code, you have 3 parmaters in "SetPlayerName" even though it only has 2 parmaters.

Example:
SetPlayerName(playerid, newname);

https://sampwiki.blast.hk/wiki/SetPlayerName

Does it save in the database now? If so, We're making progress. If not, I suggest debugging your code.
this is mysql log last 2 lines

[17:16:49] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE 'players' SET Username='Farid_OConnor' WHERE Username='Mar", callback: "R", format: "v"
[17:16:49] [ERROR] mysql_tquery - callback parameter count does not match format specifier length
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)