I've included the main parts of the script for you.
Код:
new
Float: PosX[ MAX_PLAYERS ],
Float: PosY[ MAX_PLAYERS ],
Float: PosZ[ MAX_PLAYERS ],
Float: Angle[ MAX_PLAYERS ],
Interior[ MAX_PLAYERS ],
VirtualWorld[ MAX_PLAYERS ],
Float: Health[100]
;
public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", pInfo[playerid][Pass],129); /*we will use INI_String to load user's password.
("Password",.. will load user's password inside of user's path. 'pInfo[playerid][Pass]',...We have defined our user's variable above called, pInfo. Now it's time to use it here to load user's password. '129',... 129 is a length of a hashed user's password. Whirlpool will hash 128 characters + NULL*/
INI_Int("AdminLevel",pInfo[playerid][Adminlevel]);/*We will use INI_Int to load user's admin level. INI_Int stands for INI_Integer. This load an admin level. */
INI_Int("VIPLevel",pInfo[playerid][VIPlevel]);//As explained above
INI_Int("Money",pInfo[playerid][Money]); //As explained above
INI_Int("Scores",pInfo[playerid][Scores]);//As explained above
INI_Int("Kills",pInfo[playerid][Kills]);//As explained above
INI_Int("Deaths",pInfo[playerid][Deaths]);//As explained above
INI_Int("Skin",pInfo[playerid][Skin]);
INI_Float( "PositionX", PosX[ playerid ] );
INI_Float( "PositionY", PosY[ playerid ] );
INI_Float( "PositionZ", PosZ[ playerid ] );
INI_Float( "Angle", Angle[ playerid ] );
INI_Int( "Interior", Interior[ playerid ] );
INI_Int( "VirtualWorld", VirtualWorld[ playerid ] );
INI_Float("Health", Health[ playerid ]);//As explained above
return 1;
}
public OnPlayerConnect(playerid)
{
SetSpawnInfo( playerid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
//fix
TogglePlayerSpectating(playerid, 1);
//NAMECOL
SetPlayerColor(playerid, COLOR_WHITE);
//ACCOUNTSYS
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_user", .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.*/
}
else //If the connected user is not registered,
{//then we will 'force' him to register :)
ShowPlayerDialog(playerid,dregister,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nYour security is our priority, your password is hashed.","Register","Quit");
}
return 1;
}
new Float:healthp[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );
//Same as OnDialogResponse, we will save their stats inside of their user's account
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_WriteInt(file,"Skin",GetPlayerSkin(playerid));//As explained above
INI_WriteFloat( file, "PositionX", PosX[ playerid ] );
INI_WriteFloat( file, "PositionY", PosY[ playerid ] );
INI_WriteFloat( file, "PositionZ", PosZ[ playerid ] );
INI_WriteFloat( file, "Angle", Angle[ playerid ] );
INI_WriteInt( file, "Interior", GetPlayerInterior( playerid ) );
INI_WriteInt( file, "VirtualWorld", GetPlayerVirtualWorld( playerid ) );
INI_WriteFloat(file,"Health",GetPlayerHealth(playerid, healthp[playerid]));//As explained above
INI_Close(file);//Now after we've done saving their data, we now need to close the file
return 1;
}
public OnPlayerSpawn(playerid)
{
if ( PosX[ playerid ] != 0 && PosY[ playerid ] != 0 && PosZ[ playerid ] != 0 && Angle[ playerid ] != 0 )
{
TogglePlayerSpectating(playerid, 0);
SetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
SetPlayerFacingAngle( playerid, Angle[ playerid ] );
SetPlayerInterior( playerid, Interior[ playerid ] );
SetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
SetPlayerHealth(playerid, Health[playerid]);
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage( playerid, -1, " " );
}
else if(IsNew[playerid]==true)
{
SendClientMessage(playerid,-1,"Welcome to Vertex Gaming for the first time!");
SendClientMessage(playerid,-1,"1. {9933FF}/Help {00CC33}to see a list of commands");
SendClientMessage(playerid,-1,"2. {00CC33}Head to the {9933FF} rental {00CC33}vehicles, and rent one");
SendClientMessage(playerid,-1,"3. {00CC33}Drive to {9933FF} Dillimore. {00CC33} (/dml)");
TogglePlayerSpectating(playerid, 0);
SpawnPlayer(playerid);
SetPlayerSkin(playerid, 101);
IsNew[playerid]=false;
SetPlayerPos(playerid, 1642.4740,-2240.5261,13.4948);
SetPlayerFacingAngle(playerid, 182.4304);
GivePlayerMoney(playerid, 2500);
SetPlayerColor(playerid, COLOR_WHITE);
IsNew[playerid]=false;
}
return 1;
}