SA-MP Forums Archive
String = two parts - 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: String = two parts (/showthread.php?tid=490968)



String = two parts - Riwerry - 28.01.2014

Hello guys, how can I make this? I want to make this string (it is inputtext) created from two parts of inputtext that mean:

"NAME_LASTNAME" = inputtext, I want to create name lastname array will be 9 and I need so before these two strings will be _ as you see higher. thx


Re: String = two parts - fordawinzz - 28.01.2014

use sscanf.
pawn Код:
new szFirstName[9], szSecondName[9];
if(!sscanf(inputtext, "p<_>s[9]s[9]", szFirstName, szSecondName)) {
     //names splitted.
}
else {
     //code here..
}



Re: String = two parts - Riwerry - 28.01.2014

This isnt working properly, becouse when I type to inputtext this "_text" it says as it is okay name..

I have got this code, but here is problem not like upper one, but when i type for example "text_" it count as correct name

pawn Код:
if(inputtext[0] != '_' && inputtext[strlen(inputtext)] != '_' && (strfind(inputtext, "_", true) != -1))