Code:
if (strcmp(cmd, "/register", true)==0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]");
return 1;
}
if (gPlayerAccount[playerid] == 1)
{
SendClientMessage(playerid, COLOR_GREY, "That name is already registered");
return 1;
}
strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "accounts/%s.ini", playername);
new File: file = fopen(string, io_read);
if (file)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "That name is already registered");
fclose(file);
return 1;
}
new File:hFile;
hFile = fopen(string, io_append);
new var[32];//
format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
format(var, 32, "Admin Level=%d\n", PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 32, "Needs Greeter Help=%d\n", PlayerInfo[playerid][pHelp]);fwrite(hFile, var);
format(var, 32, "Greeter Duty=%d\n", PlayerInfo[playerid][pDuty]);fwrite(hFile, var);
format(var, 32, "Greeter Level=%d\n", PlayerInfo[playerid][pGreeter]);fwrite(hFile, var);
format(var, 32, "Police Rank=%d\n", PlayerInfo[playerid][pCop]);fwrite(hFile, var);
format(var, 32, "Medic Rank=%d\n", PlayerInfo[playerid][pMedic]);fwrite(hFile, var);
format(var, 32, "Agent Rank%d\n", PlayerInfo[playerid][pAgent]);fwrite(hFile, var);
format(var, 32, "Presidential Security=%d\n", PlayerInfo[playerid][pPS]);fwrite(hFile, var);
format(var, 32, "On Duty=%d\n", PlayerInfo[playerid][pDuty]);fwrite(hFile, var);
format(var, 32, "In Jail=%d\n", PlayerInfo[playerid][pJail]);fwrite(hFile, var);
format(var, 32, "Drivers License=%d\n", PlayerInfo[playerid][pLicense]);fwrite(hFile, var);
format(var, 32, "Passport=%d\n", PlayerInfo[playerid][pPassport]);fwrite(hFile, var);
format(var, 32, "Muted=%d\n", PlayerInfo[playerid][pMute]);fwrite(hFile, var);
format(var, 32, "Skin=%d\n", PlayerInfo[playerid][pSkin]);fwrite(hFile, var);
format(var, 32, "Duty Skin=%d\n", PlayerInfo[playerid][pDutySkin]);fwrite(hFile, var);
format(var, 32, "Wanted=%d\n", PlayerInfo[playerid][pWanted]);fwrite(hFile, var);
format(var, 32, "Car=%d\n", PlayerInfo[playerid][pCar]);fwrite(hFile, var);
format(var, 32, "Car Locked or Unlocked=%d\n", PlayerInfo[playerid][pCarLocked]);fwrite(hFile, var);
format(var, 32, "News Rank=%d\n", PlayerInfo[playerid][pNewsRank]);fwrite(hFile, var);
format(var, 32, "Interior=%d\n", PlayerInfo[playerid][pInterior]);fwrite(hFile, var);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
fclose(hFile);
SendClientMessage(playerid, COLOR_LIGHTGREEN, "Succesfully Registered!");
SendClientMessage(playerid, COLOR_WHITE, "Next time you connect, type /login <password> to log in.");
SpawnPlayer(playerid);
OnPlayerLogin(playerid,PlayerInfo[playerid][pPassword]);
return 1;
}
Thats my basic registration script.
Code:
public OnPlayerUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
new string3[32];
new pname3[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname3, sizeof(pname3));
format(string3, sizeof(string3), "accounts/%s.ini", pname3);
new File: pFile = fopen(string3, io_write);
if (pFile)
{
new var[32];
format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
fclose(pFile);
new File: hFile = fopen(string3, io_append);
format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
format(var, 32, "Admin Level=%d\n", PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
format(var, 32, "Needs Greeter Help=%d\n", PlayerInfo[playerid][pHelp]);fwrite(hFile, var);
format(var, 32, "Greeter Duty=%d\n", PlayerInfo[playerid][pDuty]);fwrite(hFile, var);
format(var, 32, "Greeter Level=%d\n", PlayerInfo[playerid][pGreeter]);fwrite(hFile, var);
format(var, 32, "Police Rank=%d\n", PlayerInfo[playerid][pCop]);fwrite(hFile, var);
format(var, 32, "Medic Rank=%d\n", PlayerInfo[playerid][pMedic]);fwrite(hFile, var);
format(var, 32, "Agent Rank%d\n", PlayerInfo[playerid][pAgent]);fwrite(hFile, var);
format(var, 32, "Presidential Security=%d\n", PlayerInfo[playerid][pPS]);fwrite(hFile, var);
format(var, 32, "On Duty=%d\n", PlayerInfo[playerid][pDuty]);fwrite(hFile, var);
format(var, 32, "In Jail=%d\n", PlayerInfo[playerid][pJail]);fwrite(hFile, var);
format(var, 32, "Drivers License=%d\n", PlayerInfo[playerid][pLicense]);fwrite(hFile, var);
format(var, 32, "Passport=%d\n", PlayerInfo[playerid][pPassport]);fwrite(hFile, var);
format(var, 32, "Muted=%d\n", PlayerInfo[playerid][pMute]);fwrite(hFile, var);
format(var, 32, "Skin=%d\n", PlayerInfo[playerid][pSkin]);fwrite(hFile, var);
format(var, 32, "Duty Skin=%d\n", PlayerInfo[playerid][pDutySkin]);fwrite(hFile, var);
format(var, 32, "Wanted=%d\n", PlayerInfo[playerid][pWanted]);fwrite(hFile, var);
format(var, 32, "Car=%d\n", PlayerInfo[playerid][pCar]);fwrite(hFile, var);
format(var, 32, "Car Locked or Unlocked=%d\n", PlayerInfo[playerid][pCarLocked]);fwrite(hFile, var);
format(var, 32, "News Rank=%d\n", PlayerInfo[playerid][pNewsRank]);fwrite(hFile, var);
format(var, 32, "Interview=%d\n", PlayerInfo[playerid][pInterview]);fwrite(hFile, var);
format(var, 32, "Interior=%d\n", PlayerInfo[playerid][pInterior]);fwrite(hFile, var);
PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
fclose(hFile);
}
}
}
return 1;
}
That is my ONPLAYERUPDATE...
They are both closed perfectly...
it remembers the player...just not the admin for some reason.