Ко всем include
Код:
#include <mxINI> #define MOD_VERSION "Osnowa"
Далее ко всем enum
Код:
enum pInfo { pPass[64], pAdmin, pSex, pReg, pChar, pOrigin, pMoney, Float:pHealth, Float:pSHealth, pInt }
Ко всем new
Код:
new PlayerInfo[MAX_PLAYERS][pInfo]; new PAccount[MAX_PLAYERS];
В OnPlayerRequestClass
Код:
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); new string1[512];new string2[512]; if(PAccount[playerid] == 1) { new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid, sendername, sizeof sendername); format(string1,sizeof(string1),"{FF9900}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nВерсия мода {e3be88}(%s){FF9900}\n\nЭтот паспорт зарегистрирован\n\nВ нашей базе данных\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD," Авторизация",string1,"Войти","Отмена"); } else { new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid, sendername, sizeof sendername); format(string2,sizeof(string2),"{66CCFF}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n{FF9900}Версия мода {e3be88}(%s){FF9900}\n\nРегистрация нового паспорта\n\nВ штате\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n{66CCFF}<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD," Регистрация",string2,"Готово","Отмена"); }
В OnPlayerConnect
Код:
new playername[MAX_PLAYER_NAME]; new string[128]; GetPlayerName(playerid,playername,sizeof(playername)); format(string,sizeof(string),"acc/%s.ini", playername); if(fexist(string)) { PAccount[playerid] = 1; } else { PAccount[playerid] = 0; } GivePlayerMoney(playerid,PlayerInfo[playerid][pMoney]); PlayerInfo[playerid][pSex] = 0; PlayerInfo[playerid][pAdmin] = 0; PlayerInfo[playerid][pReg] = 0; PlayerInfo[playerid][pChar] = 0; PlayerInfo[playerid][pOrigin] = 0; PlayerInfo[playerid][pSHealth] = 0.0; PlayerInfo[playerid][pHealth] = 50.0; PlayerInfo[playerid][pInt] = 15;
Сделаем 3 stock
Код:
stock OnPlayerRegister(playerid, password[]) { if(IsPlayerConnected(playerid)) { new string[64]; new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername, sizeof(playername)); format(string,sizeof(string), "acc/%s.ini", playername); new iniFile = ini_createFile(string); if(iniFile < 0) { iniFile = ini_openFile(string); } if(iniFile >= 0) { strmid(PlayerInfo[playerid][pPass],password,0,strlen(password),255); ini_setString(iniFile,"Pass",PlayerInfo[playerid][pPass]); ini_setInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]); ini_setInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]); ini_setInteger(iniFile,"Registered",PlayerInfo[playerid][pReg]); ini_setInteger(iniFile,"Char",PlayerInfo[playerid][pChar]); ini_setInteger(iniFile,"Origin", PlayerInfo[playerid][pOrigin]); PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid); ini_setInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]); ini_setFloat(iniFile,"pSHealth",PlayerInfo[playerid][pSHealth]); GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]); ini_setFloat(iniFile,"pHealth",PlayerInfo[playerid][pHealth]); ini_setInteger(iniFile, "Int", PlayerInfo[playerid][pInt]); ini_closeFile(iniFile); new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid, sendername, sizeof sendername);new string1[512]; format(string1,sizeof(string1),"{FF9900}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nВерсия мода {e3be88}(%s){FF9900}\n\nЭтот паспорт зарегистрирован\n\nВ нашей базе данных\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD," Авторизация",string1,"Войти","Отмена"); } } return 1; } stock OnPlayerLogin(playerid,password[]) { if(IsPlayerConnected(playerid)) { new string[64];new string2[64]; new pass[64]; new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername, sizeof(playername)); format(string,sizeof(string), "acc/%s.ini", playername); new iniFile = ini_openFile(string); ini_getString(iniFile,"Pass",pass,64); if(strcmp(pass,password,true) == 0) { ini_getString(iniFile,"Pass",PlayerInfo[playerid][pPass],64); ini_getInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]); ini_getInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]); ini_getInteger(iniFile,"Registered",PlayerInfo[playerid][pReg]); ini_getInteger(iniFile,"Char",PlayerInfo[playerid][pChar]); ini_getInteger(iniFile,"Origin", PlayerInfo[playerid][pOrigin]); ini_getInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]); ini_getFloat(iniFile,"pSHealth",PlayerInfo[playerid][pSHealth]); GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]); ini_getFloat(iniFile,"pHealth",PlayerInfo[playerid][pHealth]); ini_getInteger(iniFile, "Int", PlayerInfo[playerid][pInt]); ini_closeFile(iniFile); } else { ini_closeFile(iniFile); new sendername[MAX_PLAYER_NAME]; GetPlayerName(playerid, sendername, sizeof sendername);new string1[512]; format(string1,sizeof(string1),"{FF9900}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nВерсия мода {e3be88}(%s){FF9900}\n\nЭтот паспорт зарегистрирован\n\nВ нашей базе данных\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD," Авторизация",string1,"Войти","Отмена"); return 1; } if(PlayerInfo[playerid][pReg] == 0) { PlayerInfo[playerid][pReg] = 1; PlayerInfo[playerid][pMoney] = 500; PlayerInfo[playerid][pSHealth] = 0.0; PlayerInfo[playerid][pHealth] = 50.0; if(PlayerInfo[playerid][pSex] == 1) { PlayerInfo[playerid][pChar] = 23; } else if(PlayerInfo[playerid][pSex] == 2) { PlayerInfo[playerid][pChar] = 192; } PlayerInfo[playerid][pInt] = 15; } if (PlayerInfo[playerid][pAdmin] > 0) { format(string2, sizeof(string2), "SERVER: Вы вошли как админ %d уровня.",PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_WHITE,string2); } SetPlayerMoney(playerid,PlayerInfo[playerid][pMoney]); SetPlayerInterior(playerid,PlayerInfo[playerid][pInt]); SendClientMessage(playerid,0xFF00000,"Добро пожаловать на Osnowa"); SpawnPlayer(playerid); } return 1; } stock SavePlayer(playerid) { new string[64]; new playername[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername, sizeof(playername)); format(string, sizeof(string), "acc/%s.ini", playername); new iniFile = ini_openFile(string); ini_setString(iniFile,"Pass",PlayerInfo[playerid][pPass]); ini_setInteger(iniFile,"Admin",PlayerInfo[playerid][pAdmin]); ini_setInteger(iniFile,"Sex",PlayerInfo[playerid][pSex]); ini_setInteger(iniFile,"Registered",PlayerInfo[playerid][pReg]); ini_setInteger(iniFile,"Char",PlayerInfo[playerid][pChar]); ini_setInteger(iniFile,"Origin", PlayerInfo[playerid][pOrigin]); PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid); ini_setInteger(iniFile,"Money",PlayerInfo[playerid][pMoney]); ini_setFloat(iniFile,"pSHealth",PlayerInfo[playerid][pSHealth]); GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]); ini_setFloat(iniFile,"pHealth",PlayerInfo[playerid][pHealth]); ini_setInteger(iniFile, "Int", PlayerInfo[playerid][pInt]); ini_closeFile(iniFile); }
Далее сделаем диалоги.
В OnDialogResponse
Код:
new string[512];new string1[512];new string2[512]; new sendername[MAX_PLAYER_NAME]; if(dialogid == 1) { if(response) { if(!strlen(inputtext)) { GetPlayerName(playerid, sendername, sizeof sendername); format(string1,sizeof(string1),"{FF9900}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nВерсия мода {e3be88}(%s){FF9900}\n\nЭтот паспорт зарегистрирован\n\nВ нашей базе данных\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD," Авторизация",string1,"Войти","Отмена"); return 1; } new pass[64]; strmid(pass,inputtext,0,strlen(inputtext),64); OnPlayerLogin(playerid,pass); } else { GetPlayerName(playerid, sendername, sizeof sendername); format(string1,sizeof(string1),"{FF9900}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nВерсия мода {e3be88}(%s){FF9900}\n\nЭтот паспорт зарегистрирован\n\nВ нашей базе данных\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD," Авторизация",string1,"Войти","Отмена"); } } if(dialogid == 2) { if(response) { if(!strlen(inputtext)) { GetPlayerName(playerid, sendername, sizeof sendername); format(string2,sizeof(string2),"{66CCFF}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n{FF9900}Версия мода {e3be88}(%s){FF9900}\n\nРегистрация нового паспорта\n\nВ штате\n\nЛогин: {66CCFF} %s{FF9900}\n\nВведите пароль:\n\n{66CCFF}<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<",MOD_VERSION,sendername); ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD," Регистрация",string2,"Готово","Отмена"); return 1; } new pass[64]; strmid(pass,inputtext,0,strlen(inputtext),64); OnPlayerRegister(playerid,pass); GetPlayerName(playerid, sendername, sizeof sendername); format(string,sizeof(string),"{FFFFFF}\t\t\t Здравствуйте, [{FF9900}%s{ffffff}]\n\n•• Ты зарегистрировал(а) этот аккаунт в базе данных сервера\n\n•• {FF9900}Ты действительно хочеш играть на нашем сервере?{ffffff}\ \n\n•• {ffffff}Выбор за тобой! Если ты хочеш завершить регистрацию нажми {008000}'Далее'{ffffff}\ \n\n•• Если ты не хочеш продолжать нажми {ff0000}'Отмена' {ffffff}и аккаунт будет {ff0000}удален{ffffff}!",sendername); ShowPlayerDialog(playerid,3,DIALOG_STYLE_MSGBOX," ",string,"Далее","Отмена"); } else { GetPlayerName(playerid, sendername, sizeof(sendername)); format(string2, sizeof(string2), "acc/%s.ini", sendername); SendClientMessage(playerid, COLOR_LIGHTRED, "Для выхода из игры используйте {FFFFFF}/q(uit)"); Kick(playerid); fremove(string2); } } else if(dialogid == 3) // register { if(response) { GetPlayerName(playerid, sendername, sizeof sendername);new pass[64]; OnPlayerLogin(playerid,pass); format(string,sizeof(string),"{ffffff} Привет, [{FF9900}%s{ffffff}]\n\n* Спасибо за регистрацию\n\n* Наш сайт: {FF9900}Pawno-Info.Ru{ffffff}\n\n* Ты кто, Парень или Девушка",sendername); ShowPlayerDialog(playerid,4,DIALOG_STYLE_MSGBOX," ",string,"Парень","Девушка"); return 1; } else { GetPlayerName(playerid, sendername, sizeof(sendername)); SendClientMessage(playerid, COLOR_GRAD1, "{ffffff}Вы отменили процедуру дальнейшей регистрации. Ваш аккаунт был {ff0000}удалён{ffffff}."); format(string, sizeof(string), "acc/%s.ini", sendername); SendClientMessage(playerid, COLOR_LIGHTRED, "Для выхода из игры используйте {FFFFFF}/q(uit)"); Kick(playerid); fremove(string); return 1; } } else if(dialogid == 4) // register { if(response) { SendClientMessage(playerid, COLOR_GRAD1, "Спасибо за регистрацию | Ты,| {0066B3}Парень"); PlayerInfo[playerid][pSex] = 1; SetPlayerSkin(playerid, 23); PlayerInfo[playerid][pChar] = 23; return 1; } else { SendClientMessage(playerid, COLOR_GRAD1, "Спасибо за регистрацию | Ты,| {CC0099}Девушка"); PlayerInfo[playerid][pSex] = 2; SetPlayerSkin(playerid, 192); PlayerInfo[playerid][pChar] = 192; return 1; } }
В OnPlayerDisconnect
Код:
SavePlayer(playerid);
В OnPlayerSpawn
Код:
if(IsPlayerConnected(playerid)) { SetPlayerSkin(playerid, PlayerInfo[playerid][pChar]); if(PlayerInfo[playerid][pOrigin] == 0) { SetPlayerPos(playerid,-144.1583,1223.8292,19.8992); SetPlayerFacingAngle(playerid, 169.5015); SetPlayerInterior(playerid,0); } }