Detecting spaces in dialogs (inputtext) -
2KY - 16.02.2013
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..
Re: Detecting spaces in dialogs (inputtext) -
Luis- - 16.02.2013
Would sscanf not do the trick? Never actually tried something like this before, i'm sure i've seen it done though.
Re: Detecting spaces in dialogs (inputtext) -
2KY - 16.02.2013
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?
Re: Detecting spaces in dialogs (inputtext) -
Luis- - 16.02.2013
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!
Re: Detecting spaces in dialogs (inputtext) -
SchurmanCQC - 16.02.2013
Use SSCANF or Explode in westie's strlib.
Re: Detecting spaces in dialogs (inputtext) -
2KY - 16.02.2013
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.
Re: Detecting spaces in dialogs (inputtext) -
RajatPawar - 16.02.2013
Something like..this? Would it work?
pawn Код:
new Float:x, Float:y, Float:z;
sscanf(inputtext,"fff",x,y,z);
Re: Detecting spaces in dialogs (inputtext) -
2KY - 16.02.2013
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.