strtok equivalent in this situation
#1

I know the code might be a bit long and not quite make sense but is from a kind of old gamemode and i try to understand it so i know what exactly happen (OnPlayerText)
Pastebin(so its not to long post):
https://pastebin.com/VzimTEH0

I know strtok was replaced by sscanf for commands most part but in this situation cant figure out how sscanf would handle it

If i have this
PHP код:
new idx;
        
tmp strtok(textidx);
if ((
strcmp("News"tmptruestrlen(tmp)) == 0
And replace it with
PHP код:
sscanf(text"s[256]"tmp); 
tmp via sscanf way will contain exact string that the player inputed in chat
Eg: text:"News something" tmp: "News something"

I thought about strfind way which was a more appealing approach
PHP код:
strfind("News"textfalse) != -1
but "News 1" would be similar with "1 News" as the substrings are the same and to avoid that you would need to store the "News" substring position so you can offset the strfind for number

So im asking you guys, do you have a healthy approach about this?
Reply
#2

Yeah that works but its working for the nesting? Like in this

PHP код:
if (strcmp(text"news"true4))
        {
            if(
strcmp(text,"1",true1) == 0)
            {}
        } 
Because there is some code like that and idk if typing "news 1" will actually hit the second strcmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)