Raised This Month: $32 Target: $400
 8% 

[QUESTION] Working with strings.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 05-09-2007 , 23:02   [QUESTION] Working with strings.
Reply With Quote #1

Okay, so i have a line in a file like so:

Code:
"STEAM_ID_BLAH" "PLAYER NAME"
And i break it up with "StrBreak"

Which's makes it come up with "STEAM_ID_BLAH" and i place that into a string. But how do i get "PLAYER NAME" into a string? (Since StrBreak only takes the front of the string)
And, for a second question. What is "decl" iv seen it used as so: "decl String:line[255]"
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 05-10-2007 , 02:24   Re: [QUESTION] Working with strings.
Reply With Quote #2

Code:
new String:Hat[] = "\"STEAM_0:0:16\" \"B........"\""; new String:Auth[64]; new len = StrBreak(Hat, Auth, sizeof(Auth)); /* Here second part of the string */ if(len != -1) {      PrintToServer("%s", Hat[len]); } /* If there were more arguments you would just simply use StrBreak again but with Hat[len]  */

Edit: changes in bold.
As for decl is the same as new except for one difference. When the variable is created it does not zero out the variable.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 05-10-2007 at 19:37.
teame06 is offline
Send a message via AIM to teame06
BAILOPAN
Join Date: Jan 2004
Old 05-10-2007 , 10:22   Re: [QUESTION] Working with strings.
Reply With Quote #3

Note that if you were to have three arguments: "a" "b" "c"
You have to account for the fact that StrBreak is additive...

Code:
new String:str[] = "\"a\" \"b\" \"c\"" new String:buffer[24] new cur_idx, idx idx = StrBreak(str, buffer, sizeof(buffer)) /* Get "a" */ while (idx != -1) {    cur_idx += idx    idx = StrBreak(str[cur_idx], buffer, sizeof(buffer)) /* Get next */ }

Since it will return a position relative to where you start from, you need to make sure you handle that properly.
__________________
egg
BAILOPAN is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 05-10-2007 , 21:45   Re: [QUESTION] Working with strings.
Reply With Quote #4

Thanks teame, and bail. Finally got it working.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Reply


Thread Tools
Display Modes

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 23:56.


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