SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Making the chat and the message split? (https://forum.sa-mp.com/showthread.php?t=396086)

JaKe Elite 29/11/2012 09:41 AM

Making the chat and the message split?
 
Is it possible to split up the chat??

Like if i've 120 lengths in my word it will automatically do like

Code:

I love Chicken I ha-
te McDonalds

I've one but it shows the name like

Code:

* Romel Rowan junking in the yard for 3 mon-
* Romel Rowan ths

Here is the code

pawn Code:
if(IsPlayerInRangeOfPoint(i, radi, x, y, z))
{
    if(strlen(string) <= 120) SendClientMessage(i, color, string);
    else
    {
        new texts[120];
        strmid(texts, string, 120, 129);
        strins(string, "-", 120, 1);
        strdel(string, 121, 129);
        SendClientMessage(i, color, string);
        SendClientMessage(i, color, string);
    }
}

Boooth 29/11/2012 09:48 AM

Re: Making the chat and the message split?
 
Can you show me your OnPlayerCommandText.

JaKe Elite 29/11/2012 09:49 AM

Re: Making the chat and the message split?
 
I'm not using OnPlayerCommandText

GiamPy. 29/11/2012 12:39 PM

Re: Making the chat and the message split?
 
pawn Code:
stock SendPlayerExtendedMessage(playerid, color, const string[])
{
    new firstString[128],
        secondString[128],
        finalStringLINE1[128],
        finalStringLINE2[128];
       
    if(strlen(string) > 70) // here you can choose the lenght of the first string
    {
        format(firstString, sizeof(firstString), string);
        format(secondString, sizeof(secondString), string);
       
        strdel(firstString, 70, 140);
        strdel(secondString, 0, 70);
       
        format(finalStringLINE1, sizeof(finalStringLINE1), "%s ...", firstString);
        SendClientMessage(playerid, color, finalStringLINE1);
        format(finalStringLINE2, sizeof(finalStringLINE2), "... %s", secondString);
        SendClientMessage(playerid, color, finalStringLINE2);
        return true;
    }
    else
    {
        SendClientMessage(playerid, color, string);
        return true;
    }
}

[MM]RoXoR[FS] 29/11/2012 12:46 PM

Re: Making the chat and the message split?
 
Try this

UNTESTED


pawn Code:
if(IsPlayerInRangeOfPoint(i, radi, x, y, z))
{
    new j=0;
    new temp[121];
    for(;string[j]!='\0';)
    {
        for(new i=0;i<=119 && string[j]!='\0';++i)
        {
            temp[i]=string[j];
            ++j;
        }
        temp[120]='-';
        SendClientMessage(i, color,temp);
    }
}

JaKe Elite 30/11/2012 01:03 AM

Re: Making the chat and the message split?
 
I will try later. I'm in mobile.

JaKe Elite 30/11/2012 10:25 AM

Re: Making the chat and the message split?
 
RoXor it works but it fails to split up.
I type random words at the end i type.

Code:

xenialoveu
but it shows

Code:

xenialove-x

cosbraa 30/11/2012 10:46 AM

Re: Making the chat and the message split?
 
pawn Code:
stock strsplit(source[], first[], second[], split_pos)
{
    strmid(source, first, 0, split_pos);
    strins(first, "-", split_pos);
    strmid(source, second, split_pos, strlen(source));
    return 1;
}
I had something like this, don't have access to it right now.
Might have to play around with it, but it worked for me.

JaKe Elite 30/11/2012 10:49 AM

Re: Making the chat and the message split?
 
How could i use it.?

cosbraa 30/11/2012 11:14 AM

Re: Making the chat and the message split?
 
pawn Code:
CMD:me(playerid, params[])
{
    new line1[128], line2[128], string[128];
    if(strlen(params) > 120)
    {
        // "* 012345678901234567890123 " = 27 characters. 128 - 27 = 101
        strsplit(params, line1, line2, 101);
        format(string, sizeof(string), "* %s %s", GetNameEx(playerid), line1);
        NearByMessage(playerid, COLOUR, string);
        format(string, sizeof(string), "* %s ((%s)), line2, GetNameEx(playerid));
        NearByMessage(playerid, COLOUR, string);
    }
    else
    {
        format(string, sizeof(string), "
* %s %s", GetNameEx(playerid), params);
        NearByMessage(playerid, COLOUR, string);
    }
    return 1;
}
that kind of way. on ipod, may have mistakes.


All times are GMT. The time now is 05:55 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.