22.03.2009, 00:37
Were can I get the strtok function? HELP?
Originally Posted by /^We(stie|z+[e|a
|
Originally Posted by [CK
Steel ]
Were can I get the strtok function? HELP? |
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:
pawn Код:
|
Originally Posted by Pyrokid
I assume you are making a gamemode from scratch. Instead of strtok, I'd suggest you use DCMD with sscanf.
https://sampwiki.blast.hk/wiki/Fast_Commands |
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:
|
Originally Posted by Stevelo
Quote:
|
Originally Posted by Stevelo
Quote:
|
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 }
Originally Posted by Pyrokid
I've used strtok for many previous scripts and it's just a general bitch to deal with.
|
Originally Posted by /^We(stie|z+[e|a
r)$/ ]
strtok is a great function if you know when and how to use it. I am in the process of making MTA style command handlers (I don't like dcmd), and the great thing about strtok is that how portable it is, how you can modify it, and how easy it is to use, honest! |
Originally Posted by Pghpumpkin
Quote:
|
Originally Posted by Pghpumpkin
i was talking about strtok. Maybe you dont understand what its doing technically.. how it parses the data.. then maybe you do and still have troubles with it..
|
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:
pawn Код:
|
Originally Posted by Mikep
Firstly, strtok is in Vactions.pwn
Secondly, if hes a new scripter, I doubt he want's confusing with dcmd and sscanf. |
Originally Posted by Pyrokid
Quote:
|
Originally Posted by <__Ethan__>
the thing is your guys are so UNHELPFUL, this forum is made for help, not for people to say "search it yourself" or "do it yourself". I do what your supposed to do on a forum like this. Help. and saying find it yourself is certainly not helping.
|