changename cmd y_ini system problem
#1

I Want to make a cmd with zcmd to change players name
and i want it to move all players data to a new file ...
i want that to save money , score and ... in new profile
actually i want to know how can i do something to change a y_ini file Name ! ( User Profile )
Help Me Please
Reply
#2

I have this;
pawn Код:
CMD:changename(playerid, params[]) {
    new string[84], newname[24], password[40], pName[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pLoggedIn] == 0) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You need to be logged in to use this command!");
    if(GetPlayerCash(playerid) < 20000) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You need 20'000$ to change your name!");
    if(sscanf(params, "s[24]s[40]", newname, password)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}/changename [NewName] [YourPassword]");
    if(udb_hash(password) != PlayerInfo[playerid][pPass]) return SendClientMessage(playerid, COLOR_RED, "* Incorrect password - Password doesn't match!");
   
    GetPlayerName(playerid, pName, sizeof(pName));
    if(strcmp(newname, pName) == 0) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}You already have that name..");
   
    format(string, sizeof(string), "/Users/%s.ini", newname);
    if(fexist(string)) return SendClientMessage(playerid, -1, "{FFFFFF}* {00C0FF}That user-name already exists!");
   
    else
    {
        /*new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"Name-Change info");
        INI_WriteString(File,"Previous Name", pName);
        INI_WriteString(File,"New Name", newname);
        INI_Close(File);*/

       
        format(string, sizeof(string), "/Users/%s.ini", pName);
        fremove(string); //Deletes the old name

        format(string, sizeof(string), "[NOTE] - %s[%d] changed his name to %s", pName, playerid, newname);
        SendMessageToAdmins(COLOR_YELLOW,string);

        format(string, sizeof(string), "* Your name has been changed to %s!", newname);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        format(string, sizeof(string), "* Password reminder: %s", password);
        SendClientMessage(playerid, -1, string);
        printf("%s has changed his name to %s | Password: %s", pName, newname, password);

        GivePlayerCash(playerid, -20000);
        GetPlayerIp(playerid, ppIP[playerid], 16);

        format(string, sizeof(string), "%s", newname);
        SetPlayerName(playerid, string);

        new INI:File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
                //All of your stats/data here
            INI_Close(File);
    }
    return 1;
}
Reply
#3

use this stock
pawn Код:
stock frename(oldname[], newname[])
{
    if (!fexist(oldname)) return 0;
    new File:oldfile = fopen(oldname, io_read);
    new File:newfile = fopen(newname, io_write);
    new line[256];
    while (fread(oldfile, line))
    {
        fwrite(newfile, line);
    }
    fclose(oldfile);
    fclose(newfile);
    fremove(oldname);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)