[HELP]Change Name.
#1

I have this command:

Код:
	if(strcmp(cmd, "/changename", true) == 0)
    {
      	if(IsPlayerConnected(playerid))
      {
        	tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if (PlayerInfo[playerid][pAdmin] >= 4)
            {
              if(IsPlayerConnected(giveplayerid))
              {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                        new length = strlen(cmdtext);
                        while ((idx < length) && (cmdtext[idx] <= ' '))
                        {
                            idx++;
                        }
                        new offset = idx;
                        new result[64];
                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                        {
                            result[idx - offset] = cmdtext[idx];
                            idx++;
                        }
                        result[idx - offset] = EOS;
                        if(!strlen(result))
                        {
                            SendClientMessage(playerid, COLOR_GRAD2, "[USAGE]: /changename [id] [newname]");
                            return 1;
                        }
                        SetPlayerName(giveplayerid, (result));
                        return 1;
                    }
                }
            }
        }
        return 1;
    }
But is a problem, after relog, or server restart, the new name doesn't save in MySQL. How can i save the new name in MySQL DataBase?
Reply
#2

Its not that it doesnt save, but surely you will have to change your name on the client aswell, as that is what you connect with and initialize the game with.
Reply
#3

Yes, but i want to save the name.. How can i do? I need a function .. something like MysqlAccountUpdate().. I don`t know
Reply
#4

Someone ..?
Reply
#5

Helppp xD.
Reply
#6

Help me xD.
Reply
#7

Just use mysql query:"UPDATE players SET Username='%s' where ID=%d",VARIABLE_WHERE_THE_NEW_NAME_IS_SAVED, SQL_ID
Reply
#8

srsly dude, you are having this one command while you clearly don't know anything about mysql... do you even have a database? do you even have a plugin? is your gamemode mysql based and in order? if you do... you know how to update and process a mysql query...

http://forum.sa-mp.com/showthread.ph...ighlight=mysql

https://sampwiki.blast.hk/wiki/MySQL_Plugin
Reply
#9

I don't know what database structure you are using but.

Add this before SetPlayerName():
pawn Код:
new
    query[128];
format(query, sizeof(query), "UPDATE `players` SET `name` = '%s' WHERE `name` = '%s';", result, giveplayer);
mysql_query(query);
Change players, and name to whatever suits your structure.
Reply
#10

Quote:
Originally Posted by _rAped
Посмотреть сообщение
I don't know what database structure you are using but.

Add this before SetPlayerName():
pawn Код:
new
    query[128];
format(query, sizeof(query), "UPDATE `players` SET `name` = '%s' WHERE `name` = '%s';", result, giveplayer);
mysql_query(query);
Change players, and name to whatever suits your structure.
This is the correct form: samp_mysql_query(query);


RESOLVED !

Help me with these problems: https://sampforum.blast.hk/showthread.php?tid=208516&page=2
https://sampforum.blast.hk/showthread.php?tid=207996

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)