sscanf - extracting ints from string (+REP)
#1

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
Reply
#2

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);
Reply
#3

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);
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)