Is it Possible to Get Value From Strfind ?
#1

Is it Possible to Get Value From Strfind ? Like this

Example:

pawn Код:
if(strfind(text,"this is mean to id 1",true) != -1)
{
     Condition Blah Blah
}
Is it possible ? to get Value "1" From String and return value out ?
and if it's change to 2 3 or 4 value will changes as I changes


//Sorry for my bad grammer

Thank you
PP.
Reply
#2

Check sscanf out.
Reply
#3

Quote:
Originally Posted by colonel-top
Посмотреть сообщение
Is it Possible to Get Value From Strfind ? Like this
PHP код:
if(strfind(text,"this is mean to id 1",true) != -1
Yes. You may not realize it, but you already have the variable stored in "text".

In this case, you're searching for "1" inside "this is mean to id 1".
What you're comparing in the function is text with "this is mean to id 1". This means you've put the "1" inside the variable text, which you can then use to return the answer.
Reply
#4

If you exactly know how the text is supposed to look, as you obviously do, it is possible. Although not with "strfind"
You can use the "strfind" function the way you do to find a starting position from where to search.
Код:
new start = strfind(text, "this is mean to id", true);
Now you can either use something like strmid to get the number out of the string, or call it directly like: text[position];

The "position" would be "start" + the length of the text from the start pos to the number.
e.g.
Код:
new position = start + strlen("this is mean to id ");
new id = text[position];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)