Change player name?
#1

I need help with a /changename command. I want the player to able to change their name IG so it changes the name of their .sav file as well. I don't know how to come about doing that. I use Dudb
Код:
dcmd_register(playerid,params[])
{

  new plrip[128];
  GetPlayerIp(playerid,plrip,sizeof(plrip));

  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are already logged into your account");

  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"This name is registered, please use /login password to log in.");

  if (RegisterLoginDisabled == 1337) return SystemMsg(playerid,"New Account Registrations are Disabled. This is due to maintenance");

  if (strlen(params)==0) return SystemMsg(playerid,"Use: /register password to create a new account");

  if (udb_Create(PlayerName(playerid),params)) {

    dUserSetINT(PlayerName(playerid)).("money",7500);
    dUserSetINT(PlayerName(playerid)).("bankcash",5000);
    dUserSetINT(PlayerName(playerid)).("regplayer",0);
    dUserSetINT(PlayerName(playerid)).("score",0);
    dUserSetINT(PlayerName(playerid)).("adminlevel",0);
    dUserSetINT(PlayerName(playerid)).("deaths",0);
    dUserSetINT(PlayerName(playerid)).("totaljailtime",0);
    dUserSetINT(PlayerName(playerid)).("nameban",0);
    dUserSetINT(PlayerName(playerid)).("connectedminute",0);
    dUserSetINT(PlayerName(playerid)).("connectedhour",0);
    dUserSetINT(PlayerName(playerid)).("timesfuckedoff",0);
    dUserSetINT(PlayerName(playerid)).("RegularPlayer",0);
    dUserSet(PlayerName(playerid)).("ipaddress",plrip);

    return SystemMsg(playerid,"Your Account has been created. Login with /login password now to log in (Before Spawn)");

  }
  return true;

}
Reply
#2

Just create the new file of the new name and set the stats to the ones from the old name and delete the old name.
Reply
#3

Quote:
Originally Posted by YeahYeahYeahs
Just create the new file of the new name and set the stats to the ones from the old name and delete the old name.
If i do that manually then people will always be creating names and my scriptfiles folder will be filled with millions of files.


I need one that automatically edits the name
Reply
#4

The way I do it (in my current filebased script) I delete the old file, change their name, save the players data with the new name (if the file doesn't exist before saving, it's created).
Reply
#5

Quote:
Originally Posted by Freddo
The way I do it (in my current filebased script) I delete the old file, change their name, save the players data with the new name (if the file doesn't exist before saving, it's created).
can you help me with that then, if that works great?

Reply
#6

It's simple. Just use fremove( var_with_file_name ); and then where you save player data add:

pawn Код:
if( ! fexist( var_with_file_name ) )
{
dini_Create( var_with_file_name );
}

Reply
#7

Quote:
Originally Posted by Freddo
It's simple. Just use fremove( var_with_file_name ); and then where you save player data add:

pawn Код:
if( ! fexist( var_with_file_name ) )
{
dini_Create( var_with_file_name );
}

Wait, So what do i write in var_with_file_name ? Like, I wanna check if the players name is registerd, if it is, it changes the name of the file.
Reply
#8

There is rename function in dudb.inc
Код:
udb_RenameUser(nickname[], newnick[])
Reply
#9

I know what the functions are, i just have no idea how to come about doing this.


I've searched to find examples, but all posts with a /changeme command fail.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)