Advertisement
Guest User

cofe

a guest
Aug 4th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.36 KB | None | 0 0
  1. //BytePass v1.2                    PRECISA DE ZCMD + DOF2      ||    CRIE A PASTA BytePass EM scriptfiles
  2.  
  3. #include a_samp
  4. #include zcmd
  5. #include DOF2
  6. //include sscanf
  7. stock sscanf(string[], format[], {Float,_}:...)
  8. {
  9.     #if defined isnull
  10.         if (isnull(string))
  11.     #else
  12.         if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  13.     #endif
  14.         {
  15.             return format[0];
  16.         }
  17.     #pragma tabsize 4
  18.     new
  19.         formatPos = 0,
  20.         stringPos = 0,
  21.         paramPos = 2,
  22.         paramCount = numargs(),
  23.         delim = ' ';
  24.     while (string[stringPos] && string[stringPos] <= ' ')
  25.     {
  26.         stringPos++;
  27.     }
  28.     while (paramPos < paramCount && string[stringPos])
  29.     {
  30.         switch (format[formatPos++])
  31.         {
  32.             case '\0':
  33.             {
  34.                 return 0;
  35.             }
  36.             case 'i', 'd':
  37.             {
  38.                 new
  39.                     neg = 1,
  40.                     num = 0,
  41.                     ch = string[stringPos];
  42.                 if (ch == '-')
  43.                 {
  44.                     neg = -1;
  45.                     ch = string[++stringPos];
  46.                 }
  47.                 do
  48.                 {
  49.                     stringPos++;
  50.                     if ('0' <= ch <= '9')
  51.                     {
  52.                         num = (num * 10) + (ch - '0');
  53.                     }
  54.                     else
  55.                     {
  56.                         return -1;
  57.                     }
  58.                 }
  59.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  60.                 setarg(paramPos, 0, num * neg);
  61.             }
  62.             case 'h', 'x':
  63.             {
  64.                 new
  65.                     num = 0,
  66.                     ch = string[stringPos];
  67.                 do
  68.                 {
  69.                     stringPos++;
  70.                     switch (ch)
  71.                     {
  72.                         case 'x', 'X':
  73.                         {
  74.                             num = 0;
  75.                             continue;
  76.                         }
  77.                         case '0' .. '9':
  78.                         {
  79.                             num = (num << 4) | (ch - '0');
  80.                         }
  81.                         case 'a' .. 'f':
  82.                         {
  83.                             num = (num << 4) | (ch - ('a' - 10));
  84.                         }
  85.                         case 'A' .. 'F':
  86.                         {
  87.                             num = (num << 4) | (ch - ('A' - 10));
  88.                         }
  89.                         default:
  90.                         {
  91.                             return -1;
  92.                         }
  93.                     }
  94.                 }
  95.                 while ((ch = string[stringPos]) > ' ' && ch != delim);
  96.                 setarg(paramPos, 0, num);
  97.             }
  98.             case 'c':
  99.             {
  100.                 setarg(paramPos, 0, string[stringPos++]);
  101.             }
  102.             case 'f':
  103.             {
  104.  
  105.                 new changestr[16], changepos = 0, strpos = stringPos;
  106.                 while(changepos < 16 && string[strpos] && string[strpos] != delim)
  107.                 {
  108.                     changestr[changepos++] = string[strpos++];
  109.                     }
  110.                 changestr[changepos] = '\0';
  111.                 setarg(paramPos,0,_:floatstr(changestr));
  112.             }
  113.             case 'p':
  114.             {
  115.                 delim = format[formatPos++];
  116.                 continue;
  117.             }
  118.             case '\'':
  119.             {
  120.                 new
  121.                     end = formatPos - 1,
  122.                     ch;
  123.                 while ((ch = format[++end]) && ch != '\'') {}
  124.                 if (!ch)
  125.                 {
  126.                     return -1;
  127.                 }
  128.                 format[end] = '\0';
  129.                 if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  130.                 {
  131.                     if (format[end + 1])
  132.                     {
  133.                         return -1;
  134.                     }
  135.                     return 0;
  136.                 }
  137.                 format[end] = '\'';
  138.                 stringPos = ch + (end - formatPos);
  139.                 formatPos = end + 1;
  140.             }
  141.             case 'u':
  142.             {
  143.                 new
  144.                     end = stringPos - 1,
  145.                     id = 0,
  146.                     bool:num = true,
  147.                     ch;
  148.                 while ((ch = string[++end]) && ch != delim)
  149.                 {
  150.                     if (num)
  151.                     {
  152.                         if ('0' <= ch <= '9')
  153.                         {
  154.                             id = (id * 10) + (ch - '0');
  155.                         }
  156.                         else
  157.                         {
  158.                             num = false;
  159.                         }
  160.                     }
  161.                 }
  162.                 if (num && IsPlayerConnected(id))
  163.                 {
  164.                     setarg(paramPos, 0, id);
  165.                 }
  166.                 else
  167.                 {
  168.                     #if !defined foreach
  169.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  170.                         #define __SSCANF_FOREACH__
  171.                     #endif
  172.                     string[end] = '\0';
  173.                     num = false;
  174.                     new
  175.                         name[MAX_PLAYER_NAME];
  176.                     id = end - stringPos;
  177.                     foreach (Player, playerid)
  178.                     {
  179.                         GetPlayerName(playerid, name, sizeof (name));
  180.                         if (!strcmp(name, string[stringPos], true, id))
  181.                         {
  182.                             setarg(paramPos, 0, playerid);
  183.                             num = true;
  184.                             break;
  185.                         }
  186.                     }
  187.                     if (!num)
  188.                     {
  189.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  190.                     }
  191.                     string[end] = ch;
  192.                     #if defined __SSCANF_FOREACH__
  193.                         #undef foreach
  194.                         #undef __SSCANF_FOREACH__
  195.                     #endif
  196.                 }
  197.                 stringPos = end;
  198.             }
  199.             case 's', 'z':
  200.             {
  201.                 new
  202.                     i = 0,
  203.                     ch;
  204.                 if (format[formatPos])
  205.                 {
  206.                     while ((ch = string[stringPos++]) && ch != delim)
  207.                     {
  208.                         setarg(paramPos, i++, ch);
  209.                     }
  210.                     if (!i)
  211.                     {
  212.                         return -1;
  213.                     }
  214.                 }
  215.                 else
  216.                 {
  217.                     while ((ch = string[stringPos++]))
  218.                     {
  219.                         setarg(paramPos, i++, ch);
  220.                     }
  221.                 }
  222.                 stringPos--;
  223.                 setarg(paramPos, i, '\0');
  224.             }
  225.             default:
  226.             {
  227.                 continue;
  228.             }
  229.         }
  230.         while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  231.         {
  232.             stringPos++;
  233.         }
  234.         while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  235.         {
  236.             stringPos++;
  237.         }
  238.         paramPos++;
  239.     }
  240.     do
  241.     {
  242.         if ((delim = format[formatPos++]) > ' ')
  243.         {
  244.             if (delim == '\'')
  245.             {
  246.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  247.             }
  248.             else if (delim != 'z')
  249.             {
  250.                 return delim;
  251.             }
  252.         }
  253.     }
  254.     while (delim > ' ');
  255.     return 0;
  256. }
  257.  
  258. #define cor1 0xFFE12525
  259. #define cor2 0xFF2538E1
  260. #define cor3 0xFF28E125
  261. #define cor4 0xFFDEE125
  262. #define cor5 0xFFE17D25
  263. #define cor6 0xFFDE25E1
  264. #define cor7 0xFF9325E1
  265. #define cor8 0xFF2E8F2F
  266.  
  267. //ADMINISTRAÇÃO DE SENHAS, VIA RCON
  268. CMD:editarsenha(playerid,params[])
  269. {
  270.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,cor3,"Você não está logado na RCON.");
  271.     new senha,senhac;
  272.     if(sscanf(params, "dd",senha,senhac)) return SendClientMessage(playerid,cor3,"Use /editarsenha [lvl-senha1a4] [nova-senha]");
  273.     if(senha >= 5) return SendClientMessage(playerid,cor6,"O sistema é composto por apenas 4 senhas.");
  274.  
  275.     new file[32];
  276.     format(file,sizeof file,"BytePass/senha.ini");
  277.  
  278.     new strsenha[64];
  279.     format(strsenha,sizeof strsenha,"Senha%d",senha);
  280.     DOF2_SetInt(file, strsenha, senhac);
  281.     DOF2_SaveFile();
  282.     SendClientMessage(playerid,cor2,"Senha editada com sucesso, para ve-la use /versenhas.");
  283.     return 1;
  284. }
  285.  
  286. CMD:criarsenha(playerid,params[])
  287. {
  288.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,cor3,"Você não está logado na RCON.");
  289.     new senha;
  290.     if(sscanf(params, "d",senha)) return SendClientMessage(playerid,cor5,"Use /criarsenha senha[numeros]");
  291.     new file[32];
  292.     format(file,sizeof file,"BytePass/senha.ini");
  293.     if(!DOF2_FileExists(file))
  294.     {
  295.         DOF2_CreateFile(file);
  296.         DOF2_SetInt(file, "Senha1", 0);
  297.         DOF2_SetInt(file, "Senha2", 0);
  298.         DOF2_SetInt(file, "Senha3", 0);
  299.         DOF2_SetInt(file, "Senha4", 0);
  300.         DOF2_SaveFile();
  301.         SendClientMessage(playerid,cor7,"Arquivo criado com sucesso! Agora você pode criar senhas.");
  302.         return 1;
  303.     }
  304.     else
  305.     {
  306.         if(DOF2_GetInt(file, "Senha1") == 0)
  307.         {
  308.             DOF2_SetInt(file, "Senha1", senha);
  309.             DOF2_SaveFile();
  310.             return SendClientMessage(playerid,cor4,"Senha Admin LVL 1 criada com sucesso.");
  311.         }
  312.         else
  313.         {
  314.             if(DOF2_GetInt(file, "Senha2") == 0)
  315.             {
  316.                 DOF2_SetInt(file, "Senha2", senha);
  317.                 DOF2_SaveFile();
  318.                 return SendClientMessage(playerid,cor4,"Senha Admin LVL 2 criada com sucesso.");
  319.             }
  320.             else
  321.             {
  322.                 if(DOF2_GetInt(file, "Senha3") == 0)
  323.                 {
  324.                     DOF2_SetInt(file, "Senha3", senha);
  325.                     DOF2_SaveFile();
  326.                     return SendClientMessage(playerid,cor4,"Senha Admin LVL 3 criada com sucesso.");
  327.                 }
  328.                 else
  329.                 {
  330.                     if(DOF2_GetInt(file, "Senha4") == 0)
  331.                     {
  332.                         DOF2_SetInt(file, "Senha4", senha);
  333.                         DOF2_SaveFile();
  334.                         return SendClientMessage(playerid,cor4,"Senha Admin LVL 4 criada com sucesso.");
  335.                     }
  336.                     else return SendClientMessage(playerid,cor2,"O limite de senhas estourou, use /editarsenha ou /removersenhas para modificar ou criar uma.");
  337.                 }
  338.             }
  339.         }
  340.     }
  341. }
  342.  
  343. CMD:versenhas(playerid)
  344. {
  345.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,cor3,"Você não está logado na RCON.");
  346.     new file[32];
  347.     format(file,sizeof file,"BytePass/senha.ini");
  348.     if(!DOF2_FileExists(file)) return SendClientMessage(playerid,cor3,"Arquivo não criado.");
  349.     SendClientMessage(playerid,cor2,"-------------------------------------------------------------------------------------------------");
  350.     new str[128];
  351.     format(str,sizeof str,"ADMIN LVL 1: %d",DOF2_GetInt(file, "Senha1"));
  352.     SendClientMessage(playerid,-1,str);
  353.     format(str,sizeof str,"ADMIN LVL 2: %d",DOF2_GetInt(file, "Senha2"));
  354.     SendClientMessage(playerid,-1,str);
  355.     format(str,sizeof str,"ADMIN LVL 3: %d",DOF2_GetInt(file, "Senha3"));
  356.     SendClientMessage(playerid,-1,str);
  357.     format(str,sizeof str,"ADMIN LVL 4: %d",DOF2_GetInt(file, "Senha4"));
  358.     SendClientMessage(playerid,-1,str);
  359.     SendClientMessage(playerid,cor2,"-------------------------------------------------------------------------------------------------");
  360.     return 1;
  361. }
  362.  
  363. CMD:removersenhas(playerid)
  364. {
  365.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,cor3,"Você não está logado na RCON.");
  366.     new file[32];
  367.     format(file,sizeof file,"BytePass/senha.ini");
  368.     if(!DOF2_FileExists(file)) return SendClientMessage(playerid,cor3,"Arquivo não criado.");
  369.     DOF2_SetInt(file, "Senha1", 0);
  370.     DOF2_SetInt(file, "Senha2", 0);
  371.     DOF2_SetInt(file, "Senha3", 0);
  372.     DOF2_SetInt(file, "Senha4", 0);
  373.     DOF2_SaveFile();
  374.     SendClientMessage(playerid,cor3,"Senhas removidas com sucesso! Use /criarsenha para cria-las novamente.");
  375.     return 1;
  376. }
  377.  
  378. //SISTEMA PARA LOGIN, LEVELS
  379.  
  380. new playeradmin[MAX_PLAYERS];
  381.  
  382. CMD:login(playerid,params[])
  383. {
  384.     new senha;
  385.     if(sscanf(params, "d",senha)) return SendClientMessage(playerid,cor3,"Use /login [senha]");
  386.     new file[32];
  387.     new senhacerta;
  388.     format(file,sizeof file,"BytePass/senha.ini");
  389.     if(DOF2_GetInt(file, "Senha1") == senha)
  390.     {
  391.         playeradmin[playerid] = 1;
  392.         senhacerta = 1;
  393.         return SendClientMessage(playerid,cor3,"Logado com sucesso, use /aa para ver os comandos.");
  394.     }
  395.     if(DOF2_GetInt(file, "Senha2") == senha)
  396.     {
  397.         playeradmin[playerid] = 2;
  398.         senhacerta = 1;
  399.         return SendClientMessage(playerid,cor3,"Logado com sucesso, use /aa para ver os comandos.");
  400.     }
  401.     if(DOF2_GetInt(file, "Senha3") == senha)
  402.     {
  403.         playeradmin[playerid] = 3;
  404.         senhacerta = 1;
  405.         return SendClientMessage(playerid,cor3,"Logado com sucesso, use /aa para ver os comandos.");
  406.     }
  407.     if(DOF2_GetInt(file, "Senha4") == senha)
  408.     {
  409.         playeradmin[playerid] = 4;
  410.         senhacerta = 1;
  411.         return SendClientMessage(playerid,cor3,"Logado com sucesso, use /aa para ver os comandos.");
  412.     }
  413.     if(senhacerta == 0) return SendClientMessage(playerid,cor8,"Senha incorreta.");
  414.     senhacerta = 0;
  415.     return 1;
  416. }
  417.  
  418. //AGORA É SÓ COLOCAR SEUS COMANDOS
  419. // CONFIGURANDO COM AS VARIAVEIS CITADAS:
  420. /*
  421. if(playeradmin[playerid] >= LEVEL)
  422. {
  423.     SUAS FUNÇÕES
  424. }
  425. else return SendClientMessage(playerid,cor3,"Você não é um administrador ou não logou-se");
  426. */
  427. CMD:kick(playerid,params[])
  428. {
  429.     if(playeradmin[playerid] >= 1)
  430.     {
  431.         new id,motivo[128];
  432.         if(sscanf(params, "ds",id,motivo)) return SendClientMessage(playerid,cor3,"Use /kick [id] [motivo]");
  433.         new nome[24];
  434.         GetPlayerName(id,nome,sizeof nome);
  435.         new str[128];
  436.         format(str,sizeof str,"AdmCmd: %s foi kickado do servidor. Motivo: %s",nome,motivo);
  437.         SendClientMessageToAll(cor1,str);
  438.         Kick(id);
  439.     }
  440.     else return SendClientMessage(playerid,cor3,"Você não é um administrador ou não logou-se");
  441.     return 1;
  442. }//NÃO TESTEI ESSE COMANDO, MÁS ACHO QUE FUNCIONA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement