Advertisement
MiqueiasBarros

[FilterScript] Sistema VIP v1.0 (ZCMD + SSCANF)

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