sscanf - extracting ints from string (+REP) - 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)
+--- Thread: sscanf - extracting ints from string (+REP) (
/showthread.php?tid=548652)
sscanf - extracting ints from string (+REP) -
Itzhak E. - 01.12.2014
Hello...
so I have a variable from OnDialogResponse callback - inputtext which contains 2 numbers that I would like to extract but it doesn't work...
Код:
sscanf(inputtext, "ii", s_ID, s_Pos);
EDIT: the inputtext string looks like: (ID: %d, Position: %d) Name and I need those 2 %d's
Re: sscanf - extracting ints from string (+REP) -
Galletziz - 01.12.2014
I hope that i understand what you mean, try this:
pawn Код:
tmp_str[128];
sscanf(inputtext,"ii",s_ID,s_Pos);
format(tmp_str,sizeof(tmp_str),"The ID: %i, at Position: %i",s_ID, s_Pos);
SendClientMessage(playerid,-1,tmp_str);
Re: sscanf - extracting ints from string (+REP) -
Jefff - 01.12.2014
Try
pawn Код:
sscanf(inputtext, "'ID:'p<,>i'Position:'i", s_ID, s_Pos);
or
pawn Код:
sscanf(inputtext, "{s[5]}p<,>i'Position:'i", s_ID, s_Pos);
Re: sscanf - extracting ints from string (+REP) -
Itzhak E. - 01.12.2014
Quote:
Originally Posted by Galletziz
I hope that i understand what you mean, try this:
pawn Код:
tmp_str[128]; sscanf(inputtext,"ii",s_ID,s_Pos); format(tmp_str,sizeof(tmp_str),"The ID: %i, at Position: %i",s_ID, s_Pos); SendClientMessage(playerid,-1,tmp_str);
|
Thats exactly what I did and it doesn't work...
Quote:
Originally Posted by Jefff
Try
pawn Код:
sscanf(inputtext, "'ID:'p<,>i'Position:'i", s_ID, s_Pos);
or
pawn Код:
sscanf(inputtext, "{s[5]}p<,>i'Position:'i", s_ID, s_Pos);
|
Well this seem to work half-way but I'll take it. thank you. +Rep'ed