1 Question

Started by FarisDon, Aug 08, 2015, 01:46 AM

Previous topic - Next topic

FarisDon

Well there i s no error, or nothing, but i just want to confirm something, from you guys that
if we use this         local reason = GetTok( text, " ", 2); So we can only add 1 word like killing for bla now as you can see the rest of 2 words are being cut, mean not added
same as bere        local Cash = NumTok( text, " "  ); As you can see here it can only take numbers, not text.
local reason = GetTok( text, " ", 2, NumTok( text, " " ) ); but when we combine those two together we can add many words for example:team-killing is not allowed.
why we can only type more words by combine those two code ?  GetTok( text, " ", 2, NumTok( text, " " ) );?

DizzasTeR

Quote from: KAKAN on Aug 08, 2015, 03:41 AMWhy u want to know it? its working, so let it work

Why shouldn't he know? You reply was very disappointing, he wants to learn so let him learn.

As for your question, GetTok and NumTok are 2 functions usedd for seperation and taking arguments from a string on conditions ( " " ) respectively.

If you check the function it uses split to split the text and return the arguments.

Maybe someone else will give you a better idea since im on phone.

KAKAN

I replied like that cuz I too don't know it, anyways I'll delete that post
oh no

Thijn

Like @Doom_Killer said, the GetTok function splits your string with the specified delimiter.
So it actually just splits the string "Hello this is a test." into multiple pieces. If you specify the delimiter as " " (a space), the code will split it to:
  • Hello
  • this
  • is
  • a
  • test

If you then specify you only want the 2nd element, it will return "this". If you also specify the maximum amount of tokens you want it will give you more.
If you'd do GetTok(testString, " ", 2, 4) it will return "this is a". If you want the text till the end you'd specify the maximum token as the actual amount of tokens, hence the use of NumTok. Which stands for Number of Tokens.

KAKAN

Oh thanks a lot, this is gonna help me too, I didn't knew it
oh no

FarisDon

Quote from: Thijn on Aug 08, 2015, 09:32 AMLike @Doom_Killer said, the GetTok function splits your string with the specified delimiter.
So it actually just splits the string "Hello this is a test." into multiple pieces. If you specify the delimiter as " " (a space), the code will split it to:
  • Hello
  • this
  • is
  • a
  • test

If you then specify you only want the 2nd element, it will return "this". If you also specify the maximum amount of tokens you want it will give you more.
If you'd do GetTok(testString, " ", 2, 4) it will return "this is a". If you want the text till the end you'd specify the maximum token as the actual amount of tokens, hence the use of NumTok. Which stands for Number of Tokens.
Meh Thanks, Doom, And thijn :-)