![]() |
[SOURCE] STRTOKEN - Printable Version +- SphereCommunity (https://forum.spherecommunity.net) +-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d) +--- Forum: Script Submissions (/Forum-Script-Submissions) +--- Thread: [SOURCE] STRTOKEN (/Thread-SOURCE-STRTOKEN) |
[SOURCE] STRTOKEN - xwerswoodx - 02-16-2017 03:15 AM Addes STRTOKEN function to sphere; Usage: <STRTOKEN text,n,seperator> <STRTOKEN a.b.c.d.e,3,.> returns c <STRTOKEN a.b.c.d.e,0,.> returns 5 <STRTOKEN a.b.c.d.e,6,.> returns null You can also specify a range of tokens: <STRTOKEN a.b.c.d.e,2-,.> returns 2nd token onwards = b.c.d.e <STRTOKEN a.b.c.d.e,2-4,.> returns tokens 2 through 4 = b.c.d Installation; Note: Please backup your files before starting to edit. Open File: src/common/CScriptObj.cpp find: Code: case SSC_EXPLODE: add before: Code: case SSC_StrToken: Open File: src/tables/CScriptObj_functions.tbl find: Code: ADD(StrSub, "StrSub") add after: Code: ADD(StrToken, "StrToken") RE: [SOURCE] STRTOKEN - rastrero - 03-04-2017 05:08 AM Oh its so nice... But I cant imagine why do u need this. Can you give me an example? RE: [SOURCE] STRTOKEN - xwerswoodx - 06-01-2017 03:07 AM Sorry for late answer I saw your message now, basically, it lets you to seperate sentences with commas. For example: If you have string "1,000 2,000 3,000" and you want to get 2,000 you can use <STRTOKEN "1,000 2,000 3,000",2," ">. For example if you have in-game forum like me, you can censor swearing words with strtoken but explode overrides commas so it's not possible if sentence has commas or if there are 6-7 commas you can use for/while to check everystring inside commas to do it. Code: [FUNCTION DIFF] 23:40:'xwerswoodx' commands 'diff 1,000 2,000 5,000 100,000 9,000'=1 23:40:(insurance.scp,2)ARGS: 000 5 23:40:(insurance.scp,3)STRTOKEN: 5,000 23:40:(insurance.scp,5)EXPLODE: 2 |