[Ajuda] fread
#1

aew galera
eu nгo entendo como funciona esse fread
Na wiki falava q a funзгo nгo retornava nenhum valor...
Entгo pq ta dentro do while?
como funciona esse codigo de registro ae?


PHP код:
                new key256 ] , val256 ];
                new 
Data256 ];
                while ( 
freadUserFile Data sizeofData ) ) )
                {
                    
key ini_GetKeyData );
                    if( 
strcmpkey "Level" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLevel] = strvalval ); }
                    if( 
strcmpkey "AdminLevel" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAdmin] = strvalval ); }
                    if( 
strcmpkey "DonateRank" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDonateRank] = strvalval ); }
                    if( 
strcmpkey "UpgradePoints" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][gPupgrade] = strvalval ); }
                    if( 
strcmpkey "ConnectedTime" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pConnectTime] = strvalval ); }
                    if( 
strcmpkey "Registered" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pReg] = strvalval ); }
                    if( 
strcmpkey "Sex" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pSex] = strvalval ); }
                    if( 
strcmpkey "Age" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAge] = strvalval ); }
                    if( 
strcmpkey "Origin" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pOrigin] = strvalval ); }
                    if( 
strcmpkey "Muted" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMuted] = strvalval ); }
                    if( 
strcmpkey "Respect" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pExp] = strvalval ); }
                    if( 
strcmpkey "Money" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCash] = strvalval ); }
                    if( 
strcmpkey "Bank" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAccount] = strvalval ); }
                    if( 
strcmpkey "Crimes" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCrimes] = strvalval ); }
                    if( 
strcmpkey "Kills" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pKills] = strvalval ); }
                    if( 
strcmpkey "Deaths" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDeaths] = strvalval ); }
                    if( 
strcmpkey "Arrested" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pArrested] = strvalval ); }
                    if( 
strcmpkey "WantedDeaths" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pWantedDeaths] = strvalval ); }
                    if( 
strcmpkey "Phonebook" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPhoneBook] = strvalval ); }
                    if( 
strcmpkey "Phone" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPhone] = strvalval ); }
                    if( 
strcmpkey "Mask" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMask] = strvalval ); }
                    if( 
strcmpkey "LottoNr" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLottoNr] = strvalval ); }
                    if( 
strcmpkey "Fishes" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFishes] = strvalval ); }
                    if( 
strcmpkey "BiggestFish" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pBiggestFish] = strvalval ); }
                    if( 
strcmpkey "Job" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pJob] = strvalval ); }
                    if( 
strcmpkey "Paycheck" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPayCheck] = strvalval ); }
                    if( 
strcmpkey "HeadValue" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pHeadValue] = strvalval ); }
                    if( 
strcmpkey "Jailed" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pJailed] = strvalval ); }
                    if( 
strcmpkey "JailTime" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pJailTime] = strvalval ); }
                    if( 
strcmpkey "Materials" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMats] = strvalval ); }
                    if( 
strcmpkey "Drugs" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDrugs] = strvalval ); }
                    if( 
strcmpkey "Leader" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLeader] = strvalval ); }
                    if( 
strcmpkey "Member" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMember] = strvalval ); }
                    if( 
strcmpkey "FMember" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFMember] = strvalval ); }
                    if( 
strcmpkey "Rank" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pRank] = strvalval ); }
                    if( 
strcmpkey "Char" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pChar] = strvalval ); }
                    if( 
strcmpkey "ContractTime" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pContractTime] = strvalval ); }
                    if( 
strcmpkey "DetSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDetSkill] = strvalval ); }
                    if( 
strcmpkey "SexSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pSexSkill] = strvalval ); }
                    if( 
strcmpkey "BoxSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pBoxSkill] = strvalval ); }
                    if( 
strcmpkey "LawSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLawSkill] = strvalval ); }
                    if( 
strcmpkey "MechSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMechSkill] = strvalval ); }
                    if( 
strcmpkey "JackSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pJackSkill] = strvalval ); }
                    if( 
strcmpkey "CarSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCarSkill] = strvalval ); }
                    if( 
strcmpkey "NewsSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pNewsSkill] = strvalval ); }
                    if( 
strcmpkey "DrugsSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDrugsSkill] = strvalval ); }
                    if( 
strcmpkey "CookSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCookSkill] = strvalval ); }
                    if( 
strcmpkey "FishSkill" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFishSkill] = strvalval ); }
                    if( 
strcmpkey "pSHealth" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pSHealth] = floatstrval ); }
                    if( 
strcmpkey "pHealth" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pHealth] = floatstrval ); }
                    if( 
strcmpkey "Int" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pInt] = strvalval ); }
                    if( 
strcmpkey "Local" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLocal] = strvalval ); }
                    if( 
strcmpkey "Team" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pTeam] = strvalval ); }
                    if( 
strcmpkey "Model" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pModel] = strvalval ); }
                    if( 
strcmpkey "PhoneNr" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPnumber] = strvalval ); }
                    if( 
strcmpkey "House" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPhousekey] = strvalval ); }
                    if( 
strcmpkey "Bizz" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPbiskey] = strvalval ); }
                    if( 
strcmpkey "Pos_x" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPos_x] = floatstrval ); }
                    if( 
strcmpkey "Crimes" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCrimes] = strvalval ); }
                    if( 
strcmpkey "Pos_y" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPos_y] = floatstrval ); }
                    if( 
strcmpkey "Pos_z" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPos_z] = floatstrval ); }
                    if( 
strcmpkey "CarLic" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCarLic] = strvalval ); }
                    if( 
strcmpkey "FlyLic" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFlyLic] = strvalval ); }
                    if( 
strcmpkey "BoatLic" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pBoatLic] = strvalval ); }
                    if( 
strcmpkey "FishLic" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFishLic] = strvalval ); }
                    if( 
strcmpkey "GunLic" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pGunLic] = strvalval ); }
                    if( 
strcmpkey "Gun1" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pGun1] = strvalval ); }
                    if( 
strcmpkey "Gun2" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pGun2] = strvalval ); }
                    if( 
strcmpkey "Gun3" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pGun3] = strvalval ); }
                    if( 
strcmpkey "Gun4" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pGun4] = strvalval ); }
                    if( 
strcmpkey "Ammo1" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAmmo1] = strvalval ); }
                    if( 
strcmpkey "Ammo2" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAmmo2] = strvalval ); }
                    if( 
strcmpkey "Ammo3" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAmmo3] = strvalval ); }
                    if( 
strcmpkey "InvWeapon" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pInvWeapon] = strvalval ); }
                    if( 
strcmpkey "InvAmmo" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pInvAmmo] = strvalval ); }
                    if( 
strcmpkey "Ammo4" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAmmo4] = strvalval ); }
                    if( 
strcmpkey "CarTime" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCarTime] = strvalval ); }
                    if( 
strcmpkey "PayDay" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPayDay] = strvalval ); }
                    if( 
strcmpkey "PayDayHad" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPayDayHad] = strvalval ); }
                    if( 
strcmpkey "CDPlayer" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pCDPlayer] = strvalval ); }
                    if( 
strcmpkey "Wins" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pWins] = strvalval ); }
                    if( 
strcmpkey "Loses" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pLoses] = strvalval ); }
                    if( 
strcmpkey "AlcoholPerk" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAlcoholPerk] = strvalval ); }
                    if( 
strcmpkey "DrugPerk" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDrugPerk] = strvalval ); }
                    if( 
strcmpkey "MiserPerk" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMiserPerk] = strvalval ); }
                    if( 
strcmpkey "PainPerk" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPainPerk] = strvalval ); }
                    if( 
strcmpkey "TraderPerk" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pTraderPerk] = strvalval ); }
                    if( 
strcmpkey "Tutorial" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pTut] = strvalval ); }
                    if( 
strcmpkey "Warnings" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pWarns] = strvalval ); }
                    if( 
strcmpkey "Adjustable" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pAdjustable] = strvalval ); }
                    if( 
strcmpkey "Fuel" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pFuel] = strvalval ); }
                    if( 
strcmpkey "Married" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pMarried] = strvalval ); }
                    if( 
strcmpkey "MarriedTo" true ) == ) { val ini_GetValueData ); strmid(PlayerInfo[playerid][pMarriedTo], val0strlen(val)-1255); }
                    if( 
strcmpkey "Dollar" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pDolar] = strvalval ); }
                    if( 
strcmpkey "LU" true ) == ) { val ini_GetValueData ); strmid(PlayerInfo[playerid][pLastLogin], val0strlen(val)-1255); }
                    if( 
strcmpkey "ControleRemoto" true ) == ) { val ini_GetValueData ); strmid(PlayerInfo[playerid][pControleR], val0strlen(val)-1255); }
                } 
Reply
#2

й um LOOP para ler todas 'tags' dentro de um arquivo (UserFile)
file й uma coisa muito mais complicada do que outros gerenciadores de arquivos...
Reply
#3

sim, isso eu percebi...
mas ainda nгo responde minha pergunta...
se fread nгo retorna nenhum valor, como que o loop pбra??
Reply
#4

no final, 'fclose' return true; na stock/public ^^

Nгo sei se estou certo. Mais ai nгo irб fazer um loop normal, apenas vai ler o arquivo...
Reply
#5

nгo... a fclose estб fora do while... ou seja, sу fecha quando termina de ler e sai do while ;\
eu nгo sei pq
mas o loop passa uma vez pra cada if e pбra

bom, pra entender isso eu acho que teria q entender oq o fread grava na string Data, pq dps vem o "key = ini_GetKey( Data );" pra cada iteraзгo do loop

o estranho й que na wiki fala sу que ele lк o texto da UserFile e grava na Data, mas lol.... nгo pode ser o texto inteiro, teria mto mais que 256 de tamanho... :O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)