31.05.2015, 22:39
Aight so earlier tonight i got that feeling like "I can do this i can convert this shit" so i went forThis tutorial. And it went pretty smooth until i first came in game and noticed big lag, files are saving correctly everything works fine just it lags way more than in old system.
Old saving system went something like that:
New saving system goes like that:
Old loading system:
New loading system:
I am looping and saving all players data every 1000ms (I will change this later but just to see if it is better than old system which was under on player update).
This is how user data looks like
Old saving system went something like that:
Код:
format(var, 128, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
Код:
stock SavePlayer(playerid) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Weed",PlayerInfo[playerid][pWeed]); INI_WriteInt(File,"Seed",PlayerInfo[playerid][pSeed]); INI_WriteString(File,"Punishment1",PlayerInfo[playerid][pPunishment1]); ... return 1; }
Код:
if( strcmp( key , "Weed" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pWeed] = strval( val ); }
Код:
forward LoadUserP_data(playerid,name[],value[]); public LoadUserP_data(playerid,name[],value[]) { INI_String("Key", PlayerInfo[playerid][pKey], 129); return 1; } forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Weed",PlayerInfo[playerid][pWeed]); INI_Int("Seed",PlayerInfo[playerid][pSeed]); INI_Int("Level",PlayerInfo[playerid][pLevel]); INI_Int("Spawn",PlayerInfo[playerid][pSpawn]); INI_String("CrimeReason",PlayerInfo[playerid][pCrimeReason], 129); INI_Int("Wanted",PlayerInfo[playerid][pWanted]); .... return 1; }
This is how user data looks like
Код:
[data] Password = 244646706 Weed = 0 Seed = 0 Level = 1 Spawn = 0 TesterLevel = 0 HelperLevel = 0 AdminLevel = 0 RegularRank = 0 UpgradePoints = 0 ConnectedTime = 7 Registered = 1 Sex = 1 Age = 0 GPS = 0 Origin = 0 CK = 0 Muted = 0 Frozen = 0 Blind = 0 Respect = 0 Money = 0 Bank = 0 Crimes = 0 CrimeReason = None Wanted = 0 WantedLevel = 0 Kills = 0 Deaths = 0 WhyLeft = Arrested = 0 WantedDeaths = 0 Phonebook = 0 LottoNr = 0 Fishes = 0 BiggestFish = 0 Job = 0 Paycheck = 7 HeadValue = 0 Jailed = 0 JailTime = 0 CanRobTime = 0 Materials = 0 Addicted = 0 Drugs = 0 Leader = 0 Member = 0 FMember = 255 Rank = 0 Char = 0 ContractTime = 0 DetSkill = 0 SexSkill = 0 BoxSkill = 0 LawSkill = 0 MechSkill = 0 JackSkill = 0 CarSkill = 0 NewsSkill = 0 DrugsSkill = 0 CookSkill = 0 FishSkill = 0 pSHealth = 0.000000 pHealth = 50.000000 pArmour = 0.000000 Int = 0 InteriorNr = 0 Local = 255 Team = 3 Model = 101 PhoneNr = 931674 Car = 999 Car2 = 999 Car3 = 999 House = 999 Bizz = 255 Pos_x = 1726.627075 Pos_y = -1880.137939 Pos_z = 13.629199 Passport = 0 CarLic = 0 CarLicS = 0 FlyLic = 0 FlyLicS = 0 BoatLic = 0 BoatLicS = 0 FishLic = 0 FishLicS = 0 GunLic = 0 GunLicS = 0 CopLic = 0 CopLicS = 0 CarTime = 0 PayDay = 0 PayTax = 0 PayDayHad = 0 Watch = 0 Crashed = 0 Wins = 0 Loses = 0 AlcoholPerk = 0 DrugPerk = 0 MiserPerk = 0 PainPerk = 0 TraderPerk = 0 Tutorial = 0 VirWorld = 0 Fuel = 0 Married = 0 MarriedTo = 0 FishTool = 0 Note1 = None Note1s = 0 Note2 = None Note2s = 0 Note3 = None Note3s = 0 Note4 = None Note4s = 0 Note5 = None Note5s = 0 InvWeapon = 0 InvAmmo = 0 InvWeapon2 = 0 InvAmmo2 = 0 InvWeapon3 = 0 InvAmmo3 = 0 InvAmmo4 = 0 InvWeapon5 = 0 InvAmmo5 = 0 InvWeapon6 = 0 InvAmmo6 = 0 Lighter = 0 Cigarettes = 0 Beer = 0 Sprunk = 0 Warnings = 0 Swat = 0 Fighting = 0 Boxing = 0 KneeHead = 0 KungFu = 0 GrabKick = 0 Elbow = 0 Tactical = 0 SpecialF = 0 SpecialD = 0 SpecialB = 0 ArmyTicket = 0 Judge = 0 DJ = 0 IRCChannel = 0 DutyBanned = 0 ServerBanned = 0 DDManager = 0 OnDuty = 0 DDTicket = 0 DDSTicket = 0 CDPlayer = 0 Speedo = 0 HydraDriver = 0 HunterDriver = 0 RhinoDriver = 0 PredatorDriver = 0 ViewPms = 0 AppearList = 1 AmmunationTime = 0 PistolSkill = 0 SilencedSkill = 0 DesertSkill = 0 ShotgunSkill = 0 SawnoffSkill = 0 CombatSkill = 0 UziSkill = 0 SMGSkill = 0 AK47Skill = 0 M4Skill = 0 SniperSkill = 0 TutorialDone = 0 RegularCount = 143999 PassportTime = 599 OfficerTime = 0 Achievement0 = 0 Achievement1 = 0 Achievement2 = 0 Achievement3 = 0 Achievement4 = 0 Achievement5 = 0 Achievement6 = 0 Achievement7 = 0 Achievement9 = 0 Achievement10 = 0 Achievement11 = 0 Achievement12 = 0 Achievement13 = 0 Achievement14 = 0 Achievement15 = 0 Achievement16 = 0 Achievement17 = 0 Achievement18 = 0 Achievement19 = 0 Achievement20 = 0 ShiftName = 0 Weapon = 0 Ammo = 0 Weapon2 = 0 Ammo2 = 0 Weapon3 = 0 Ammo3 = 0 Weapon4 = 0 Ammo4 = 0 Weapon5 = 0 Ammo5 = 0 Weapon6 = 0 Ammo6 = 0 Weapon7 = 0 Ammo7 = 0 Weapon8 = 0 Ammo8 = 0 Weapon9 = 0 Ammo9 = 0 Weapon10 = 0 Ammo10 = 0 Weapon11 = 0 Ammo11 = 0 Weapon12 = 0 Atc = 0 AtcRadio = 0 Pending = 0 PendingInfo = ChatMode = 0 Punishment1 = None Punishment2 = None Punishment3 = None Punishment4 = None Punishment5 = None Punishment6 = None Punishment7 = None Punishment8 = None NextPunishment = 1 PunishedTimes = 0 TazerBullets = 0 LastSeen = Neve RegistredDate = 1/6/2015 at 0:23:4 Changed = 0 Carsreseted = 0 GunsSet = 0 Mask = 0 pDBoyLvl = 0 pHasEngine = 0 pHasBattery = 0 pHasTuning = 0 pHasUEngine = 0 DeadTime = 0 LastRevive = 0 IsDead = 0 FPTime = 0 LawyerDone = 0 pAc = 0