25.10.2015, 08:14
Onplayerconnect:
--------------------------------------------------------------------------------------------
HTML Code:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid)); mysql_pquery(MySQLCon, query, "OnAccountCheck", "d", playerid);
HTML Code:
forward OnAccountCheck(playerid); public OnAccountCheck(playerid) { new string[228], rows = cache_num_rows(); if(rows) { cache_get_field_content(0, "pass", pInfo[playerid][pPass], MySQLCon, 129); cache_get_field_content(0, "LastLogin", string), strmid(pInfo[playerid][pLastLogin], string, 0, 255, 255); pInfo[playerid][pID] = cache_get_field_content_int(0, "ID"); format(string, sizeof(string), "%s\nEnter password\nLast login: {4D97FF}%s",GetName(playerid), pInfo[playerid][pLastLogin]); ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login",string,"Login","Cancel"); } else { format(string, sizeof(string), "%s\nPlease register an account.",GetName(playerid)); ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Registration",string,"Register","Cancel"); } return 1; }
HTML Code:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `user` = '%e' LIMIT 1", GetName(playerid)); mysql_pquery(MySQLCon, query, "OnPlayerLogin", "d", playerid);
HTML Code:
forward OnPlayerLogin(playerid); public OnPlayerLogin(playerid) { new rows = cache_num_rows(); if(rows) { pInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin"); pInfo[playerid][pHelper] = cache_get_field_content_int(0, "Helper"); pInfo[playerid][pMoney] = cache_get_field_content_int(0, "Money"); pInfo[playerid][pScore] = cache_get_field_content_int(0, "Score"); pInfo[playerid][pStatus] = cache_get_field_content_int(0, "Status"); pInfo[playerid][pReg] = cache_get_field_content_int(0, "Reg"); pInfo[playerid][pSex] = cache_get_field_content_int(0, "Sex"); pInfo[playerid][pAge] = cache_get_field_content_int(0, "Age"); pInfo[playerid][pMute] = cache_get_field_content_int(0, "Mute"); pInfo[playerid][pHoursPlayed] = cache_get_field_content_int(0, "HoursPlayed"); pInfo[playerid][pRPoints] = cache_get_field_content_int(0, "RPoints"); pInfo[playerid][pBankMoney] = cache_get_field_content_int(0, "BankMoney"); pInfo[playerid][pWantedLevel] = cache_get_field_content_int(0, "WantedLevel"); pInfo[playerid][pPhoneBook] = cache_get_field_content_int(0, "PhoneBook"); pInfo[playerid][pJob] = cache_get_field_content_int(0, "Job"); pInfo[playerid][pJailed] = cache_get_field_content_int(0, "Jailed"); pInfo[playerid][pPremium] = cache_get_field_content_int(0, "Premium"); pInfo[playerid][pMaterials] = cache_get_field_content_int(0, "Materials"); pInfo[playerid][pDrugs] = cache_get_field_content_int(0, "Drugs"); pInfo[playerid][pLeader] = cache_get_field_content_int(0, "Leader"); pInfo[playerid][pMember] = cache_get_field_content_int(0, "Member"); pInfo[playerid][pRank] = cache_get_field_content_int(0, "Rank"); pInfo[playerid][pPhoneNumber] = cache_get_field_content_int(0, "PhoneNumber"); pInfo[playerid][pHouse] = cache_get_field_content_int(0, "House"); pInfo[playerid][pBusiness] = cache_get_field_content_int(0, "Business"); pInfo[playerid][pCarLic] = cache_get_field_content_int(0, "CarLic"); pInfo[playerid][pFlyLic] = cache_get_field_content_int(0, "FlyLic"); pInfo[playerid][pBoatLic] = cache_get_field_content_int(0, "BoatLic"); pInfo[playerid][pGunLic] = cache_get_field_content_int(0, "GunLic"); pInfo[playerid][pCarLicTime] = cache_get_field_content_int(0, "CarLicTime"); pInfo[playerid][pFlyLicTime] = cache_get_field_content_int(0, "FlyLicTime"); pInfo[playerid][pBoatLicTime] = cache_get_field_content_int(0, "BoatLicTime"); pInfo[playerid][pGunLicTime] = cache_get_field_content_int(0, "GunLicTime"); pInfo[playerid][pWarns] = cache_get_field_content_int(0, "Warns"); pInfo[playerid][pFWarns] = cache_get_field_content_int(0, "FWarns"); pInfo[playerid][pDeaths] = cache_get_field_content_int(0, "Deaths"); pInfo[playerid][pKills] = cache_get_field_content_int(0, "Kills"); } return 1; }