Splitting a string into two parts, and then combining them again
#1

pawn Код:
CMD:pager ( playerid, params[] )
{
    new
        text [ 64 ];
       
    if( sscanf( params, "s[64]", text ) )
        return false;
       
       
    new
        pStr [ 128 ],
        pStr_Extracted [ 128 ];
       
    if( strlen ( text ) <= 57 )
    {
        format( pStr, 128, "PAGER: ~w~%s", text );
    }
    else
    {
        format( pStr, 128, "PAGER: ~w~%s~n~\t\t..", text );
        printf( pStr );
       
        strmid ( pStr_Extracted, pStr, 57, strlen ( pStr ) );
        printf( pStr_Extracted );
        strcat ( pStr, pStr_Extracted, 128 );
    }
       
    PlayerTextDrawHide ( playerid, Pager [ playerid ] );
    PlayerTextDrawSetString ( playerid, Pager [ playerid ], pStr );
    PlayerTextDrawShow( playerid, Pager [ playerid ] );
    return true;
}
Currently I've got this, and it repeats the "pStr_Extracted" back, what's wrong?

Picture for a better explaination:
Reply
#2

Can't you just use strins to insert a linefeed at your desired position? Or am I overlooking something?
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Can't you just use strins to insert a linefeed at your desired position? Or am I overlooking something?
Actually, you'd be correct. Thanks, had this weird feeling I had to use strmid, and I have no idea why.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)