01.07.2011, 16:43
Quote:
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/ |
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;
}