SA-MP Forums Archive
Splitting a string into two parts, and then combining them again - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Splitting a string into two parts, and then combining them again (/showthread.php?tid=422667)



Splitting a string into two parts, and then combining them again - 2KY - 14.03.2013

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:



Re: Splitting a string into two parts, and then combining them again - Vince - 14.03.2013

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


Re: Splitting a string into two parts, and then combining them again - 2KY - 14.03.2013

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.