SA-MP Forums Archive
StrTok Function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: StrTok Function (/showthread.php?tid=69992)

Pages: 1 2


StrTok Function - [CK]Steel - 22.03.2009

Were can I get the strtok function? HELP?


Re: StrTok Function - [CK]Steel - 22.03.2009

Quote:
Originally Posted by /^We(stie|z+[e|a
Nothing.. I keep searching...


Re: StrTok Function - Think - 22.03.2009

Quote:
Originally Posted by [CK
Steel ]
Were can I get the strtok function? HELP?
copy it from other scripts but keep the original credits


Re: StrTok Function - StrickenKid - 22.03.2009

here... scene im not an assole like some others i got it from my script for you:

pawn Код:
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;
}



Re: StrTok Function - Pyrokid - 22.03.2009

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


Re: StrTok Function - Pghpunkid - 22.03.2009

Quote:
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:

pawn Код:
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;
}
Its not that were being an asshole, its all over the forums.. literally. a simple search would find it.


Re: StrTok Function - NigNog1 - 22.03.2009

Quote:
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
strtok isn't only used for commands you know. It isn't a bad function and defintely not that slow. There is nothing wrong with using it.


Re: StrTok Function - Donny_k - 22.03.2009

Quote:
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:
He already has it in one of the scripts which come with the server package, all us assholes have it

Quote:
Originally Posted by Stevelo
Quote:
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
strtok isn't only used for commands you know. It isn't a bad function and defintely not that slow. There is nothing wrong with using it.
It makes sense to use the more efficient way which is DCMD and sscanf.


Re: StrTok Function - Pyrokid - 22.03.2009

Quote:
Originally Posted by Stevelo
Quote:
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
strtok isn't only used for commands you know. It isn't a bad function and defintely not that slow. There is nothing wrong with using it.
What else is strtok used for? Wasn't it made for commands? Correct me if I'm wrong.

I've used strtok for many previous scripts and it's just a general bitch to deal with.

I'm not forcing him to use dcmd and sscanf, I'm just making a suggestion which may lead to less of these help threads.


Re: StrTok Function - Remis93 - 22.03.2009

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

Код:
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
}
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.


Re: StrTok Function - Pghpunkid - 22.03.2009

Quote:
Originally Posted by Pyrokid
I've used strtok for many previous scripts and it's just a general bitch to deal with.
With no offense, that may be because you dont know what its doing exactly.


Re: StrTok Function - beckzy - 22.03.2009

Quote:
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!
+1


Re: StrTok Function - Pyrokid - 22.03.2009

Quote:
Originally Posted by Pghpumpkin
Quote:
Originally Posted by Pyrokid
I've used strtok for many previous scripts and it's just a general bitch to deal with.
With no offense, that may be because you dont know what its doing exactly.
Oh I know what what I'm doing. Trust me.


Re: StrTok Function - Pghpunkid - 23.03.2009

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..


Re: StrTok Function - Pyrokid - 23.03.2009

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..
Well I wasn't talking about how it works, I was talking about the troubles in using it. But hey, if your script runs well with it then no problem, right?


Re: StrTok Function - Norn - 23.03.2009

Quote:
Originally Posted by <__Ethan__>
here... scene im not an assole like some others i got it from my script for you:

pawn Код:
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;
}
Other people are assholes for asking him to search? These people aren't babies, they can find stuff themselves. Now what you have done is just spoonfed them like babies.


Re: StrTok Function - Mikep - 23.03.2009

Firstly, strtok is in Vactions.pwn

Secondly, if hes a new scripter, I doubt he want's confusing with dcmd and sscanf.


Re: StrTok Function - StrickenKid - 23.03.2009

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.


Re: StrTok Function - Pyrokid - 23.03.2009

Quote:
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.
He can use strtok if he wants (no apostrophe). No one's forcing him. It was just a suggestion.


Re: StrTok Function - Pghpunkid - 23.03.2009

Quote:
Originally Posted by Pyrokid
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..
Well I wasn't talking about how it works, I was talking about the troubles in using it. But hey, if your script runs well with it then no problem, right?
Precisely.

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.
Strtok is EVERYWHERE. We have no problem helping, we just ask you consult the Search first. We are more or less a last resort.. not ******.