22.03.2009, 12:04
It was made for extracting words from a string (words are separated by white space).
And for command with parameters you need a function which extracts words from a string.
So you can even use split instead of strtok for commands.
http://www.compuphase.com/pawn/pawn-lang.pdf
Page 35
As you can see it is even in the pawn doku, strtok has been created before sa-mp even existed. So strtok isnt even made for sa-mp.
And for command with parameters you need a function which extracts words from a string.
So you can even use split instead of strtok for commands.
http://www.compuphase.com/pawn/pawn-lang.pdf
Page 35
Код:
Listing: strtok.inc /* extract words from a string (words are separated by white space) */ #include <string> strtok(const string[], &index) { new length = strlen(string) /* skip leading white space */ while (index < length && string[index] <= ’ ’) index++ /* store the word letter for letter */ new offset = index /* save start position of token */ new result[20] /* string to store the word in */ while (index < length && string[index] > ’ ’ && index - offset < sizeof result - 1) { result[index - offset] = string[index] index++ } result[index - offset] = EOS /* zero-terminate the string */ return result }