ID:2358206
 
(See the best response by Marekssj3.)
Code:
mob/verb/Sayt(msg as text)
newmsg = ""
if(length(msg) > 15)
newmsg = msg // this would be the continuation after 15 characters
alert("[msg]") // he would only get a max of 15 characters alert
spawn(30)
if(newmsg && length(newmsg)) alert("[msg]") // he gets a new alert with the continuation after the 15 characters


Problem description:I'm having problem, I dont know what to do for limit the alert characters, I want to 15 per alert, if exceed 15 it would make another one even if it's only 1 characters. I'm not what I have to make to do this.
Best response
I'm not sure i understand, i'll hope this piece of code help you.

/*
copytext(T,Start=1,End=0) -

Copy characters in T between Start and End.
The default end position of 0 stands for the lentext(T)+1,
so by default the entire text string is copied.
*/


mob/verb/___Text(t as text,n as num)
var/list.L = cutText(t, 3) //Get list from cutText proc
for(var/v in L)
alert(v)



mob/proc/cutText(var/text, var/c)//text is text to cut, n is how long text chain is
var/list/L=list()//Prepare empty list for chains
var/l=length(text)//Text length
var/start=1// The text character position in which to begin the copy.
var/stop=0//The text character position immediately following the last character to be copied.
for(var/i=1,i<=round(l/c,1),i++)
stop=i*c+1
L.Add(copytext(text,start,stop)) //UP
start=stop
return L// return list with chains
You'd want to split the string into 15 (or less) character parts, then put each one into a list: Marekssj3 showed this. There's an easier solution though, using some of the built-in string functions and a little regex.
mob/verb/say(t as text)
. = splittext(t, regex(".{1,15}"), 1, 0, 1)
for(var/x in .)
if(x) // splittext() was adding empty strings, couldn't be bothered to find another solution
alert(src, x)

If you'd like to read about splittext() or regex(), you can press F1 in DreamMaker to open the reference to search for them.
Thank you both.