SSCANF Loading hudge data +1 Rep
#1

I'm wondering if it's possible to load hudge amount of data with SSCANF, because I know it's very fast and you know...

Let's say I want to load this with sscanf (from VX-RP Script, example only...):

Код:
enum playervEnum {
	Float: pHealth,
	Float: pArmour,
	Float: pPos[3],
	pPassword[129],
	pStatus,
	pAge,
	pMoney,
	pAdminLevel,
	pInterior,
	pLevel,
	pSkinSet,
	pCarID,
	pAnticheatExemption,
	pTabbed,
	pCarWeapons[5],
	pCarLicensePlate[32],
	pCarTrunk[2], // Cash & mats
	pPhoneCredit, // Will be done in seconds.
	pWalkieTalkie, // -1 = no walkie, 0 = switched off
	pSpectating,
	pSpecSession,
	pConnectedSeconds,
	pSpamCount,
	pFishing,
	pMuted,
	pVirtualWorld,
	pFish,
	pBanned,
	pTazer,
	pEvent,
	Float: pCarPos[4],
	pReport,
	pPrisonTime,
	pPrisonID, // 3 = IN CHARACTER JAIL! (future reference)
	pHackWarnTime,
	pHelperDuty,
	pReportMessage[64],
	pPlayingHours,
	pSkin,
	pJob,
	pRope,
	pAccent[40],
	pWarning1[32],
	pWarning2[32],
	pWarning3[32],
	pPhoneNumber,
	pSkinCount,
	pSeeOOC,
	pOOCMuted,
	pNewbieTimeout,
	pTutorial,
	pWeapons[13],
	pOutstandingWeaponRemovalSlot,
	pJetpack,
	pBankMoney,
	pHackWarnings,
	pEmail[255], // because this is the max length for a valid email.
	pSeconds,
	pFightStyle,
	pInternalID,
	pJobDelay,
	pGender,
	pNewbieEnabled,
	pFirstLogin,
	pAdminDuty,
	pHelper,
	pCarColour[2],
	pMatrunTime,
	pAdminName[MAX_PLAYER_NAME],
	pNormalName[MAX_PLAYER_NAME],
	pPhoneBook,
	pCheckpoint,
	pPMStatus,
	pOnRequest,
	Text3D: pAFKLabel,
	pGroup,
	pCarModel,
	pCarMods[13],
	pCarPaintjob,
	pCarLock,
	pVIP,
	pGroupRank,
	pDropCarTimeout,
	pMaterials,
	pJobSkill[2],
	pHospitalized,
	pFreezeTime, // Seconds. Set it to -1 if you want to permafreeze.
	pFreezeType, // 0 = not frozen (obviously), 1 = tazed, 2 = cuffed, 3 = admin frozen, 4 = tied
	pDrag,
	pAnimation,
	pPhoneStatus, // togged on/off
	pPhoneCall,
	pConnectionIP[32],
	pSeeWhisper,
	pCrimes,
	pArrests,
    pWarrants,
	pBackup,
}
This is a lot of variables I'm wondering how I can load it with sscanf without have a hudge amount of string length like str[1024];

I'm willing to give reputation.
Reply
#2

Come on guys, it's a simple questions, I'm just trying to figure out.
Reply
#3

If your planning on using sscanf for all that data the string will HAVE to be large enough to hold the data. It's as simple as that, no way around it. You could call sscanf a few times with a smaller array but that's much less efficient than using a large array.
Reply
#4

I suggest you make a global variable for it. Although it will be stuck in memory as unused, it won't resort in stacking or memory leakage.

pawn Код:
new gLargeString[4096];
stock myfunction()
{
    gLargeString=""; // erase string
    for(new spam=0;spam<40;spam++)strcat(gLargeString,"Bacon :D ");
}
Reply
#5

The problem is that if the string is very large it will causes problems, I'm wondering if it's possible to do it in another way.
Reply
#6

What problems does it cause? (because it really shouldn't)
Reply
#7

Try it yourself, load all these data into 1 row of sscanf and you will see what will happen.
Reply
#8

Quote:
Originally Posted by Ubuntu
Посмотреть сообщение
Try it yourself, load all these data into 1 row of sscanf and you will see what will happen.
Erm i asked you a question so people can help you. I really can't be bothered writing all that code when you could just tell me whats wrong with it.
Reply
#9

Well, what's wrong with it is that the string buffer overflow.
Reply
#10

Make the string larger then. If the string isn't global it will be removed from memory anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)