AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   parse string from aymbols (https://forums.alliedmods.net/showthread.php?t=240970)

faki 05-25-2014 08:51

parse string from aymbols
 
I got 2 strings in formatex function with "+" symbol between.
I need to parse string 1 and string 2 in 2 new bools.
How to ?

Here is example:
new format[512]

formatex(format,511,"%s+%s",id,auth)

i need to parse id in
new ids = id
new auths = auth
+ is character that separates them.

c2d22 05-25-2014 10:39

Re: parse string from aymbols
 
You need to use , strtok .

For ur example , if

PHP Code:

new format[512] = "12+steam_0:0:24524"
new id[20] , authid[25]
strtok(format,id,charsmax(id),authid,charsmax(authid),'+')
log_amx("Id - %s  and authid - %s",id,authid

Output
PHP Code:

Id 12 and authid steam_0:0:24524 

If u want to trim both the divided part use strtok2 , because trimming is broken in strtok .


All times are GMT -4. The time now is 09:43.

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