29.05.2014, 20:56
PHP код:
enum PlayerInfo
{
Pass[129], //User's password
Adminlevel, //User's admin level
VIPlevel, //User's vip level
Money, //User's money
Scores, //User's scores
Kills, //User's kills
Deaths //User's deaths
}
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:file = INI_Open(Path(playerid)); //will open their file
INI_SetTag(file,"Player's Data");//We will set a tag inside of user's account called "Player's Data"
INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); //If you've set his/her admin level, then his/her admin level will be saved inside of his/her account
INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_WriteInt(file,"Money",GetPlayerMoney(playerid));//We will save his money inside of his account
INI_WriteInt(file,"Scores",GetPlayerScore(playerid));//We will save his score inside of his account
INI_WriteInt(file,"Kills",pInfo[playerid][Kills]);//As explained above
INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Close(file);//Now after we've done saving their data, we now need to close the file
KillTimer(timer2);
KillTimer(timer1);
return 1;
}
public OnPlayerConnect(playerid)
{
SetPlayerColor(playerid, COLOR_DEAD);
SetPlayerMapIcon(playerid,12,1685.3970,1448.0449,10.7700,5,0); //airport
SetPlayerMapIcon(playerid,11,2207.1448,1674.9552,20.3906,25,0); // caligulas
SetPlayerMapIcon(playerid,10,2013.7827,1007.5895,39.0911,43,0); // four dragons
SetPlayerMapIcon(playerid,9,1661.2365,2241.8606,18.4302,44,0); // redsands
SetPlayerMapIcon(playerid,8,2415.6001,1123.7019,10.8203,30,0); // cityhall
SetPlayerMapIcon(playerid,7,1607.4890,1820.8252,10.8280,22,0); // hospital
SetPlayerMapIcon(playerid,6,2289.5242,2437.1992,46.9775,30,0); // LVPD
TextDrawShowForPlayer(playerid, Textdraw2);
Jailed[playerid] = false;
canarrestagain[playerid] = true;
playerspawned[playerid] = false;
escaped[playerid] = false;
waitrobstore[playerid] = false;
isafk[playerid] = false;
canrobciv[playerid] = true;
canesc[playerid] = true;
canrapeciv[playerid] = true;
canbeair[playerid] = false;
canbehealed[playerid] = false;
canrobdrag[playerid] = false;
canrobsand[playerid] = false;
canrobburger[playerid] = false;
canrobstrip[playerid] = false;
canrobcluck[playerid] = false;
canrobammu[playerid] = false;
canrobbinco[playerid] = false;
canrobpizza[playerid] = false;
canrobburger2[playerid] = false;
SendClientMessage(playerid, 0xFF8000FF, "Welcome to Crazymax Cops and Robbers!!");
SendClientMessage(playerid, 0x0000FFFF, "This is Not a Deathmatch Server, use /pc, /rules and /cmds !!");
new name[MAX_PLAYER_NAME]; //Making a new variable called 'name'. name[MAX_PLAYER_NAME] is created so we can use it to get player's name.
GetPlayerName(playerid,name,sizeof(name)); //Get player's name
if(fexist(Path(playerid))) /* Check if the connected user is registered or not. fexist stands for file exist. So if file exist in the files(Path(playerid)),*/
{// then
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); //Will load user's data using INI_Parsefile.
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"Login","Welcome back. This account is registered. \nInsert your password to login to your account","Login","Quit");/*A dialog with input style will appear so you can insert your password to login.*/
}
return 1;