enum E_PLAYER_DATA { Password[129], AdminLevel, VIPLevel, Money, Score, Kills, Deaths, Faction, Facrank, Facleader, bool:LoggedIn }; new PlayerInfo[MAX_PLAYERS][E_PLAYER_DATA];
PlayerInfo[playerid][AdminLevel] = 0; PlayerInfo[playerid][VIPLevel] = 0; PlayerInfo[playerid][Money] = 0; PlayerInfo[playerid][Score] = 1; PlayerInfo[playerid][Kills] = 0; PlayerInfo[playerid][Deaths] = 0; PlayerInfo[playerid][Faction] = 0; PlayerInfo[playerid][Facleader] = 0; PlayerInfo[playerid][Facrank] = 0; PlayerInfo[playerid][LoggedIn] = false; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); TogglePlayerSpectating(playerid, true); if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadPlayerData_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Welcome back to {00F1F1}Palomino Creek Roleplay!", "{FFFFFF}I see your account is registered already! That's awsome, enter your password below to start playing.\n\n{E6C700}* If your password is lost contact an administrator on our forums*\n{E6C700}Link:{FFFFFF} http://pcrp.net", "Login", "Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00F1F1}Welcome To Palomino Creek Roleplay!", "{FFFFFF}I see it's your first time here! Let me introduce myself, my name is {00F1F1}Cesar!\n{FF4747}You are going to play on a server, where the roleplay begins from the registration!\n\n{E6C700}Please enter your desired password below:", "Begin", "Quit"); }
public OnPlayerDisconnect(playerid, reason) { new INI:file = INI_Open(UserPath(playerid)); INI_SetTag(file,"PlayerInfo"); INI_WriteInt(file,"Faction", PlayerInfo[playerid][Faction]);//saves the players faction id on disconnect INI_WriteInt(file,"Facrank", PlayerInfo[playerid][Facrank]);//saves the players faction rank on disconnect INI_WriteInt(file,"Facleader", PlayerInfo[playerid][Facleader]);//saves the players faction leadership status on disconnect INI_WriteInt(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]); INI_WriteInt(file, "VIPLevel", PlayerInfo[playerid][VIPLevel]); INI_WriteInt(file, "Money", PlayerInfo[playerid][Money]); INI_WriteInt(file, "Score", PlayerInfo[playerid][Score]); INI_WriteInt(file, "Kills", PlayerInfo[playerid][Kills]); INI_WriteInt(file, "Deaths", PlayerInfo[playerid][Deaths]); INI_Close(file); return 1; } forward LoadPlayerData_PlayerInfo(playerid, name[], value[]); public LoadPlayerData_PlayerInfo(playerid, name[], value[]) { INI_String("Password", PlayerInfo[playerid][Password], 129); INI_Int("AdminLevel", PlayerInfo[playerid][AdminLevel]); INI_Int("VIPLevel", PlayerInfo[playerid][VIPLevel]); INI_Int("Money", PlayerInfo[playerid][Money]); INI_Int("Scores", PlayerInfo[playerid][Score]); INI_Int("Kills", PlayerInfo[playerid][Kills]); INI_Int("Deaths", PlayerInfo[playerid][Deaths]); INI_Int("Faction", PlayerInfo[playerid][Faction]); INI_Int("Facrank", PlayerInfo[playerid][Facrank]); INI_Int("Facleader", PlayerInfo[playerid][Facleader]); return 1; }
public OnPlayerDeath(playerid, killerid, reason) { TogglePlayerSpectating(playerid, false); SpawnPlayer(playerid); PlayerInfo[killerid][Kills]++; PlayerInfo[playerid][Deaths]++; return 1; }
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_REGISTER: { if(!response) Kick(playerid); else { if(!strlen(inputtext)) { SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}You have to enter your desired password in order to register."); return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00F1F1}Welcome To Palomino Creek Roleplay!", "{FFFFFF}I see it's your first time here! Let me introduce myself, my name is {00F1F1}Cesar!\n{FF4747}*You are going to play on a server, where the roleplay begins from the registration!*\n\n{E6C700}Please enter your desired password below:", "Begin", "Quit"); } WP_Hash(PlayerInfo[playerid][Password], 129, inputtext); new INI:file = INI_Open(UserPath(playerid)); INI_SetTag(file, "PlayerInfo"); INI_WriteString(file, "Password", PlayerInfo[playerid][Password]); INI_WriteInt(file, "AdminLevel", 0); INI_WriteInt(file, "VIPLevel", 0); INI_WriteInt(file, "Money", 12500); INI_WriteInt(file, "Score", 1); INI_WriteInt(file, "Kills", 0); INI_WriteInt(file, "Deaths", 0); INI_WriteInt(file, "Faction", 0); INI_WriteInt(file, "Facrank", 0); INI_WriteInt(file, "Facleader", 0); INI_Close(file); SendClientMessage(playerid, -1, ""); SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}You have successfully created an account at {00F1F1}Palomino Creek Roleplay!"); SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}For more help you can use {00F1F1}/cmds, /help, /map."); SendClientMessage(playerid, COLOR_GOLD, " *[TIP] - If spotted a hacker, or found a bug use /report to request admin assistance."); PlayerInfo[playerid][LoggedIn] = true; TogglePlayerSpectating(playerid, true); SendClientMessage(playerid, -1, ""); SendClientMessage(playerid, -1, ""); SendClientMessage(playerid, COLOR_ADM, "*** PLEASE WAIT FOR THE TUTORIAL TO LOAD ***"); TextDrawHideForPlayer(playerid, Text:Textdraw7); TextDrawHideForPlayer(playerid, Text:Textdraw8); TextDrawHideForPlayer(playerid, Text:Textdraw9); TextDrawHideForPlayer(playerid, Text:Textdraw10); TextDrawHideForPlayer(playerid, Text:Textdraw11); TextDrawHideForPlayer(playerid, Text:Textdraw12); TextDrawHideForPlayer(playerid, Text:Textdraw13); TextDrawHideForPlayer(playerid, Text:Textdraw14); TextDrawHideForPlayer(playerid, Text:Textdraw15); TextDrawHideForPlayer(playerid, Text:Textdraw16); TextDrawHideForPlayer(playerid, Text:Textdraw17); TextDrawHideForPlayer(playerid, Text:Textdraw18); TextDrawHideForPlayer(playerid, Text:Textdraw19); TextDrawHideForPlayer(playerid, Text:Textdraw20); TextDrawHideForPlayer(playerid, Text:Textdraw21); TextDrawShowForPlayer(playerid, Text:Textdraw38); TextDrawShowForPlayer(playerid, Text:Textdraw39); TextDrawShowForPlayer(playerid, Text:Textdraw40); TextDrawShowForPlayer(playerid, Text:Textdraw41); TextDrawShowForPlayer(playerid, Text:Textdraw42); TextDrawShowForPlayer(playerid, Text:Textdraw43); TextDrawShowForPlayer(playerid, Text:Textdraw44); TextDrawShowForPlayer(playerid, Text:Textdraw45); TextDrawShowForPlayer(playerid, Text:Textdraw46); TextDrawShowForPlayer(playerid, Text:Textdraw47); TextDrawShowForPlayer(playerid, Text:Textdraw48); SetTimerEx("OnPlayerInTutorial",7000,0,"ii",playerid,1); return 1; } } case DIALOG_LOGIN: { if(!response) Kick(playerid); else { new hashpass[129]; WP_Hash(hashpass, sizeof(hashpass), inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][Password])) { SendClientMessage(playerid, COLOR_WHITE, "Welcome back to {00F1F1}Palomino Creek Roleplay! {FFFFFF}Don't forget to visiout our forums: {00F1F1}http://pcrp.net"); PlayerInfo[playerid][LoggedIn] = true; new name[MAX_PLAYER_NAME], string[64+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "You are logged in as %s, enjoy your stay!", name); SendClientMessage(playerid, COLOR_GREEN, string); SetPlayerScore(playerid, PlayerInfo[playerid][Score]); GivePlayerMoney(playerid, PlayerInfo[playerid][Money]); SetSpawnInfo(playerid, 0, 46, 2500.5176,-14.0097,26.4844, 1, 0, 0, 0, 0, 0, 0); SetPlayerPos(playerid, 2500.5176,-14.0097,26.4844); SetPlayerVirtualWorld(playerid, 0); SetPlayerInterior(playerid, 0); GivePlayerMoney(playerid, 12500); TogglePlayerSpectating(playerid, false); SpawnPlayer(playerid); } else { SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: You have entered an incorrect password, try again!"); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FFFFFF}Welcome back to {00F1F1}Palomino Creek Roleplay!", "{FFFFFF}I see your account is registered already! That's awsome, enter your password below to start playing.\n\n{E6C700}* If your password is lost contact an administrator on our forums*\n{E6C700}Link:{FFFFFF} http://pcrp.net", "Login", "Quit"); } return 1; } } } return 1; }
INI_WriteInt(file, "Money", PlayerInfo[playerid][Money]);
INI_WriteInt(file, "Money", GetPlayerMoney(playerid));
GivePlayerMoney(playerid, 12500);
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
stock GivePlayerMoneyEx(playerid, amount) { GivePlayerMoney(playerid, amount); PlayerInfo[playerid][Money] = GetPlayerMoney(playerid); return 1; }
in OnPlayerDisconnect change this:
Код:
INI_WriteInt(file, "Money", PlayerInfo[playerid][Money]); Код:
INI_WriteInt(file, "Money", GetPlayerMoney(playerid)); Код:
GivePlayerMoney(playerid, 12500); Код:
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]); Код:
stock GivePlayerMoneyEx(playerid, amount) { GivePlayerMoney(playerid, amount); PlayerInfo[playerid][Money] = GetPlayerMoney(playerid); return 1; } |
CMD:makemeadmin(playerid, params[]) { if(IsPlayerAdmin(playerid)) { SendClientMessage(playerid, COLOR_ADM, "** [AdmCMD]: You have been made a level 1338 admin! (Community Owner)"); PlayerInfo[playerid][AdminLevel] = 1338; SetPlayerScore(playerid, 1338); PlayerInfo[playerid][Score] = 1338; } return 1; }
INI_WriteInt(file, "Score", PlayerInfo[playerid][Score]);
INI_WriteInt(file, "Score", GetPlayerScore(playerid));