SA-MP Forums Archive
Wrap text !! - 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: Wrap text !! (/showthread.php?tid=527278)



Wrap text !! - hafs - 21.07.2014

hello,

How to cut a sentence without cutting word?

I wanted to take the logic of php but I do not see how to convert pawn

Код:
$maxchar= 20;
if (strlen($string) > $maxchar) 
 $string= substr($string, 0, $maxchar) ;
 $space= strrpos($string, " ") ;
 $string= substr($string, 0, $space)."..." ;

echo $string;
thanks !!


Re: Wrap text !! - ikey07 - 21.07.2014

Just an idea.

start to scan the row from the length you want to cut, and at first " " symbol split it.

Like you want that it sends msgs not longer than 128 symbols,

then just start to
pawn Код:
for(new i = 120; i < strlen(string); i++)
{
if(string[i] == ' ') { split at 130 for example; }
}
and you know at which place to split it.