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;
}
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
|
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;
}
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. |