SA-MP Forums Archive
Splitting string after length - 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: Splitting string after length (/showthread.php?tid=95219)



Splitting string after length - Norn - 02.09.2009

pawn Код:
if(strlen(message) <= 51)
        {
        format(string,sizeof(string),"~g~Update: ~w~%s", message);
        }
        else
        {
// Do splitting crap.
          format(string,sizeof(string),"~g~Update: ~w~%s~n~%s", message[firstline], message[secondline]);
        }
I want to make it so that if its above 51 characters it'll create a new line, it's just the splittings the problem.

So like, "The blue cat went around the world in his blue tr~n~"
"uck", i want it to start at the beginning of a new word so its like:

"The blue cat went around the world~n~"
"in his blue truck"

If you know what i mean, i've searched but found no result and i don't have the faintest idea how to do this.

Anyone, i would be so greatful.


Re: Splitting string after length - JaTochNietDan - 02.09.2009

Use strmid.

pawn Код:
strmid(string, message, 50, strlen(message)); // String now contains the rest of the message



Re: Splitting string after length - Norn - 02.09.2009

Thank you!