Detecting a word and not cutting it?
#1

I am using the following command:

pawn Код:
if(strcmp(cmd, "/do", true) == 0)
    {
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[128];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SyntaxMessage(playerid, COLOR_SYNTAX, "/do [action]");
            return 1;
        }
        new fxString[128]; format(fxString, sizeof(fxString), "* %s ((%s))", result, PlayerRPNameEx(playerid));
       
        if(strlen(fxString) > (82 + MAX_PLAYER_NAME + 4))
        {
            format(fxString, sizeof(fxString), "* %s", result);
            if(IsPlayerLoggedIn(playerid))
            {
                new Float:posx, Float:posy, Float:posz;
                new Float:oldposx, Float:oldposy, Float:oldposz;
                new Float:tempposx, Float:tempposy, Float:tempposz;
                new invehicle[MAX_PLAYERS];
                new virtualworld = GetPlayerVirtualWorld(playerid);
                new interior = GetPlayerInterior(playerid);
                new vehicleid = GetPlayerVehicleID(playerid);
                new ivehicleid;
                new col1 = COLOR_PURPLE, col2 = COLOR_PURPLE, col3 = COLOR_PURPLE, col4 = COLOR_PURPLE, col5 = COLOR_PURPLE, Float:radi=30.0;
                if(vehicleid)
                {
                    GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
                }
                else
                {
                    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
                    vehicleid = GetPlayerVehicleID(playerid);
                }
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerLoggedIn(i))
                    {
                        if(!BigEar[i])
                        {
                            if(GetPlayerVirtualWorld(i) == virtualworld)
                            {
                                if((GetPlayerInterior(i) == interior))
                                {
                                    if(vehicleid)
                                    {
                                        if(IsPlayerInVehicle(i,vehicleid)) invehicle[i] = 1;
                                    }
                                    if(!invehicle[i])
                                    {
                                        if(IsPlayerInAnyVehicle(i))
                                        {
                                            ivehicleid = GetPlayerVehicleID(i);
                                            GetVehiclePos(ivehicleid,posx,posy,posz);
                                        }
                                        else
                                        {
                                            GetPlayerPos(i,posx,posy,posz);
                                        }
                                        tempposx = (oldposx -posx);
                                        tempposy = (oldposy -posy);
                                        tempposz = (oldposz -posz);
                                        if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                                        {
                                            new len = strlen(fxString),
                                                _iL = len / 82;

                                            if( ( len % 82 ) ) _iL++;
                                            new _Line[82 + (7 + MAX_PLAYER_NAME + 5)];

                                            new _:_i@Index;
                                            while( _i@Index < _iL )
                                            {
                                                if( _i@Index == 0 )
                                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );
                                                else
                                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );

                                                #if defined FINAL_DOTS
                                                if( _iL > 1 )
                                                {
                                                    if( _i@Index == 0 )
                                                    {
                                                        format( _Line, sizeof _Line, "%s ((%s)) ...", _Line, PlayerRPNameEx(playerid) );
                                                    }
                                                    else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
                                                    {
                                                        format( _Line, sizeof _Line, "* ... %s ...", _Line );
                                                    }
                                                    else
                                                    {
                                                        format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
                                                    }
                                                }
                                                #endif
                                                ////////////
                                                SendClientMessage( i, col1, _Line );
                                                format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
                                                LogPlayer(i, _pLog);
                                                ///////////
                                                _i@Index++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        new len = strlen(fxString) + (6 + MAX_PLAYER_NAME),
                                            _iL = len / 82;

                                        if( ( len % 82 ) ) _iL++;
                                        new _Line[82 + (7 + MAX_PLAYER_NAME + 5)];

                                        new _:_i@Index;
                                        while( _i@Index < _iL )
                                        {
                                            if( _i@Index == 0 )
                                                strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );
                                            else
                                                strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );

                                            #if defined FINAL_DOTS
                                            if( _iL > 1 )
                                            {
                                                if( _i@Index == 0 )
                                                {
                                                    format( _Line, sizeof _Line, "%s ((%d))...", _Line, PlayerRPNameEx(playerid) );
                                                }
                                                else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
                                                {
                                                    format( _Line, sizeof _Line, "* ... %s ...", _Line );
                                                }
                                                else
                                                {
                                                    format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
                                                }
                                            }
                                            #endif
                                            ////////////
                                            SendClientMessage( i, col1, _Line );
                                            format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
                                            LogPlayer(i, _pLog);
                                            ///////////
                                            _i@Index++;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            new len = strlen(fxString) + (6 + MAX_PLAYER_NAME),
                                _iL = len / 82;
                               
                            if( ( len % 82 ) ) _iL++;
                            new _Line[82 + (7 + MAX_PLAYER_NAME + 5)];

                            new _:_i@Index;
                            while( _i@Index < _iL )
                            {
                                if( _i@Index == 0 )
                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );
                                else
                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );

                                #if defined FINAL_DOTS
                                if( _iL > 1 )
                                {
                                    if( _i@Index == 0 )
                                    {
                                        format( _Line, sizeof _Line, "%s ((%d))...", _Line, PlayerRPNameEx(playerid) );
                                    }
                                    else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
                                    {
                                        format( _Line, sizeof _Line, "* ... %s ...", _Line );
                                    }
                                    else
                                    {
                                        format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
                                    }
                                }
                                #endif
                                ////////////
                                SendClientMessage( i, col1, _Line );
                                format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
                                LogPlayer(i, _pLog);
                                ///////////
                                _i@Index++;
                            }
                        }
                    }
                }
            }
        }
        else
        {
            ProxDetector(30.0, playerid, fxString, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        }
        return 1;
    }
The problem is that it cuts a word into half upon detection.

Example:
"* Player1 has a fancy hat on his head along with a parrot on his shoulder sitti ((Player1)) ..."
"* ... ng and looking around ((Player1))"

Is there anyway to detect the word, and if it's too long for the first text, to move it towards the second?
So it'd be like this:

"* Player1 has a fancy hat on his head along with a parrot on his shoulder ((Player1)) ..."
"* ... sitting and looking around ((Player1))"

//

The only lines need to be focues on(that actually cut & send):
pawn Код:
new len = strlen(fxString),
                                                _iL = len / 82;

                                            if( ( len % 82 ) ) _iL++;
                                            new _Line[82 + (7 + MAX_PLAYER_NAME + 5)];

                                            new _:_i@Index;
                                            while( _i@Index < _iL )
                                            {
                                                if( _i@Index == 0 )
                                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );
                                                else
                                                    strmid( _Line, fxString, ( _i@Index * 82 ), ( _i@Index * 82 ) + 82 );

                                                #if defined FINAL_DOTS
                                                if( _iL > 1 )
                                                {
                                                    if( _i@Index == 0 )
                                                    {
                                                        format( _Line, sizeof _Line, "%s ((%s)) ...", _Line, PlayerRPNameEx(playerid) );
                                                    }
                                                    else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
                                                    {
                                                        format( _Line, sizeof _Line, "* ... %s ...", _Line );
                                                    }
                                                    else
                                                    {
                                                        format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
                                                    }
                                                }
                                                #endif
                                                ////////////
                                                SendClientMessage( i, col1, _Line );
                                                format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
                                                LogPlayer(i, _pLog);
                                                ///////////
                                                _i@Index++;
                                            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)