SA-MP Forums Archive
Change player name? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Change player name? (/showthread.php?tid=143661)



Change player name? - ruckfules99 - 23.04.2010

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;

}



Re: Change player name? - Donuts - 23.04.2010

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.


Re: Change player name? - ruckfules99 - 24.04.2010

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


Re: Change player name? - Calgon - 24.04.2010

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).


Re: Change player name? - ruckfules99 - 24.04.2010

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?




Re: Change player name? - Calgon - 24.04.2010

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




Re: Change player name? - ruckfules99 - 24.04.2010

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.


Re: Change player name? - M4S7ERMIND - 24.04.2010

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



Re: Change player name? - ruckfules99 - 24.04.2010

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.