Advertisement
Guest User

FS Sistema VIP (ZCMD + SSCANF) [TS]

a guest
Jun 2nd, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3.                         * Sistema de VIP criado por: MiqueiasBarros *
  4.                                 * MSN: miqueiasrox@msn.com  *
  5.  _____     _        _ _____
  6. |_   _|   | |      | /  ___|
  7.   | | ___ | |_ __ _| \ `--.  __ _ _ __ ___  _ __
  8.   | |/ _ \| __/ _` | |`--. \/ _` | '_ ` _ \| '_ \
  9.   | | (_) | || (_| | /\__/ / (_| | | | | | | |_) |
  10.   \_/\___/ \__\__,_|_\____/ \__,_|_| |_| |_| .__/
  11.                                            | |
  12.                                            |_|                         
  13.   *** Não retire os créditos! ***
  14. acesse
  15. http://total-samp.blogspot.com
  16. http://total-samp.blogspot.com
  17. http://total-samp.blogspot.com
  18. */
  19.  
  20.  
  21. #include a_samp
  22. #include zcmd
  23. new pVip [ MAX_PLAYERS ] ;
  24.  
  25. #if defined FILTERSCRIPT
  26.  
  27. public OnFilterScriptInit ( )
  28. {
  29.     print ( "** Filterscript ligado com sucesso! **" ) ;
  30.     print ( "*** Criado por: MiqueiasBarros ***" ) ;
  31.     return 1;
  32. }
  33.  
  34. public OnFilterScriptExit ( )
  35. {
  36.     print ( "** Filterscript desligado com sucesso! **" ) ;
  37.     print ( "*** Criado por: MiqueiasBarros ***" ) ;
  38.     return 1;
  39. }
  40.  
  41. #else
  42.  
  43. main ( )
  44. {
  45.     print ( "* FilterScript de Vip criado por MiqueiasBarros *" ) ;
  46.     print ( "*** NÃO REMOVA OS CRÉDITOS!!! ***" ) ;
  47. }
  48.  
  49. #endif
  50.  
  51. public OnPlayerSpawn ( playerid )
  52. {
  53.     SendClientMessage ( playerid , 0xFFA500AA , "* Este servidor possui um sistema de Vip criado por MiqueiasBarros *" ) ;
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerCommandPerformed ( playerid , cmdtext [ ] , success )
  58. {
  59.     return 1;
  60. }
  61.  
  62. //      * Inicio dos comandos *     //
  63. CMD :darvip ( playerid , params [ ] )
  64. {
  65.     if ( IsPlayerConnected ( playerid ) )
  66.     {
  67.         if ( IsPlayerAdmin ( playerid ) )
  68.         {
  69.             new
  70.                 nom [ MAX_PLAYER_NAME ] ,
  71.                 str [ 79 ] ,
  72.                 pid ,
  73.                 level
  74.             ;
  75.  
  76.             if ( sscanf ( params, "ui" , pid , level ) ) return SendClientMessage ( playerid , 0xBEBEBEAA , "USO CORRETO: /darvip [playerid] [level ~ 0-3]" ) ;
  77.             if ( level <= 0 && level >= 3 ) return SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Level de 0 à 3!" ) ;
  78.             if ( level <= 0 ) return SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você só pode setar de 1 à 3!" ) ;
  79.             if ( level >= 1 && level < 3)
  80.             {
  81.                 pVip [ pid ] = level ;
  82.                 GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
  83.                 GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
  84.                 format ( str , sizeof ( str ) , "* Você setou o level vip de %s para %d." , pid , level ) ;
  85.                 SendClientMessage ( playerid , 0x00FF00AA , str ) ;
  86.                 format ( str , sizeof ( str ) , "* %s setou seu level vip para %d." , nom , level ) ;
  87.                 SendClientMessage ( playerid , 0x00FF00AA , str ) ;
  88.             }
  89.         }
  90.         else
  91.             SendClientMessage ( playerid, 0x8B1A1AAA , "[ERRO] Você não está logado na RCON!" ) ;
  92.     }
  93.     else
  94.         SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Player não conectado!" ) ;
  95.     return 1;
  96. }
  97.  
  98. CMD :vips ( playerid , params [ ] )
  99. {
  100.     if ( IsPlayerConnected ( playerid ) )
  101.     {
  102.         new
  103.             pn [ MAX_PLAYER_NAME ] ,
  104.             str [ 56 ],
  105.             Count = 0
  106.         ;
  107.  
  108.  
  109.         for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  110.         {
  111.             if ( IsPlayerConnected ( i ) )
  112.             {
  113.                 GetPlayerName ( i , pn , sizeof ( pn ) ) ;
  114.                 if ( pVip [ i ] >= 1 )
  115.                 {
  116.                     Count ++ ;
  117.                     format ( str , sizeof ( str ) , "Vip Level %d: %s" , pVip[i] , pn ) ;
  118.                     SendClientMessage ( playerid , 0xB22222AA , str ) ;
  119.                 }
  120.             }
  121.         }
  122.         if ( Count == 0 )
  123.         {
  124.             SendClientMessage ( playerid , 0x8B1A1AAA , "* Nenhum player VIP Online" ) ;
  125.         }
  126.     }
  127.     return 1;
  128. }
  129.  
  130. CMD :cvip ( playerid , params [ ] )
  131. {
  132.     if ( IsPlayerConnected ( playerid ) )
  133.     {
  134.         new
  135.             pnom [ MAX_PLAYER_NAME ] ,
  136.             texto [ 128 ] ,
  137.             str [ 79 ]
  138.         ;
  139.  
  140.         if ( pVip [ playerid ] >= 1 )
  141.         {
  142.             GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  143.             if ( sscanf ( params, "s" , texto ) ) return SendClientMessage ( playerid , 0x8B1A1AAA , "USO CORRETO: /cvip [texto]" ) ;
  144.             format ( str , sizeof ( str ) , "|| Chat Vip: Player %s | Mensagem: %s" , pnom , texto ) ;
  145.             for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  146.             {
  147.                 if ( pVip [ i ] > 0 )
  148.                 {
  149.                     SendClientMessage ( i , 0x00FFFFAA, str ) ;
  150.                 }
  151.             }
  152.         }
  153.     }
  154.     else
  155.         SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Player não conectado!" ) ;
  156.     return 1;
  157. }
  158.  
  159. CMD :ajudavip ( playerid , params [ ] )
  160. {
  161.     if ( pVip [ playerid ] >= 1 )
  162.     {
  163.         new
  164.             dial [ 500 ]
  165.         ;
  166.  
  167.         format ( dial , sizeof ( dial ) , "{6495ED}Todos comandos vip\n{EE82EE}Para dar vip: {FFFFFF}/darvip\n{EE82EE}Para vêr vips online: {FFFFFF}/vips\n{EE82EE}Chat vip: {FFFFFF}/cvip" ) ;
  168.         ShowPlayerDialog ( playerid , 999 , DIALOG_STYLE_MSGBOX , "{FFFF00}Comandos Vip" , dial , "OK" , "" ) ;
  169.     }
  170.     else
  171.         SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP!" ) ;
  172.     return 1;
  173. }
  174. //      * Fim dos comandos *      //
  175.  
  176. stock sscanf(string[], format[], {Float,_}:...)
  177. {
  178.     #if defined isnull
  179.         if (isnull(string))
  180.     #else
  181.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  182.     #endif
  183.         {
  184.             return format[0];
  185.         }
  186.     #pragma tabsize 4
  187.     new
  188.         formatPos = 0,
  189.         stringPos = 0,
  190.         paramPos = 2,
  191.         paramCount = numargs(),
  192.         delim = ' ';
  193.     while (string[stringPos] && string[stringPos] <= ' ')
  194.     {
  195.         stringPos++;
  196.     }
  197.     while (paramPos < paramCount && string[stringPos])
  198.     {
  199.         switch (format[formatPos++])
  200.         {
  201.             case '\0':
  202.             {
  203.                 return 0;
  204.             }
  205.             case 'i', 'd':
  206.             {
  207.                 new
  208.                     neg = 1,
  209.                     num = 0,
  210.                     ch = string[stringPos];
  211.                 if (ch == '-')
  212.                 {
  213.                     neg = -1;
  214.                     ch = string[++stringPos];
  215.                 }
  216.                 do
  217.                 {
  218.                     stringPos++;
  219.                     if ('0' <= ch <= '9')
  220.                     {
  221.                         num = (num * 10) + (ch - '0');
  222.                     }
  223.                     else
  224.                     {
  225.                         return -1;
  226.                     }
  227.                 }
  228.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  229.                 setarg(paramPos, 0, num * neg);
  230.             }
  231.             case 'h', 'x':
  232.             {
  233.                 new
  234.                     num = 0,
  235.                     ch = string[stringPos];
  236.                 do
  237.                 {
  238.                     stringPos++;
  239.                     switch (ch)
  240.                     {
  241.                         case 'x', 'X':
  242.                         {
  243.                             num = 0;
  244.                             continue;
  245.                         }
  246.                         case '0' .. '9':
  247.                         {
  248.                             num = (num << 4) | (ch - '0');
  249.                         }
  250.                         case 'a' .. 'f':
  251.                         {
  252.                             num = (num << 4) | (ch - ('a' - 10));
  253.                         }
  254.                         case 'A' .. 'F':
  255.                         {
  256.                             num = (num << 4) | (ch - ('A' - 10));
  257.                         }
  258.                         default:
  259.                         {
  260.                             return -1;
  261.                         }
  262.                     }
  263.                 }
  264.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  265.                 setarg(paramPos, 0, num);
  266.             }
  267.             case 'c':
  268.             {
  269.                 setarg(paramPos, 0, string[stringPos++]);
  270.             }
  271.             case 'f':
  272.             {
  273.  
  274.                 new changestr[16], changepos = 0, strpos = stringPos;
  275.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  276.                 {
  277.                     changestr[changepos++] = string[strpos++];
  278.                     }
  279.                 changestr[changepos] = '\0';
  280.                 setarg(paramPos,0,_:floatstr(changestr));
  281.             }
  282.             case 'p':
  283.             {
  284.                 delim = format[formatPos++];
  285.                 continue;
  286.             }
  287.             case '\'':
  288.             {
  289.                 new
  290.                     end = formatPos - 1,
  291.                     ch;
  292.                 while ((ch = format[++end]) && ch != '\'') {}
  293.                 if (!ch)
  294.                 {
  295.                     return -1;
  296.                 }
  297.                 format[end] = '\0';
  298.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  299.                 {
  300.                     if (format[end + 1])
  301.                     {
  302.                         return -1;
  303.                     }
  304.                     return 0;
  305.                 }
  306.                 format[end] = '\'';
  307.                 stringPos = ch + (end - formatPos);
  308.                 formatPos = end + 1;
  309.             }
  310.             case 'u':
  311.             {
  312.                 new
  313.                     end = stringPos - 1,
  314.                     id = 0,
  315.                     bool:num = true,
  316.                     ch;
  317.                 while ((ch = string[++end]) && ch != delim)
  318.                 {
  319.                     if (num)
  320.                     {
  321.                         if ('0' <= ch <= '9')
  322.                         {
  323.                             id = (id * 10) + (ch - '0');
  324.                         }
  325.                         else
  326.                         {
  327.                             num = false;
  328.                         }
  329.                     }
  330.                 }
  331.                 if (num && IsPlayerConnected(id))
  332.                 {
  333.                     setarg(paramPos, 0, id);
  334.                 }
  335.                 else
  336.                 {
  337.                     #if !defined foreach
  338.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  339.                         #define __SSCANF_FOREACH__
  340.                     #endif
  341.                     string[end] = '\0';
  342.                     num = false;
  343.                     new
  344.                         name[MAX_PLAYER_NAME];
  345.                     id = end - stringPos;
  346.                     foreach (Player, playerid)
  347.                     {
  348.                         GetPlayerName(playerid, name, sizeof (name));
  349.                         if (!strcmp(name, string[stringPos], true, id))
  350.                         {
  351.                             setarg(paramPos, 0, playerid);
  352.                             num = true;
  353.                             break;
  354.                         }
  355.                     }
  356.                     if (!num)
  357.                     {
  358.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  359.                     }
  360.                     string[end] = ch;
  361.                     #if defined __SSCANF_FOREACH__
  362.                         #undef foreach
  363.                         #undef __SSCANF_FOREACH__
  364.                     #endif
  365.                 }
  366.                 stringPos = end;
  367.             }
  368.             case 's', 'z':
  369.             {
  370.                 new
  371.                     i = 0,
  372.                     ch;
  373.                 if (format[formatPos])
  374.                 {
  375.                     while ((ch = string[stringPos++]) && ch != delim)
  376.                     {
  377.                         setarg(paramPos, i++, ch);
  378.                     }
  379.                     if (!i)
  380.                     {
  381.                         return -1;
  382.                     }
  383.                 }
  384.                 else
  385.                 {
  386.                     while ((ch = string[stringPos++]))
  387.                     {
  388.                         setarg(paramPos, i++, ch);
  389.                     }
  390.                 }
  391.                 stringPos--;
  392.                 setarg(paramPos, i, '\0');
  393.             }
  394.             default:
  395.             {
  396.                 continue;
  397.             }
  398.         }
  399.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  400.         {
  401.             stringPos++;
  402.         }
  403.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  404.         {
  405.             stringPos++;
  406.         }
  407.         paramPos++;
  408.     }
  409.     do
  410.     {
  411.         if ((delim = format[formatPos++]) > ' ')
  412.         {
  413.             if (delim == '\'')
  414.             {
  415.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  416.             }
  417.             else if (delim != 'z')
  418.             {
  419.                 return delim;
  420.             }
  421.         }
  422.     }
  423.     while (delim > ' ');
  424.     return 0;
  425. }
  426.  
  427. /*
  428.  
  429.                         * Sistema de VIP criado por: MiqueiasBarros *
  430.                                 * MSN: miqueiasrox@msn.com  *
  431.                               *** Não retire os créditos! ***
  432.  
  433. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement