djSon & changename command..
#9

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Try to do some simple debugging.

pawn Код:
CMD:rename(playerid, params[])
{
    if(PVar[playerid][pLevel] >= 4)
    {
        new Player, newname[32], string[128], File[85];

        if(!sscanf(params, "us[32]", Player, newname))
        {

            format(File, sizeof(File), PFiles, newname);
            if(!fexist(File))
            {

                format(File, sizeof(File), PFiles, pName(playerid));

                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", newname);
                djCreateFile(string);
               
                format(File, sizeof(File), PFiles, newname);

                printf("File: %s", File);
               
                djSetInt        (File, "Kills",     PVar[playerid][pKills]);
                djSetInt        (File, "Deaths",    PVar[playerid][pDeaths]);
                djSetInt        (File, "Level",     PVar[playerid][pLevel]);
                djSetInt        (File, "Cash",      PVar[playerid][pCash]);
                djSetInt        (File, "Muted",     PVar[playerid][pMuted]);
                djSetInt        (File, "Skin",      PVar[playerid][pSkin]);
                djSetInt        (File, "UseSkin",   PVar[playerid][pUseSkin]);
                djSet           (File, "MutedReason", PVar[playerid][pMutedReason]);

                format(string, sizeof(string), "%s.json", pName(playerid));
                djRemoveFile(string);

                SetPlayerName(playerid, newname);
               
            }
            else return SendClientMessage(playerid, COLOR_RED, "File already exists!");

        }
        else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /rename < Player ID > < New Name >");
    }
    else return AdminCMD(playerid, 4);
    return 1;
}
Also do you happen to be using dutils? There is a file re-name function in there that would make all of this a lot easier, it would all boil down to one function in fact.
No, uhh.. Could you help me out as to explaining what that is?

Quote:

[19:35:05] K: 0, D: 0, Level: 5, Money: $0 [before]
[19:35:05] File: PFiles/Sky7.json
[19:35:05] K: 0, D: 0, Level: 5, Money: $0 [after]
[19:35:05] [nick] Sky6 nick changed to Sky7

Something's not right. :3
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: 3 Guest(s)