Advertisement
MiqueiasBarros

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

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