18.08.2010, 03:11
Would someone mind giving me some way i could optimize this code? Like some examples
pawn Код:
public OnPlayerLogin(playerid,password[])
{
if(IsPlayerConnected(playerid)) {
CheckIfBanned(playerid);
new plrIP[16];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
new DataString[128], Query[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format( Query, sizeof( Query ), "SELECT * FROM `players` WHERE `Username` = '%s'",pname);
mysql_query(Query);
mysql_store_result();
mysql_fetch_field("id", DataString);
PlayerInfo[playerid][pID] = strval(DataString);
PlayerInfo[playerid][pID] = PlayerInfo[playerid][pID];
mysql_fetch_field("Password", DataString);
//PlayerInfo[playerid][pKey] = strval(DataString);
strmid(PlayerInfo[playerid][pKey], DataString, 0, sizeof(DataString));
if(strlen(password) == 0 || strcmp(password, DataString, false) != 0)return 1;
mysql_fetch_field("Age", DataString);
PlayerInfo[playerid][pAge] = strval(DataString);
mysql_fetch_field("Religon", DataString);
PlayerInfo[playerid][pReligon] = strval(DataString);
mysql_fetch_field("LeftX", DataString);
PlayerInfo[playerid][pLeftX] = floatstr(DataString);
mysql_fetch_field("LeftY", DataString);
PlayerInfo[playerid][pLeftY] = floatstr(DataString);
mysql_fetch_field("LeftZ", DataString);
PlayerInfo[playerid][pLeftZ] = floatstr(DataString);
mysql_fetch_field("LeftInt", DataString);
PlayerInfo[playerid][pLeftInt] = strval(DataString);
mysql_fetch_field("LeftWorld", DataString);
PlayerInfo[playerid][pLeftW] = strval(DataString);
mysql_fetch_field("Cash", DataString);
PlayerInfo[playerid][pCash] = strval(DataString);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
mysql_fetch_field("Skin", DataString);
PlayerInfo[playerid][pSkin] = strval(DataString);
mysql_fetch_field("Admin", DataString);
PlayerInfo[playerid][pAdmin] = strval(DataString);
mysql_fetch_field("Mod", DataString);
PlayerInfo[playerid][pModerator] = strval(DataString);
mysql_fetch_field("Faction", DataString);
PlayerInfo[playerid][pFaction] = strval(DataString);
mysql_fetch_field("Rank", DataString);
PlayerInfo[playerid][pRank] = strval(DataString);
mysql_fetch_field("WantedLevel", DataString);
PlayerInfo[playerid][pWLevel] = strval(DataString);
mysql_fetch_field("Jailed", DataString);
PlayerInfo[playerid][pJailed] = strval(DataString);
mysql_fetch_field("JailTime", DataString);
PlayerInfo[playerid][pCrashed] = strval(DataString);
GetPlayerHealth(playerid,PlayerInfo[playerid][pHealth]);
mysql_fetch_field("Health", DataString);
PlayerInfo[playerid][pHealth] = floatstr(DataString);
GetPlayerArmour(playerid,PlayerInfo[playerid][pArmour]);
mysql_fetch_field("Armour", DataString);
PlayerInfo[playerid][pArmour] = floatstr(DataString);
mysql_fetch_field("Hours", DataString);
PlayerInfo[playerid][pHours] = strval(DataString);
mysql_fetch_field("PayCheck", DataString);
PlayerInfo[playerid][pPaycheck] = strval(DataString);
mysql_fetch_field("AllowedPayday", DataString);
PlayerInfo[playerid][pAllowedPayday] = strval(DataString);
mysql_fetch_field("Bank", DataString);
PlayerInfo[playerid][pBank] = strval(DataString);
mysql_fetch_field("Level", DataString);
PlayerInfo[playerid][pLevel] = strval(DataString);
SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
mysql_fetch_field("Carlic", DataString);
PlayerInfo[playerid][pCarlic] = strval(DataString);
mysql_fetch_field("Fighting", DataString);
PlayerInfo[playerid][pFighting] = strval(DataString);
mysql_fetch_field("LockerM", DataString);
PlayerInfo[playerid][pLockerM] = strval(DataString);
mysql_fetch_field("Card", DataString);
PlayerInfo[playerid][pCard] = strval(DataString);
mysql_fetch_field("CardM", DataString);
PlayerInfo[playerid][pCardM] = strval(DataString);
mysql_fetch_field("9mm", DataString);
PlayerInfo[playerid][p9mm] = strval(DataString);
mysql_fetch_field("Deagle", DataString);
PlayerInfo[playerid][pEagle] = strval(DataString);
mysql_fetch_field("Shotgun", DataString);
PlayerInfo[playerid][pShotgun] = strval(DataString);
mysql_fetch_field("MSMSG", DataString);
PlayerInfo[playerid][pMsmg] = strval(DataString);
mysql_fetch_field("Ak", DataString);
PlayerInfo[playerid][pAK] = strval(DataString);
mysql_fetch_field("Country", DataString);
PlayerInfo[playerid][pCountry] = strval(DataString);
mysql_fetch_field("ALocked", DataString);
PlayerInfo[playerid][pLocked] = strval(DataString);
mysql_fetch_field("CK", DataString);
PlayerInfo[playerid][pCK] = strval(DataString);
mysql_fetch_field("Weaplic", DataString);
PlayerInfo[playerid][pWeaplic] = strval(DataString);
mysql_fetch_field("FishLic", DataString);
PlayerInfo[playerid][pFishlic] = strval(DataString);
mysql_fetch_field("Fishes", DataString);
PlayerInfo[playerid][pFishes] = strval(DataString);
mysql_fetch_field("WeedSeeds", DataString);
PlayerInfo[playerid][pWeedSeeds] = strval(DataString);
mysql_fetch_field("Weed", DataString);
PlayerInfo[playerid][pWeed] = strval(DataString);
mysql_fetch_field("CokeSeeds", DataString);
PlayerInfo[playerid][pCokeSeeds] = strval(DataString);
mysql_fetch_field("Coke", DataString);
PlayerInfo[playerid][pCoke] = strval(DataString);
mysql_fetch_field("ShroomSeeds", DataString);
PlayerInfo[playerid][pShroomSeeds] = strval(DataString);
mysql_fetch_field("Shrooms", DataString);
PlayerInfo[playerid][pShrooms] = strval(DataString);
mysql_fetch_field("LSD", DataString);
PlayerInfo[playerid][pLSD] = strval(DataString);
mysql_fetch_field("GotArmour", DataString);
PlayerInfo[playerid][pGotArmour] = strval(DataString);
mysql_fetch_field("Phone", DataString);
PlayerInfo[playerid][pPhone] = strval(DataString);
mysql_fetch_field("PhoneNumber", DataString);
PlayerInfo[playerid][pPhonenumber] = strval(DataString);
mysql_fetch_field("PhoneCard", DataString);
PlayerInfo[playerid][pPhoneC] = strval(DataString);
mysql_fetch_field("Contact", DataString);
PlayerInfo[playerid][pContacts] = strval(DataString);
mysql_fetch_field("Biz1", DataString);
PlayerInfo[playerid][pBiz1] = strval(DataString);
mysql_fetch_field("Biz2", DataString);
PlayerInfo[playerid][pBiz2] = strval(DataString);
mysql_fetch_field("GPS", DataString);
PlayerInfo[playerid][pGPS] = strval(DataString);
mysql_fetch_field("PhoneB", DataString);
PlayerInfo[playerid][pPhoneb] = strval(DataString);
mysql_fetch_field("Laptop", DataString);
PlayerInfo[playerid][pLaptop] = strval(DataString);
mysql_fetch_field("Virus", DataString);
PlayerInfo[playerid][pVirus] = strval(DataString);
mysql_fetch_field("AntiVirus", DataString);
PlayerInfo[playerid][pAntiVirus] = strval(DataString);
mysql_fetch_field("PMIN", DataString);
PlayerInfo[playerid][pPMin] = strval(DataString);
mysql_fetch_field("Spawn", DataString);
PlayerInfo[playerid][pSpawn] = strval(DataString);
mysql_fetch_field("Crashed", DataString);
PlayerInfo[playerid][pCrashed] = strval(DataString);
mysql_fetch_field("Walk", DataString);
PlayerInfo[playerid][pWalk] = strval(DataString);
mysql_fetch_field("Sex", DataString);
PlayerInfo[playerid][pSex] = strval(DataString);
mysql_fetch_field("Job", DataString);
PlayerInfo[playerid][pJob] = strval(DataString);
mysql_fetch_field("Outfit1", DataString);
PlayerInfo[playerid][pOutfit1] = strval(DataString);
mysql_fetch_field("Outfit2", DataString);
PlayerInfo[playerid][pOutfit2] = strval(DataString);
mysql_fetch_field("Outfit3", DataString);
PlayerInfo[playerid][pOutfit3] = strval(DataString);
mysql_fetch_field("Shovel", DataString);
PlayerInfo[playerid][pShovel] = strval(DataString);
mysql_fetch_field("Knife", DataString);
PlayerInfo[playerid][pKnife] = strval(DataString);
mysql_fetch_field("Baseball", DataString);
PlayerInfo[playerid][pBaseball] = strval(DataString);
mysql_fetch_field("Bombs", DataString);
PlayerInfo[playerid][pBomb] = strval(DataString);
mysql_fetch_field("BombMats", DataString);
PlayerInfo[playerid][pBombMats] = strval(DataString);
mysql_fetch_field("AJailed", DataString);
PlayerInfo[playerid][pAJailed] = strval(DataString);
mysql_fetch_field("Watch", DataString);
PlayerInfo[playerid][pWatch] = strval(DataString);
mysql_fetch_field("Mats", DataString);
PlayerInfo[playerid][pMats] = strval(DataString);
mysql_fetch_field("M4", DataString);
PlayerInfo[playerid][pM4] = strval(DataString);
mysql_fetch_field("Sniper", DataString);
PlayerInfo[playerid][pSniper] = strval(DataString);
mysql_fetch_field("Sawn", DataString);
PlayerInfo[playerid][pSawn] = strval(DataString);
mysql_fetch_field("Flame", DataString);
PlayerInfo[playerid][pFlame] = strval(DataString);
mysql_fetch_field("Dead", DataString);
PlayerInfo[playerid][pDead] = strval(DataString);
mysql_fetch_field("VIP", DataString);
PlayerInfo[playerid][pVIP] = strval(DataString);
mysql_fetch_field("House1", DataString);
PlayerInfo[playerid][pHouse1] = strval(DataString);
mysql_fetch_field("House2", DataString);
PlayerInfo[playerid][pHouse2] = strval(DataString);
mysql_fetch_field("Rent", DataString);
PlayerInfo[playerid][pRent] = strval(DataString);
mysql_fetch_field("Gun1", DataString);
PlayerInfo[playerid][pGun1] = strval(DataString);
mysql_fetch_field("Gun2", DataString);
PlayerInfo[playerid][pGun2] = strval(DataString);
mysql_fetch_field("Gun3", DataString);
PlayerInfo[playerid][pGun3] = strval(DataString);
mysql_fetch_field("Gun4", DataString);
PlayerInfo[playerid][pGun4] = strval(DataString);
mysql_fetch_field("Gun5", DataString);
PlayerInfo[playerid][pGun5] = strval(DataString);
mysql_fetch_field("Gun6", DataString);
PlayerInfo[playerid][pGun6] = strval(DataString);
mysql_fetch_field("Gun7", DataString);
PlayerInfo[playerid][pGun7] = strval(DataString);
mysql_fetch_field("Gun8", DataString);
PlayerInfo[playerid][pGun8] = strval(DataString);
mysql_fetch_field("Gun9", DataString);
PlayerInfo[playerid][pGun9] = strval(DataString);
mysql_fetch_field("Gun10", DataString);
PlayerInfo[playerid][pGun10] = strval(DataString);
mysql_fetch_field("Gun11", DataString);
PlayerInfo[playerid][pGun11] = strval(DataString);
mysql_fetch_field("Gun12", DataString);
PlayerInfo[playerid][pGun12] = strval(DataString);
mysql_fetch_field("Ammo1", DataString);
PlayerInfo[playerid][pAmmo1] = strval(DataString);
mysql_fetch_field("Ammo2", DataString);
PlayerInfo[playerid][pAmmo2] = strval(DataString);
mysql_fetch_field("Ammo3", DataString);
PlayerInfo[playerid][pAmmo3] = strval(DataString);
mysql_fetch_field("Ammo4", DataString);
PlayerInfo[playerid][pAmmo4] = strval(DataString);
mysql_fetch_field("Ammo5", DataString);
PlayerInfo[playerid][pAmmo5] = strval(DataString);
mysql_fetch_field("Ammo6", DataString);
PlayerInfo[playerid][pAmmo6] = strval(DataString);
mysql_fetch_field("Ammo7", DataString);
PlayerInfo[playerid][pAmmo7] = strval(DataString);
mysql_fetch_field("Ammo8", DataString);
PlayerInfo[playerid][pAmmo8] = strval(DataString);
mysql_fetch_field("Ammo9", DataString);
PlayerInfo[playerid][pAmmo9] = strval(DataString);
mysql_fetch_field("Ammo10", DataString);
PlayerInfo[playerid][pAmmo10] = strval(DataString);
mysql_fetch_field("Ammo11", DataString);
PlayerInfo[playerid][pAmmo11] = strval(DataString);
mysql_fetch_field("Ammo12", DataString);
PlayerInfo[playerid][pAmmo12] = strval(DataString);
mysql_fetch_field("Mask", DataString);
PlayerInfo[playerid][pMask] = strval(DataString);
mysql_fetch_field("Prison", DataString);
PlayerInfo[playerid][pPrison] = strval(DataString);
mysql_fetch_field("PrisonTime", DataString);
PlayerInfo[playerid][pPrisonTime] = strval(DataString);
mysql_fetch_field("LGun1", DataString);
PlayerInfo[playerid][pLGun1] = strval(DataString);
mysql_fetch_field("LAmmo1", DataString);
PlayerInfo[playerid][pLAmmo1] = strval(DataString);
mysql_fetch_field("LGun2", DataString);
PlayerInfo[playerid][pLGun2] = strval(DataString);
mysql_fetch_field("LAmmo2", DataString);
PlayerInfo[playerid][pLAmmo2] = strval(DataString);
mysql_fetch_field("LGun3", DataString);
PlayerInfo[playerid][pLGun3] = strval(DataString);
mysql_fetch_field("LAmmo3", DataString);
PlayerInfo[playerid][pLAmmo3] = strval(DataString);
mysql_fetch_field("Cigars", DataString);
PlayerInfo[playerid][pCigars] = strval(DataString);
mysql_fetch_field("TimesSmoked", DataString);
PlayerInfo[playerid][pTimesSmoked] = strval(DataString);
mysql_fetch_field("Disease", DataString);
PlayerInfo[playerid][pDisease] = strval(DataString);
mysql_fetch_field("Spray", DataString);
PlayerInfo[playerid][pSpray] = strval(DataString);
mysql_fetch_field("Battery", DataString);
PlayerInfo[playerid][pBattery] = strval(DataString);
mysql_fetch_field("Bug", DataString);
PlayerInfo[playerid][pBug] = strval(DataString);
mysql_fetch_field("Int", DataString);
PlayerInfo[playerid][pInt] = strval(DataString);
mysql_fetch_field("Local", DataString);
PlayerInfo[playerid][pLocal] = strval(DataString);
mysql_fetch_field("Exp", DataString);
PlayerInfo[playerid][pExp] = strval(DataString);
mysql_fetch_field("Days", DataString);
PlayerInfo[playerid][pDays] = strval(DataString);
mysql_fetch_field("pMins", DataString);
PlayerInfo[playerid][pMins] = strval(DataString);
mysql_fetch_field("Flyinglic", DataString);
PlayerInfo[playerid][pFlyLicense] = strval(DataString);
mysql_fetch_field("Carkey1", DataString);
PlayerInfo[playerid][pPcarkey] = strval(DataString);
mysql_fetch_field("Carkey2", DataString);
PlayerInfo[playerid][pPcarkey2] = strval(DataString);
mysql_fetch_field("Carkey3", DataString);
PlayerInfo[playerid][pPcarkey3] = strval(DataString);
mysql_fetch_field("Ip", DataString);
PlayerInfo[playerid][pIP] = strval(DataString);
mysql_fetch_field("accepted", DataString);
PlayerInfo[playerid][pAccepted] = strval(DataString);
mysql_fetch_field("Banned", DataString);
PlayerInfo[playerid][pBanned] = strval(DataString);
}