how to make chat continue in 2nd line -
DGRP - 05.02.2017
Hello, I just want to ask, How do I make my chat to the 2nd line if the chat in line 1 is already full? example:
/b HELLO WORLD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ... <<<<<<EXAMPLE 128 CHARACTERSS
then I want to continue it in 2nd line, so it will be something like
Quote:
James_Phillip: HELLO WORLD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ...
James_Phillip: ... HIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
|
I tried using code from THE_KNOWN but I keep getting error
Code:
stock splitstring(actualstring,&split1[],&split2[])
{
if(sizeof(actualstring) > 100)
{
new rlen = sizeof(actualstring) - 100, str[rlen];
format(split1,100,"%s",actualstring);
for(new i;i<rlen;i++)
{
split2[i]=actualstring[99+i];
}
}
return 1;
}
Error:
Quote:
error 067: variable cannot be both a reference and an array (variable "split1")
|
Re: how to make chat continue in 2nd line -
SyS - 05.02.2017
Code:
stock splitstring(actualstring,&split1[],&split2[])
Arrays are passed by reference you don't need to use & remove it
Re: how to make chat continue in 2nd line -
DGRP - 05.02.2017
Quote:
Originally Posted by Sreyas
Code:
stock splitstring(actualstring,&split1[],&split2[])
Arrays are passed by reference you don't need to use & remove it
|
how do I make it continue in 2nd line without it?
Re: how to make chat continue in 2nd line -
SyS - 05.02.2017
Quote:
Originally Posted by DGRP
how do I make it continue in 2nd line without it?
|
It is not the thing splitting it. & means passing the memory address of a variable to function so what ever the changes made in that function's formal parameter affects in actual parameter (calling statement).
But the size of the array can't be predicted by compiler as it needs some computation to determine the size and is static allocation(cant predict what happens in run time).Therefore the arrays can't be copied and can't be passed as value.Hence,using references on array is pointless.What ever changes made in formal parameter will be reflected back to actual parameter if it is an array.
Note:Using
strmid function you can make this function more simple.
Re: how to make chat continue in 2nd line -
GoldenLion - 05.02.2017
You could do something like this instead:
Code:
if (strlen(string) > 100)
{
new message[100];
format(message, sizeof(message), "%.100s", string);
SendClientMessage(playerid, -1, message);
format(message, sizeof(message), "...%s", string[100]);
SendClientMessage(playerid, -1, message);
}
else SendClientMessage(playerid, -1, string);