Advertisement
Hauke

h_format v.1.0

Oct 1st, 2012
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.08 KB | None | 0 0
  1. // h_format include by Hauke Marquardt alias |-|auke - 01.10.2012
  2. /*
  3. License:
  4.         This code is free: you can redistribute it and/or modify
  5.         it under the terms of the GNU General Public License as published by
  6.         the Free Software Foundation, either version 3 of the License, or
  7.         (at your option) any later version.
  8.  
  9.         This code is distributed in the hope that it will be useful,
  10.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.         GNU General Public License for more details.
  13.  
  14.         You should have received a copy of the GNU General Public License
  15.         along with this program.  If not, see <http://www.gnu.org/licenses/>.
  16.         You´re not allowed to copy any code from this, into your code without
  17.         naming authors name in credits!
  18.        
  19.     - SendClientMessagef(playerid, color, format, { Float , _ } : ... );
  20.     - SendClientMessageToAllf(color, format, { Float , _ } : ... );
  21.     - SetGameModeTextf(format, { Float , _ } : ... );
  22.     - UpdatePlayer3DTextLabelTextf(playerid, 3dTextLabel, color, format, { Float , _ } : ... );
  23.     - Update3DTextLabelTextf(3dTextLabel, color, format, { Float , _ } : ... );
  24.     - TextDrawSetStringf(textdraw, format, { Float , _ } : ... );
  25.     - SetPVarStringf(playerid,"varname", format, { Float , _ } : ... );
  26. */
  27.  
  28. stock SendClientMessagef ( playerid , color , output[ 256 ] , { Float , _ } : ... ) {
  29.     new c = numargs ( ) , idx;
  30.     for ( new i = 3; i < c; i ++ ) {
  31.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  32.         for ( new x; x < strlen ( output ); x ++ ) {
  33.             if ( output[ x ] == '%' ) {
  34.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  35.                     iI = true;
  36.                 if ( output[ x + 1 ] == 'f' )
  37.                     iF = true;
  38.                 strdel ( output , x , x + 2 );
  39.                 p = x;
  40.                 break;
  41.             }
  42.         }
  43.         while ( getarg ( i , idx ) ) {
  44.             Arg[ idx ] = getarg ( i , idx );
  45.             idx ++;
  46.         }
  47.         if ( iI == true )
  48.             format ( Arg , 32 , "%d" , Arg );
  49.         if ( iF == true )
  50.             format ( Arg , 32 , "%f" , Arg );
  51.         idx = 0;
  52.         strins ( output , Arg , p );
  53.     }
  54.     SendClientMessage ( playerid , color , output );
  55. }
  56.  
  57. stock SendClientMessageToAllf ( color , output[ 256 ] , { Float , _ } : ... ) {
  58.     new c = numargs ( ) , idx;
  59.     for ( new i = 2; i < c; i ++ ) {
  60.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  61.         for ( new x; x < strlen ( output ); x ++ ) {
  62.             if ( output[ x ] == '%' ) {
  63.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  64.                     iI = true;
  65.                 if ( output[ x + 1 ] == 'f' )
  66.                     iF = true;
  67.                 strdel ( output , x , x + 2 );
  68.                 p = x;
  69.                 break;
  70.             }
  71.         }
  72.         while ( getarg ( i , idx ) ) {
  73.             Arg[ idx ] = getarg ( i , idx );
  74.             idx ++;
  75.         }
  76.         if ( iI == true )
  77.             format ( Arg , 32 , "%d" , Arg );
  78.         if ( iF == true )
  79.             format ( Arg , 32 , "%f" , Arg );
  80.         idx = 0;
  81.         strins ( output , Arg , p );
  82.     }
  83.     SendClientMessageToAll ( color , output );
  84. }
  85.  
  86. stock SetGameModeTextf ( output[ 256 ] , { Float , _ } : ... ) {
  87.     new c = numargs ( ) , idx;
  88.     for ( new i = 1; i < c; i ++ ) {
  89.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  90.         for ( new x; x < strlen ( output ); x ++ ) {
  91.             if ( output[ x ] == '%' ) {
  92.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  93.                     iI = true;
  94.                 if ( output[ x + 1 ] == 'f' )
  95.                     iF = true;
  96.                 strdel ( output , x , x + 2 );
  97.                 p = x;
  98.                 break;
  99.             }
  100.         }
  101.         while ( getarg ( i , idx ) ) {
  102.             Arg[ idx ] = getarg ( i , idx );
  103.             idx ++;
  104.         }
  105.         if ( iI == true )
  106.             format ( Arg , 32 , "%d" , Arg );
  107.         if ( iF == true )
  108.             format ( Arg , 32 , "%f" , Arg );
  109.         idx = 0;
  110.         strins ( output , Arg , p );
  111.     }
  112.     SetGameModeText ( output );
  113. }
  114.  
  115. stock UpdatePlayer3DTextLabelTextf ( playerid , PlayerText3D:id , color , output[ 256 ] , { Float , _ } : ... ) {
  116.     new c = numargs ( ) , idx;
  117.     for ( new i = 4; i < c; i ++ ) {
  118.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  119.         for ( new x; x < strlen ( output ); x ++ ) {
  120.             if ( output[ x ] == '%' ) {
  121.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  122.                     iI = true;
  123.                 if ( output[ x + 1 ] == 'f' )
  124.                     iF = true;
  125.                 strdel ( output , x , x + 2 );
  126.                 p = x;
  127.                 break;
  128.             }
  129.         }
  130.         while ( getarg ( i , idx ) ) {
  131.             Arg[ idx ] = getarg ( i , idx );
  132.             idx ++;
  133.         }
  134.         if ( iI == true )
  135.             format ( Arg , 32 , "%d" , Arg );
  136.         if ( iF == true )
  137.             format ( Arg , 32 , "%f" , Arg );
  138.         idx = 0;
  139.         strins ( output , Arg , p );
  140.     }
  141.     UpdatePlayer3DTextLabelText ( playerid , id , color , output );
  142. }
  143.  
  144. stock Update3DTextLabelTextf ( PlayerText3D:id , color , output[ 256 ] , { Float , _ } : ... ) {
  145.     new c = numargs ( ) , idx;
  146.     for ( new i = 3; i < c; i ++ ) {
  147.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  148.         for ( new x; x < strlen ( output ); x ++ ) {
  149.             if ( output[ x ] == '%' ) {
  150.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  151.                     iI = true;
  152.                 if ( output[ x + 1 ] == 'f' )
  153.                     iF = true;
  154.                 strdel ( output , x , x + 2 );
  155.                 p = x;
  156.                 break;
  157.             }
  158.         }
  159.         while ( getarg ( i , idx ) ) {
  160.             Arg[ idx ] = getarg ( i , idx );
  161.             idx ++;
  162.         }
  163.         if ( iI == true )
  164.             format ( Arg , 32 , "%d" , Arg );
  165.         if ( iF == true )
  166.             format ( Arg , 32 , "%f" , Arg );
  167.         idx = 0;
  168.         strins ( output , Arg , p );
  169.     }
  170.     Update3DTextLabelText ( id , color , output );
  171. }
  172.  
  173. stock TextDrawSetStringf ( Text:text , output[ 256 ] , { Float , _ } : ... ) {
  174.     new c = numargs ( ) , idx;
  175.     for ( new i = 2; i < c; i ++ ) {
  176.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  177.         for ( new x; x < strlen ( output ); x ++ ) {
  178.             if ( output[ x ] == '%' ) {
  179.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  180.                     iI = true;
  181.                 if ( output[ x + 1 ] == 'f' )
  182.                     iF = true;
  183.                 strdel ( output , x , x + 2 );
  184.                 p = x;
  185.                 break;
  186.             }
  187.         }
  188.         while ( getarg ( i , idx ) ) {
  189.             Arg[ idx ] = getarg ( i , idx );
  190.             idx ++;
  191.         }
  192.         if ( iI == true )
  193.             format ( Arg , 32 , "%d" , Arg );
  194.         if ( iF == true )
  195.             format ( Arg , 32 , "%f" , Arg );
  196.         idx = 0;
  197.         strins ( output , Arg , p );
  198.     }
  199.     TextDrawSetString ( text , output );
  200. }
  201.  
  202. stock SetPVarStringf ( playerid , varname[ ] , output[ 256 ] , { Float , _ } : ... ) {
  203.     new c = numargs ( ) , idx;
  204.     for ( new i = 3; i < c; i ++ ) {
  205.         new Arg[ 32 ] , p , bool:iI , bool:iF;
  206.         for ( new x; x < strlen ( output ); x ++ ) {
  207.             if ( output[ x ] == '%' ) {
  208.                 if ( output[ x + 1 ] == 'd' || output[ x + 1 ] == 'i' )
  209.                     iI = true;
  210.                 if ( output[ x + 1 ] == 'f' )
  211.                     iF = true;
  212.                 strdel ( output , x , x + 2 );
  213.                 p = x;
  214.                 break;
  215.             }
  216.         }
  217.         while ( getarg ( i , idx ) ) {
  218.             Arg[ idx ] = getarg ( i , idx );
  219.             idx ++;
  220.         }
  221.         if ( iI == true )
  222.             format ( Arg , 32 , "%d" , Arg );
  223.         if ( iF == true )
  224.             format ( Arg , 32 , "%f" , Arg );
  225.         idx = 0;
  226.         strins ( output , Arg , p );
  227.     }
  228.     SetPVarString ( playerid , varname , output );
  229. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement