File name change
#1

Hey all. How can I make it that when someone changes his name ingame his dini file will be editted to that name as well?

I create a player file like this:
pawn Код:
new INI:File = INI_Open(UserPath(playerid));
Now how can I make it that the file name changes if the player name changes?
Reply
#2

i dont know if you can rename the file when the player's name is chagne but what i know is that
you can delete his old file and make a new one with all his saved data
Reply
#3

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
i dont know if you can rename the file when the player's name is chagne but what i know is that
you can delete his old file and make a new one with all his saved data
Could you explain me how to delete the old file and make the new file with the stats?
Reply
#4

You can delete a file by using the function 'fremove'.
When you change his/her name with the command, store everythign that is inside the file in variables. After that delete his/her file, change his/her name, create a new file and save the variables inside the file.
If you need more info, or a small snippet, just post here or pm me
Reply
#5

I attempted to make a remove file command to see if it works.

pawn Код:
COMMAND:remove(playerid,params[])
{
    GetPlayerName(playerid, Name, sizeof(Name));
    fremove(Name);
    return 1;
}
This didn't work.
Reply
#6

Thats because you have to define the WHOLE path.

pawn Код:
COMMAND:remove(playerid,params[])
{
    new Name[24], file[50];
    GetPlayerName( playerid, Name, sizeof Name );
    format( file, sizeof file, "RegisterSystem/Users/%s.ini", Name );
    fremove( file );
    return 1;
}
Reply
#7

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
Thats because you have to define the WHOLE path.

pawn Код:
COMMAND:remove(playerid,params[])
{
    new Name[24], file[50];
    GetPlayerName( playerid, Name, sizeof Name );
    format( file, sizeof file, "RegisterSystem/Users/%s.ini", Name );
    fremove( file );
    return 1;
}
It worked Thanks. NO I'll try to make the other parts.
Reply
#8

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
Thats because you have to define the WHOLE path.

pawn Код:
COMMAND:remove(playerid,params[])
{
    new Name[24], file[50];
    GetPlayerName( playerid, Name, sizeof Name );
    format( file, sizeof file, "RegisterSystem/Users/%s.ini", Name );
    fremove( file );
    return 1;
}
Hmm, I'm screwing it up xD PLease let me PM youy my script
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)