19.03.2019, 18:03
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
And replace it with
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
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?
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(text, idx);
if ((strcmp("News", tmp, true, strlen(tmp)) == 0)
PHP код:
sscanf(text, "s[256]", tmp);
Eg: text:"News something" tmp: "News something"
I thought about strfind way which was a more appealing approach
PHP код:
strfind("News", text, false) != -1)
So im asking you guys, do you have a healthy approach about this?