04.06.2017, 13:34
(
Последний раз редактировалось MrFantasy; 04.06.2017 в 14:07.
Причина: Edited
)
Код:
public WhenAccountCheck(playerid, password[]) { new rows, fields; cache_get_data(rows, fields, handle); if(rows) { gRegistred[playerid] = 1; } else { gRegistred[playerid] = 0; } if(pInfo[playerid][pLogged] == 0) { if(gRegistred[playerid] == 1) { if(rows) { new string[256]; format(string,sizeof(string),"{BECBFC}Welcome, {95A3FF}%s{BECBFC}!\nPlease enter your password below to login to your account.",PlayerName(playerid)); ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD,"DayZ Account Login",string,"Login","Exit"); } } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "DayZ Register", "DayZ Account Registration\nEnter your password below:", "Register", "Cancel"); } } SetPlayerCameraPos(playerid, 1500.7156,-1778.1880,80.3080); SetPlayerCameraLookAt(playerid, 1500.7156,-1778.1880,80.3080); SetPlayerPos_Allow(playerid, 1437.6957,-2266.6355,13.5469); return 1; } public OnPlayerAccountLogin(playerid, enteredPassword[]) { if(IsPlayerNPC(playerid)) return 1; { if(IsPlayerConnected(playerid)) { new query[350]; format(query, sizeof(query), "SELECT * FROM `users` WHERE `Username`= '%s' AND `Password` = SHA1('%s')", PlayerName(playerid), enteredPassword); mysql_tquery(handle, query, "WhenPlayerLogin", "i", playerid); } } return 1; } public WhenPlayerLogin(playerid) { if(IsPlayerConnected(playerid)) { pInfo[playerid][pHunger] = 2500; pInfo[playerid][pThrist] = 1000; pInfo[playerid][pBlood] = 12000; pInfo[playerid][Humanity] = 2500; new rows, fields; new tmp[128]; cache_get_data(rows, fields, handle); if(rows != 0) { cache_get_field_content(0, "Password", tmp), format(pInfo[playerid][Password], 128, tmp); cache_get_field_content(0, "Headshots", tmp), pInfo[playerid][Headshots] = strval(tmp); cache_get_field_content(0, "Murders", tmp), pInfo[playerid][Murders] = strval(tmp); cache_get_field_content(0, "BanditsKilled", tmp), pInfo[playerid][BanditsKilled] = strval(tmp); cache_get_field_content(0, "ZombiesKilled", tmp), pInfo[playerid][ZombiesKilled] = strval(tmp); cache_get_field_content(0, "Backpack", tmp), pInfo[playerid][Backpack] = strval(tmp); cache_get_field_content(0, "BackpackSlots", tmp), pInfo[playerid][BackpackSlots] = strval(tmp); cache_get_field_content(0, "BackpackSlotsUsed", tmp), pInfo[playerid][BackpackSlotsUsed] = strval(tmp); cache_get_field_content(0, "pAdminLevel", tmp), pInfo[playerid][pAdminLevel] = strval(tmp); cache_get_field_content(0, "pPremium", tmp), pInfo[playerid][pPremium] = strval(tmp); cache_get_field_content(0, "pX", tmp), pInfo[playerid][pX] = strval(tmp); cache_get_field_content(0, "pY", tmp), pInfo[playerid][pY] = strval(tmp); cache_get_field_content(0, "pZ", tmp), pInfo[playerid][pZ] = strval(tmp); cache_get_field_content(0, "pWeap1", tmp), pInfo[playerid][pWeap1] = strval(tmp); cache_get_field_content(0, "pAmmo1", tmp), pInfo[playerid][pAmmo1] = strval(tmp); cache_get_field_content(0, "pWeap2", tmp), pInfo[playerid][pWeap2] = strval(tmp); cache_get_field_content(0, "pAmmo2", tmp), pInfo[playerid][pAmmo2] = strval(tmp); cache_get_field_content(0, "pWeap3", tmp), pInfo[playerid][pWeap3] = strval(tmp); cache_get_field_content(0, "pAmmo3", tmp), pInfo[playerid][pAmmo3] = strval(tmp); cache_get_field_content(0, "pWeap4", tmp), pInfo[playerid][pWeap4] = strval(tmp); cache_get_field_content(0, "pAmmo4", tmp), pInfo[playerid][pAmmo4] = strval(tmp); cache_get_field_content(0, "pWeap5", tmp), pInfo[playerid][pWeap5] = strval(tmp); cache_get_field_content(0, "pAmmo5", tmp), pInfo[playerid][pAmmo5] = strval(tmp); cache_get_field_content(0, "pWeap6", tmp), pInfo[playerid][pWeap6] = strval(tmp); cache_get_field_content(0, "pAmmo6", tmp), pInfo[playerid][pAmmo6] = strval(tmp); cache_get_field_content(0, "pWeap7", tmp), pInfo[playerid][pWeap7] = strval(tmp); cache_get_field_content(0, "pAmmo7", tmp), pInfo[playerid][pAmmo7] = strval(tmp); cache_get_field_content(0, "pWeap8", tmp), pInfo[playerid][pWeap8] = strval(tmp); cache_get_field_content(0, "pAmmo8", tmp), pInfo[playerid][pAmmo8] = strval(tmp); cache_get_field_content(0, "pWeap9", tmp), pInfo[playerid][pWeap9] = strval(tmp); cache_get_field_content(0, "pAmmo9", tmp), pInfo[playerid][pAmmo9] = strval(tmp); cache_get_field_content(0, "pHour", tmp), pInfo[playerid][pHour] = strval(tmp); cache_get_field_content(0, "pMin", tmp), pInfo[playerid][pMin] = strval(tmp); cache_get_field_content(0, "pSec", tmp), pInfo[playerid][pSec] = strval(tmp); cache_get_field_content(0, "pBlood", tmp), pInfo[playerid][pBlood] = strval(tmp); cache_get_field_content(0, "pThrist", tmp), pInfo[playerid][pThrist] = strval(tmp); cache_get_field_content(0, "pHunger", tmp), pInfo[playerid][pHunger] = strval(tmp); cache_get_field_content(0, "Humanity", tmp), pInfo[playerid][Humanity] = strval(tmp); cache_get_field_content(0, "pFirstSpawn", tmp), pInfo[playerid][pFirstSpawn] = strval(tmp); cache_get_field_content(0, "pAliveTime", tmp), pInfo[playerid][pAliveTime] = strval(tmp); cache_get_field_content(0, "pIsMapOpened", tmp), pInfo[playerid][pIsMapOpened] = strval(tmp); cache_get_field_content(0, "pSkin", tmp), pInfo[playerid][pSkin] = strval(tmp); cache_get_field_content(0, "Helper", tmp), pInfo[playerid][Helper] = strval(tmp); cache_get_field_content(0, "IsPlayerBleeding", tmp), pInfo[playerid][IsPlayerBleeding] = strval(tmp); cache_get_field_content(0, "IsPlayerLegBroken", tmp), pInfo[playerid][IsPlayerLegBroken] = strval(tmp); cache_get_field_content(0, "pAmbientEnable", tmp), pInfo[playerid][pAmbientEnable] = strval(tmp); cache_get_field_content(0, "DefaultGender", tmp), pInfo[playerid][DefaultGender] = strval(tmp); cache_get_field_content(0, "ID", tmp), pInfo[playerid][pUserID] = strval(tmp); } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "The passwords don't match!\nType your account's password below:", "Login", "Exit"); return 1; } if(pInfo[playerid][pAmbientEnable] == 0) { pInfo[playerid][pAmbientEnable] = 1; SendClientMessage(playerid, -1, ""chat" The ambient has been enabled, you can change this by default in the GAME OPTIONS menu!"); } printf("%s has logged in.", PlayerName(playerid)); if(pInfo[playerid][pFirstSpawn] == 0) { pInfo[playerid][pFirstSpawn] = 1; } pInfo[playerid][pLogged] = 1; ClearChatPlayer(playerid); LoadInventory(playerid); SetPlayerScore(playerid,pInfo[playerid][pHour]); DayZSA_ShowMenuForPlayer(playerid); } return 1; } public OnPlayerRegister(playerid, password[]) { if(IsPlayerConnected(playerid)) { new Query[450],IP[16]; GetPlayerIp(playerid, IP, sizeof(IP)); strcat(Query,"INSERT INTO `users` (Username,Password,IP) VALUES ('%s', sha1('%s'),'%s')"); format(Query,sizeof(Query),Query,PlayerName(playerid),password,IP); mysql_tquery(handle, Query, "", ""); printf("%s",Query); pInfo[playerid][pFirstSpawn] = 1; pInfo[playerid][pHunger] = 2500; pInfo[playerid][pThrist] = 1000; pInfo[playerid][pBlood] = 12000; pInfo[playerid][Humanity] = 2500; pInfo[playerid][Backpack] = 0; pInfo[playerid][BackpackSlots] = 8; pInfo[playerid][BackpackSlotsUsed] = 0; ShowPlayerDialog(playerid, DIALOG_LOGIN ,DIALOG_STYLE_PASSWORD, "Login", "Please enter your password below to login to your account.", "Login", "Exit"); } return 1; }