Detecting spaces in dialogs (inputtext)
#1

Currently I have...

pawn Код:
case DIALOG_GOTOPOS:
        {
            if ( response )
            {
                if( IsFloat ( inputtext ) )
                {

                }
                else
                {
                    if( strcmp ( inputtext, "immigration", false ) == 0 )
                    {
                        SetPlayerPos ( playerid, 1489.1519, -1145.5687, 24.0781 );
                        SetPlayerFacingAngle ( playerid, 91.3527 );
                    }
                }
            }
        }
My problem is trying to determine if there's a space in between inputtexts.. Which is really hard to explain; I mean like..

In the dialog, I would input "0.0 10.0 20.0" if i wanted to go to 0.0, 10.0, 20.0. How would I go about splitting it up from the inputtext? God that's hard to explain..
Reply
#2

Would sscanf not do the trick? Never actually tried something like this before, i'm sure i've seen it done though.
Reply
#3

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Would sscanf not do the trick? Never actually tried something like this before, i'm sure i've seen it done though.
I've never really used sscanf to separate data, I'm sure it's possible, just don't have the experience to make it happen. Do you know how to go about doing it?
Reply
#4

Hmm, i'm 100% sure it's possible too but i've never actually scripted anything related to this. I'm sure someone with more knowledge will explain it, ****** should know seeing as he created sscanf. Sorry I can't give you any information on it!
Reply
#5

Use SSCANF or Explode in westie's strlib.
Reply
#6

Quote:
Originally Posted by Schurman
Посмотреть сообщение
Use SSCANF or Explode in westie's strlib.
We've established sscanf is the answer, problem is I have absolutely no idea how to split data using sscanf, and I'm pretty positive there's no tutorials on it.
Reply
#7

Something like..this? Would it work?
pawn Код:
new Float:x, Float:y, Float:z;
sscanf(inputtext,"fff",x,y,z);
Reply
#8

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Something like..this? Would it work?
pawn Код:
new Float:x, Float:y, Float:z;
sscanf(inputtext,"fff",x,y,z);
I sincerely hope it's not truly that easy.

EDIT: in case anyone was wondering, I got it working.

pawn Код:
case DIALOG_GOTOPOS:
{
        if ( response )
        {
                if( strcmp ( inputtext, "immigration", false ) == 0 )
                {
                        SetPlayerPos ( playerid, 1489.1519, -1145.5687, 24.0781 );
                        SetPlayerFacingAngle ( playerid, 91.3527 );
                }
                else
                {
                        new
                                Float: xpos,
                                Float: ypos,
                                Float: zpos;
                               
                        if( !sscanf( inputtext, "p<,>fff", xpos, ypos, zpos ) )
                        {
                                SetPlayerPos ( playerid, xpos, ypos, zpos );
                        }
                }
        }
}
Pretty simple, actually.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)