SA-MP Forums Archive
Getting string from inputtext - 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: Getting string from inputtext (/showthread.php?tid=627823)



Getting string from inputtext - rOps - 02.02.2017

Hi all, as I know I can use LIST dialog type as a inputtext when player response. So how I can get player names string on this example?




Re: Getting string from inputtext - Lordzy - 02.02.2017

Extracting data from inputtext of a list-type dialog is not safe. Players can modify the inputtext you get as response. It's not recommended unless you plan on saving the content shown in dialog first and then comparing it with the corresponding list's data. Anyway, sticking to what you've asked for - you can use sscanf with it's quiet-mode to extract the name only.
pawn Code:
new tmpName[MAX_PLAYER_NAME + 1];
inputtext[1] = ' '; //Assuming your inputtext will be from each line only. Replacing '.' to ' ' (space) to make it use for current version of sscanf.
sscanf(inputtext, "?<SSCANF_QUIET=1>{d}s[25]'\t'{s}", tmpName);
//tmpName now holds the name.



Re: Getting string from inputtext - rOps - 02.02.2017

Thank you.