Long Chat -
StR_MaRy - 19.05.2015
hi to all guys i want to make a longer chat text like this
/o 12345678910111213141516171819202122232425262728293 03132333435363738394041 - i have a text like this when no the numbers there is my text but i want to make it like this
/o 12345678910111213141516171819202122232425262728293 03132333435363738394041424344454647484950515253545 5565758596061626364656667686970
i mean 2 lines not 1 i edited new result[56]; to 500 but same problem , string 126 to 500 same problem , can some1 help me ?
Re: Long Chat -
Dignity - 19.05.2015
Older function of mine, taken from my Sublimity RP V2 gamemode. Should work though. What it does is split strings in half instead of cutting them off.
pawn Код:
ReturnSplittedMessage(playerid, senderid, color, text[], type)
{
if(strlen(text) <= 70) SendClientMessage(playerid, color, text);
else if(strlen(text) > 70)
{
// Was "105" before, change back if shit fucks up
if(strlen(text) > 144)
return SendClientMessage(senderid, COLOR_ERROR, "[ERROR]:{E0E0E0} Message format request can't be completed because the string exceeds the limit!");
new texts[74];
strmid(texts, text, 70, 144);
strdel(text, 70, 144);
// Following causes strins error and fucks the function up:
// strins(text, " ..", 70, 3);
// printf("START %s END", text);
if(type == 1) // Local
{
SendClientMessage(playerid, color, text);
SendClientMessage(playerid, color, texts);
}
else if(type == 2) // Global
{
SendClientMessageToAll(color, text);
SendClientMessageToAll(color, texts);
}
}
return true;
}
EDIT: I added a "type" parameter because I didn't want to use two seperate functions to split strings (or use loops), as I was also using this for global OOC chats. You don't need it.
Picture:
http://i.imgur.com/rneBBEL.png
Re: Long Chat -
StR_MaRy - 19.05.2015
yes , thx but a question where should i put this ?
Re: Long Chat -
HeLiOn_PrImE - 20.05.2015
Quote:
Originally Posted by Satori_Komeiji
Older function of mine, taken from my Sublimity RP V2 gamemode. Should work though. What it does is split strings in half instead of cutting them off.
[...]
EDIT: I added a "type" parameter because I didn't want to use two seperate functions to split strings (or use loops), as I was also using this for global OOC chats. You don't need it.
Picture: http://i.imgur.com/rneBBEL.png
|
Please take your time and tell him how to implement that function, because he doesn't have the experience to figure it out.
He also came to me for help, but I can't do any better, since I never studied this subject and I didn't create the code at hand.
Re: Long Chat -
Dignity - 20.05.2015
Quote:
Originally Posted by StR_MaRy
yes , thx but a question where should i put this ?
|
Anywhere as long as it isn't in a callback.
A little info about the params:
playerid - used to send the message to a player. It's there because this function was originally used in a loop.
senderid - should be "playerid" in most cases. This is used to send a warning message to the sender in case their input exceeded the limit of 144.
color - self explanatory
text - string you want to submit
type - 1 = sendclientmessage, 2 = sendclientmessagetoall.
Essentially, you should just do this:
pawn Код:
public OnPlayerText(playerid, text[]) {
ReturnSplittedMessage(playerid, playerid, 0xffffffff, "Text", 2);
return 0;
}
EDIT: If you want to have a local chat, add this function as well (again, anywhere outside any brackets) and use it instead of ReturnSplittedMessage.
pawn Код:
SendLocalMessage(playerid, color, text[], Float: range)
{
new Float: psX, Float: psY, Float: psZ;
GetPlayerPos(playerid, psX, psY, psZ);
foreach(new i: Player)
{
if(IsPlayerInRangeOfPoint(i, range, psX, psY, psZ))
{
ReturnSplittedMessage(i, playerid, color, text, 1);
}
}
return true;
}
Using this, you only need to do this instead of SendClientMessage:
pawn Код:
// senderid, colorid, text, range
SendLocalMessage(playerid, 0xffffffff, text[], Float: range)
It will only send messages to people that are in range of the provided range