djSon & changename command..
#5

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
A simple note is that is not how djSon was intended to be used, it was actually intended to be used to have all of the players information stored in a single file.

Regardless, it's quite easy to change the name of that file then, all you need is to re-name the file.

Unfortunately there is no file re-naming function that comes with the SA-MP package, although there are plenty of PAWN implementations available around.

Read this great page I found for more information: http://dracoblue.net/dev/renaming-a-file-in-pawn/139/
That's an interesting page, thank you!

Well, here's my attempt at a changename command, and i'm going to go check it in-game right now. Wish me luck! :P

pawn Код:
CMD:rename(playerid, params[])
{
    if(PVar[playerid][pLevel] >= 4)
    {
        new Player, newname[MAX_PLAYER_NAME], string[128], File[50];
       
        if(!sscanf(params, "us[MAX_PLAYER_NAME]", Player, newname))
        {
       
            format(string, sizeof(string), "%s.json", newname);
            djCreateFile(string);
           
            format(File, sizeof(File), PFiles, newname);
           
            PVar[playerid][pKills]      = djInt     (File, "Kills");
            PVar[playerid][pDeaths]     = djInt     (File, "Deaths");
            PVar[playerid][pLevel]      = djInt     (File, "Level");
            PVar[playerid][pMuted]      = djInt     (File, "Muted");
            PVar[playerid][pCash]       = djInt     (File, "Cash");
            PVar[playerid][pSkin]       = djInt     (File, "Skin");
            PVar[playerid][pUseSkin]    = djInt     (File, "UseSkin");
            format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
           
            format(string, sizeof(string), "%s.json", pName(playerid));
            djRemoveFile(string);
           
            SetPlayerName(playerid, newname);
       
        }
    }
    return 1;
}
EDIT: It worked other than one major problem.. The statistics did not transfer over (PVar[playerid][pKills] = djInt (File, "Kills"); <-- that part).. Any synopsis on what could be wrong?
Reply


Messages In This Thread
djSon & changename command.. - by Skylar Paul - 01.07.2011, 16:11
Re: djSon & changename command.. - by JaTochNietDan - 01.07.2011, 16:15
Re: djSon & changename command.. - by Skylar Paul - 01.07.2011, 16:28
Re: djSon & changename command.. - by JaTochNietDan - 01.07.2011, 16:37
Re: djSon & changename command.. - by Skylar Paul - 01.07.2011, 16:43
Re: djSon & changename command.. - by JaTochNietDan - 01.07.2011, 17:02
Re: djSon & changename command.. - by Skylar Paul - 01.07.2011, 17:11
Re: djSon & changename command.. - by JaTochNietDan - 01.07.2011, 17:15
Re: djSon & changename command.. - by Skylar Paul - 01.07.2011, 17:31
Re: djSon & changename command.. - by Calgon - 01.07.2011, 17:43

Forum Jump:


Users browsing this thread: 1 Guest(s)