Raised This Month: $51 Target: $400
 12% 

Parsing nVault Data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-08-2011 , 06:19   Parsing nVault Data
Reply With Quote #1

What's the best way to parse nVault data if I don't know how hany pieces of data I'm going to have inside it, formatted like %i#%i# , so I don't have to use parse() and code it all out? I think strbreak() could be helpful if I knew how to use it.

Thanks.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-08-2011 , 08:01   Re: Parsing nVault Data
Reply With Quote #2

strbreak uses the same "delimiter" that parse() does and neither will work if you are delimiting with a # symbol.

You will need to use the more generic strtok() function.

Something like this:

PHP Code:
    strtok(remainingtexttextofinterestcharsmax(textofinterest), remainingtextcharsmax(remainingtext), '#')
    
number str_to_num(textofinterest
__________________
fysiks is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-08-2011 , 09:05   Re: Parsing nVault Data
Reply With Quote #3

Okay. So would I have to remove each piece of the string after I use it? Or ... ?
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2011 , 10:05   Re: Parsing nVault Data
Reply With Quote #4

If there is always a # at the end of the string, you could do this:
Code:
new vaultData[/*size of vault data */] new piece[/* size of the piece you are getting */] while(contain(vaultData, "#") >= 0) {     strtok(vaultData, piece, charsmax(piece), vaultData, charsmax(vaultData), '#')         // piece is the piece you want }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-08-2011 , 11:20   Re: Parsing nVault Data
Reply With Quote #5

Quote:
Originally Posted by hornet View Post
Okay. So would I have to remove each piece of the string after I use it? Or ... ?
Using the original vault string recursively means it removes it for you automatically, if that was not clear.

@Exolent, I don't think your code will get the last peice of data unless the last characters is the token.

E.g:
"I'm first#I'm Second#I've been left behind:("

So, the "I've been left behind:(" will actually be left in vaultData after the loop finishes.
__________________
fysiks is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2011 , 11:21   Re: Parsing nVault Data
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
Using the original vault string recursively means it removes it for you automatically, if that was not clear.

@Exolent, I don't think your code will get the last peice of data unless the last characters is the token.

"I'm first#I'm Second#I've been left behind:("
Quote:
Originally Posted by Exolent[jNr] View Post
If there is always a # at the end of the string, you could do this
Also, his post had the # at the end, just like the XP Mod tutorial that all new scripters copy from.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-08-2011 , 11:23   Re: Parsing nVault Data
Reply With Quote #7

Oops, saw more code than regular text so I skipped the regular text. My bad.
__________________
fysiks is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 08-08-2011 , 23:40   Re: Parsing nVault Data
Reply With Quote #8

Quote:
Originally Posted by Exolent[jNr] View Post
Also, his post had the # at the end, just like the XP Mod tutorial that all new scripters copy from.
Lol thanks for that. Learnt from, not copied from :p.

Thanks guys for your help.

EDIT: Tested now and working perfect!
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 08-09-2011 at 00:08.
hornet is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode