11.12.2014, 09:50
This is how the public OnPlayerConnect and OnPlayerDisconnect looks like
Here are some stocks:
Код:
public OnPlayerConnect(playerid) { PlayerInfo[playerid][pVIP] = 0; //Setting the VIP level 0 on player connect- Enablevheal[playerid] = 1; //Enabling the /vheal command on player connect-- Enablevbonus[playerid] = 1; //Enabling the /vbonus command on player connect HasSpawnedCar[playerid] = 0;//-Setting the value to 0 //-------------Checking and creating the player account in database--------- if(fexist(getACC(playerid))) { new string[256]; INI_Open(getACC(playerid)); PlayerInfo[playerid][pVIP] = INI_ReadInt("Level"); format(string, sizeof(string),"Welcome %s Your VIP level has been successfully loaded [VIP Level: %d][VIP Rank: %s]",PlayerName(playerid),PlayerInfo[playerid][pVIP],Rank(playerid)); print("\n----------------------------------------------------------"); printf("_____[%s] Very Important Player Connected_____", PlayerName(playerid)); print("------------------------------------------------------------\n"); SendClientMessage(playerid, GREEN,string); } else { MakeACC(playerid); //Creating the account if the account doesn't exists } return 1; } //Saving PLayer Stats on his disconnect========================================= public OnPlayerDisconnect(playerid, reason) { SaveLevel(playerid); return 1; }
Код:
//=============================STOCKS=========================================== stock PlayerName(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); return name; } //===================Account==================================================== stock getACC(playerid) { new file[200]; format(file, sizeof(file),"VIP/%s.ini",PlayerName(playerid)); return file; } //============Vip Ranks Can be editted========================================== stock Rank(playerid) { new str[156]; if(PlayerInfo[playerid][pVIP] == 0) str = ("Player"); else if(PlayerInfo[playerid][pVIP] == 1) str = ("Donator Level 1"); else if(PlayerInfo[playerid][pVIP] == 2) str = ("Donator Level 2"); else if(PlayerInfo[playerid][pVIP] == 3) str = ("Donator Level 3"); return str; } //=====================Creating the account===================================== stock MakeACC(playerid) { if(!fexist(getACC(playerid))) { new string[125]; format(string, sizeof(string),"%s",Rank(playerid)); INI_Open(getACC(playerid)); INI_WriteInt("Level",0); INI_WriteString("Rank",string); INI_Save(); INI_Close(); PlayerInfo[playerid][pVIP] = 0; } return 1; } //===========Saving the VIP level=============================================== stock SaveLevel(playerid) { INI_Open(getACC(playerid)); INI_WriteInt("Level",PlayerInfo[playerid][pVIP]); INI_WriteString("Rank",Rank(playerid)); INI_Save(); INI_Close(); SendClientMessage(playerid, LIGHTGREEN,"VIP Level saved in accounts!"); return 1; }