SA-MP Forums Archive
Detect the two first letters from a string? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Detect the two first letters from a string? (/showthread.php?tid=158195)



Detect the two first letters from a string? - Fj0rtizFredde - 09.07.2010

Hello
I need some help with detect/take out some parts of a string if it is possible.
Example: Lets say that I have a dialog and I type in "Hello". Is it then possible to just get the two first letters from the the inputtext? So my output will be like: "You word Hello starts with He."

Hope you get what I mean


Re: Detect the two first letters from a string? - Zezombia - 09.07.2010

https://sampwiki.blast.hk/wiki/Strmid

For example:
pawn Код:
strmid(string, "Hello", 0, 2);
That would make "string" be "He".


Re: Detect the two first letters from a string? - Fj0rtizFredde - 10.07.2010

Could you show me an example of how to use it with lets say.. Inputtext from one of my dialogs?

Or if anyone else knows a way/example then it would be great


Re: Detect the two first letters from a string? - bigcomfycouch - 10.07.2010

https://sampwiki.blast.hk/wiki/Firstchars


Re: Detect the two first letters from a string? - Grim_ - 10.07.2010

new string[128];
strmid(inputtext, string, 2, strlen(inputtext));


Re: Detect the two first letters from a string? - Jefff - 10.07.2010

pawn Код:
printf("%c%c",inputtext[0],inputtext[1]);



Re: Detect the two first letters from a string? - Fj0rtizFredde - 10.07.2010

Thanks all I will try out the things and see what I can do with it