26.01.2019, 19:47
Code:
function WhenPlayerLogin(playerid) { if(IsPlayerConnected(playerid)) { new string[256]; new pName[30]; GetPlayerName(playerid, pName, sizeof(pName)); cache_get_value_index(rows, fields, handle); if(rows != 0) { mysql_fetch_field_row(0, "password", temp), format(PlayerInfo[playerid][pPassword], 128, temp); mysql_fetch_field_row(0, "Level", temp), PlayerInfo[playerid][pLevel] = strval(temp); mysql_fetch_field_row(0, "AdminLevel", temp), PlayerInfo[playerid][pAdmin] = strval(temp); mysql_fetch_field_row(0, "HelperLevel", temp), PlayerInfo[playerid][pHelper] = strval(temp); mysql_fetch_field_row(0, "Cash", temp), PlayerInfo[playerid][pCash] = strval(temp); mysql_fetch_field_row(0, "Account", temp), PlayerInfo[playerid][pAccount] = strval(temp); mysql_fetch_field_row(0, "Email", temp), format(PlayerInfo[playerid][pEmail], 256, temp); mysql_fetch_field_row(0, "Registred", temp), PlayerInfo[playerid][pRegistred] = strval(temp); mysql_fetch_field_row(0, "Tutorial", temp), PlayerInfo[playerid][pTutorial] = strval(temp); mysql_fetch_field_row(0, "Sex", temp), PlayerInfo[playerid][pSex] = strval(temp); mysql_fetch_field_row(0, "Age", temp), PlayerInfo[playerid][pAge] = strval(temp); mysql_fetch_field_row(0, "PhoneNumber", temp), PlayerInfo[playerid][pPhoneNumber] = strval(temp); mysql_fetch_field_row(0, "PremiumAccount", temp), PlayerInfo[playerid][pPremiumAccount] = strval(temp); mysql_fetch_field_row(0, "Banned", temp), PlayerInfo[playerid][pBanned] = strval(temp); mysql_fetch_field_row(0, "Warns", temp), PlayerInfo[playerid][pWarns] = strval(temp); mysql_fetch_field_row(0, "Leader", temp), PlayerInfo[playerid][pLeader] = strval(temp); mysql_fetch_field_row(0, "Member", temp), PlayerInfo[playerid][pMember] = strval(temp); mysql_fetch_field_row(0, "Rank", temp), PlayerInfo[playerid][pRank] = strval(temp); mysql_fetch_field_row(0, "Skin", temp), PlayerInfo[playerid][pSkin] = strval(temp); mysql_fetch_field_row(0, "IP", temp), PlayerInfo[playerid][pIP] = strval(temp); } 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(PlayerInfo[playerid][pRegistred] == 0) { PlayerInfo[playerid][pLevel] = 1; Update(playerid, pLevelu); PlayerInfo[playerid][pAdmin] = 0; Update(playerid, pAdminu); GivePlayerCash(playerid, 150); PlayerInfo[playerid][pAccount] = 500; Update(playerid, pAccountu); PlayerInfo[playerid][pRegistred] = 1; Update(playerid, pRegistredu); new randomphonenumber = 1000000 + random(9999999); PlayerInfo[playerid][pPhoneNumber] = randomphonenumber; Update(playerid, pPhoneNumberu); PlayerInfo[playerid][pInterior] = 0; } if(PlayerInfo[playerid][pBanned] == 1) { KickWithMessage(playerid, COLOR_LIGHTRED2, "Your account is currently banned."); KickWithMessage(playerid, COLOR_LIGHTRED2, "In case you think this is a confusion, request an unban at the forums."); } GetPlayerCash(playerid); SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]); SetPlayerCash(playerid, PlayerInfo[playerid][pCash]); new rand = random(sizeof(SpawnCivR)); SetSpawnInfo(playerid, 0, 0, SpawnCivR[rand][0],SpawnCivR[rand][1],SpawnCivR[rand][2],SpawnCivR[rand][3], 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); Update(playerid, pLastLoginu); new pNameIP[256]; GetPlayerIp(playerid, pNameIP, sizeof(pNameIP)); strmid(PlayerInfo[playerid][pIP], pNameIP, 0, 100, 255); Update(playerid, pIPu); if (PlayerInfo[playerid][pAdmin] >= 1) { format(string, sizeof(string), "You're logged in as a level %d admin.", PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_YELLOW2, string); } if (PlayerInfo[playerid][pHelper] >= 1) { format(string, sizeof(string), "You're logged in as a level %d helper.", PlayerInfo[playerid][pHelper]); SendClientMessage(playerid, COLOR_YELLOW2, string); } if (PlayerInfo[playerid][pPremiumAccount] >= 1) { SendClientMessage(playerid, COLOR_WHITE,"You're a premium account user. "); } printf("%s has logged in.", pName); gLogged[playerid] = 1; } return 1; }