18.06.2012, 12:58
(
Последний раз редактировалось Gengar; 18.06.2012 в 12:59.
Причина: pawn code
)
Okay, I started to script recently and need a little help with the /changename (I've used /setname here) command.
The idea is to actually change the name of the player completely. By that I mean, his userfiles get copied into another one with a new name. I tried my best to create it but it doesn't copy his data into a new file. Also I'm using the Y_INI system.
Please take a look at the coding and help me out. I'd be eternally grateful thanks.
The idea is to actually change the name of the player completely. By that I mean, his userfiles get copied into another one with a new name. I tried my best to create it but it doesn't copy his data into a new file. Also I'm using the Y_INI system.
Please take a look at the coding and help me out. I'd be eternally grateful thanks.
pawn Код:
COMMAND:setname(playerid, params[])
{ new oldname[125], newname[125], string[128];
GetPlayerName(playerid, oldname, sizeof(oldname));
if(sscanf(params, "s[125]", newname)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setname [new_name]");
format(string,sizeof(string),"\\Users\\%s.ini",newname);
if(fexist(string)) return SendClientMessage(playerid, COLOR_YELLOW, "Account name already exists! Please choose another name!");
else
{
new INI:File2 = INI_Open(string); new lolname[128];
if (File2 != INI_NO_FILE)
{
INI_SetTag(File2,"data");
INI_WriteInt(File2,"Password",PlayerInfo[playerid][pPass]);
INI_WriteString(File2,"PasswordOrig",stringpass);
INI_WriteInt(File2,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File2,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File2,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File2,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteFloat(File2,"X_Coord",1683.2069); //ignore the value of the coords
INI_WriteFloat(File2,"Y_Coord",1449.3086);
INI_WriteFloat(File2,"Z_Coord",10.7716);
INI_Close(File2);
}
SetPlayerName(playerid,newname);
format(lolname,sizeof(lolname)," ~ %s has changed his account name to %s", oldname, newname);
SendClientMessageToAll(COLOR_ORANGE,lolname);
fremove(UserPath(playerid));
}
return 1;
}