Advertisement
ricop522

[FS][v1] Sistema de Evento

Jul 17th, 2011
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.37 KB | None | 0 0
  1. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  2. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  3. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  4.  
  5.                                     // Versão do sistema de eventos: 0.1B
  6.                                         //by Ricop522
  7.  
  8. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  9. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  10. // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  11.  
  12. #include <a_samp>
  13. #pragma semicolon 0
  14.  
  15. enum ricop_evento
  16. {
  17.     eArmas[8],
  18.     bool:eUseSkin,
  19.     eSkin,
  20.     eVagas,
  21.     eQuantidadeVagas,
  22.     Float:eVida,
  23.     Float:eColete,
  24.     Float:ePos[3],
  25.     eInterior,
  26.     eVirWorld,
  27.     eStatus,
  28. }
  29. new EventoInfo[ricop_evento];
  30. new bool:eEntrou[MAX_PLAYERS];
  31. new eString[0x80];
  32.  
  33. #define ricop true
  34. #define eCor 0x77BBFFAA
  35. #define DIALOG_CREDITOS 1123
  36.  
  37.  
  38. public OnFilterScriptInit()
  39. {
  40.     print("\n--------------------------------------");
  41.     print(" Sistema de Eventos by [Ricop522] carregado com sucesso !");
  42.     print("--------------------------------------\n");
  43.     return 1;
  44. }
  45.  
  46. public OnFilterScriptExit()
  47. {
  48.     print("\n--------------------------------------");
  49.     print(" Sistema de Eventos by [Ricop522] descarregado com sucesso !");    // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  50.     print("--------------------------------------\n");
  51.     return 1;
  52. }
  53. public OnPlayerConnect(playerid)
  54. {
  55.     eEntrou[playerid] = false;
  56.     return 1;
  57. }
  58. public OnPlayerCommandText(playerid, cmdtext[])
  59. {
  60.     new rCmd[0x80], idx, tmp[128];
  61.     if(!strcmp(rCmd, "/ecreditos", true)) // FAVOR NÃO REMOVER OS CRÉDITOS! RETIRÁ-LOS NÃO SIGNIFICA QUE FOI VOCÊ QUEM FEZ.
  62.     {
  63.         ShowPlayerDialog(playerid, DIALOG_CREDITOS, DIALOG_STYLE_LIST, "[ Créditos do sistema de Evento ]", "<<< Sistema de eventos feito por Ricop522 ou Justin_Ston|Lemon >>>", "OK", " ");
  64.         return 1;
  65.     }
  66.     if(!strcmp(rCmd, "/evento", true))
  67.     {
  68.         new r_r[0x24], eArma, eOption;
  69.         r_r = strtok(cmdtext, idx);
  70.         if(!strlen(r_r))
  71.         {
  72.             SendClientMessage(playerid, eCor, "Use: /evento [opção]'");
  73.             SendClientMessage(playerid, -1, "entrar, ecreditos");
  74.             if(IsPlayerAdmin(playerid))
  75.             {
  76.                 SendClientMessage(playerid, -1, "[Admin]: arma[1-8], usarskin, skinevento, vida, colete");
  77.                 SendClientMessage(playerid, -1, "[Admin]: quantidadevagas, abrir, fechar, kick");
  78.             }
  79.             return 0x01;
  80.         }
  81.         if(strcmp(r_r,"kick",true) == 0)
  82.         {
  83.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  84.             tmp = strtok(cmdtext, idx);
  85.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use /evento kick [ID] [Motivo]");
  86.             new id = strval(tmp);
  87.             new length = strlen(cmdtext), offset = idx, result[128]
  88.             while ((idx < length) && (cmdtext[idx] <= ' ')) idx++;
  89.             while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; }
  90.             result[idx - offset] = EOS;
  91.             if(!strlen(result)) return SendClientMessage(playerid, eCor, "<!> Use /evento kick [ID] [Motivo]");
  92.             if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID || eEntrou[id] == false) return SendClientMessage(playerid, -1, "Jogador inválido / offline / Não está no evento.");
  93.             if(strlen(result) == 0) { format(eString, sizeof(eString), "[AD:Evento]: Administrador %s kickou %s do evento, motivo: Não informado", eNome(playerid), eNome(id)); }
  94.             else { format(eString, sizeof(eString), "[AD:Evento]: Administrador %s kickou %s do evento, motivo: %s", eNome(playerid), eNome(id),(result)); }
  95.             SendClientMessageToAll(eCor, eString);
  96.             Kick(id);
  97.             return 0x01;
  98.         }
  99.         if(strcmp(r_r,"fechar",true) == 0)
  100.         {
  101.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  102.             new length = strlen(cmdtext), offset = idx, result[128]
  103.             while ((idx < length) && (cmdtext[idx] <= ' ')) idx++;
  104.             while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; }
  105.             result[idx - offset] = EOS;
  106.             if(!strlen(result)) return SendClientMessage(playerid, eCor, "<!> /evento fechar [motivo]");
  107.             EventoInfo[eStatus] = false;
  108.             if(strlen(result) == 0) { format(eString, sizeof(eString), "[AD:Evento]: Administrador %s fechou o evento, motivo: Não informado", eNome(playerid)); }
  109.             else { format(eString, sizeof(eString), "[AD:Evento]: Administrador %s fechou o evento, motivo: %s", eNome(playerid), (result)); }
  110.             SendClientMessageToAll(eCor, eString);
  111.             resetarEvento();
  112.             return 0x01;
  113.         }
  114.         if(strcmp(r_r,"abrir",true) == 0)
  115.         {
  116.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  117.             EventoInfo[eStatus] = true;
  118.             format(eString, sizeof(eString), "[AD:Evento]: Administrador %s abriu o evento! use \"/evento entrar\" para entrar nele! Vagas: %i", eNome(playerid), EventoInfo[eQuantidadeVagas]);
  119.             SendClientMessageToAll(eCor, eString);
  120.             return 0x01;
  121.         }
  122.         if(strcmp(r_r,"quantidadevagas",true) == 0)
  123.         {
  124.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  125.             tmp = strtok(cmdtext, idx);
  126.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento quantidadevagas [qtd]");
  127.             eOption = strval(tmp);
  128.             EventoInfo[eColete] = eOption;
  129.             format(eString, sizeof(eString), "[AD:Evento]: Quantidade de pessoas no evento setada para %i", eOption);
  130.             SendClientMessage(playerid, eCor, eString);
  131.             return 0x01;
  132.         }
  133.         if(strcmp(r_r,"colete",true) == 0)
  134.         {
  135.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  136.             tmp = strtok(cmdtext, idx);
  137.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento colete [qtd]");
  138.             new Float:eOption2 = floatstr(tmp);
  139.             EventoInfo[eColete] = eOption2;
  140.             format(eString, sizeof(eString), "[AD:Evento]: Colete do evento setada para %f", eOption2);
  141.             SendClientMessage(playerid, eCor, eString);
  142.             return 0x01;
  143.         }
  144.         if(strcmp(r_r,"vida",true) == 0)
  145.         {
  146.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  147.             tmp = strtok(cmdtext, idx);
  148.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento vida [qtd]");
  149.             new Float:eOption2 = floatstr(tmp);
  150.             EventoInfo[eVida] = eOption2;
  151.             format(eString, sizeof(eString), "[AD:Evento]: Vida do evento setada para %f", eOption2);
  152.             SendClientMessage(playerid, eCor, eString);
  153.             return 0x01;
  154.         }
  155.         if(strcmp(r_r,"skinevento",true) == 0)
  156.         {
  157.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  158.             if(EventoInfo[eUseSkin] == false) return SendClientMessage(playerid, eCor, "[AD:Evento]: Ultilize \"/evento usarskin 1\" para ativar a skin no evento.");
  159.             tmp = strtok(cmdtext, idx);
  160.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento skinevento [skinid]");
  161.             eOption = strval(tmp);
  162.             if(eOption < 0 || eOption > 299) return SendClientMessage(playerid, eCor, "[AD:Evento]: Ultilize skins de 1 a 299.");
  163.             EventoInfo[eSkin] = eOption;
  164.             return 0x01;
  165.         }
  166.         if(strcmp(r_r,"usarskin",true) == 0)
  167.         {
  168.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  169.             tmp = strtok(cmdtext, idx);
  170.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento usarskin [opção]");
  171.             eOption = strval(tmp);
  172.             if(eOption < 0 || eOption > 1) return SendClientMessage(playerid, eCor, "[AD:Evento]: Ultilize (1 - ativado) | (0 - desativado).");
  173.             if(eOption == 1) { (EventoInfo[eUseSkin] = true); } else { (EventoInfo[eUseSkin] = false); }
  174.             return 0x01;
  175.         }
  176.         if(strcmp(r_r,"entrar",true) == 0)
  177.         {
  178.             if(EventoInfo[eStatus] == 0) return SendClientMessage(playerid, eCor, "[AD:Evento]: Evento fechado!");
  179.             eEntrou[playerid] = true;
  180.             entrarEvento(playerid);
  181.         }
  182.         if(strcmp(r_r,"arma1",true) == 0)
  183.         {
  184.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  185.             tmp = strtok(cmdtext, idx);
  186.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma1 [armaID]");
  187.             eArma = strval(tmp);
  188.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  189.             EventoInfo[eArmas][0] = eArma;
  190.             return 0x01;
  191.         }
  192.         if(strcmp(r_r,"arma2",true) == 0)
  193.         {
  194.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  195.             tmp = strtok(cmdtext, idx);
  196.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma2 [armaID]");
  197.             eArma = strval(tmp);
  198.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  199.             EventoInfo[eArmas][1] = eArma;
  200.             return 0x01;
  201.         }
  202.         if(strcmp(r_r,"arma3",true) == 0)
  203.         {
  204.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  205.             tmp = strtok(cmdtext, idx);
  206.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma3 [armaID]");
  207.             eArma = strval(tmp);
  208.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  209.             EventoInfo[eArmas][2] = eArma;
  210.             return 0x01;
  211.         }
  212.         if(strcmp(r_r,"arma4",true) == 0)
  213.         {
  214.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  215.             tmp = strtok(cmdtext, idx);
  216.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma4 [armaID]");
  217.             eArma = strval(tmp);
  218.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  219.             EventoInfo[eArmas][3] = eArma;
  220.             return 0x01;
  221.         }
  222.         if(strcmp(r_r,"arma5",true) == 0)
  223.         {
  224.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  225.             tmp = strtok(cmdtext, idx);
  226.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma5 [armaID]");
  227.             eArma = strval(tmp);
  228.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  229.             EventoInfo[eArmas][4] = eArma;
  230.             return 0x01;
  231.         }
  232.         if(strcmp(r_r,"arma6",true) == 0)
  233.         {
  234.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  235.             tmp = strtok(cmdtext, idx);
  236.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma6 [armaID]");
  237.             eArma = strval(tmp);
  238.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  239.             EventoInfo[eArmas][5] = eArma;
  240.             return 0x01;
  241.         }
  242.         if(strcmp(r_r,"arma7",true) == 0)
  243.         {
  244.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  245.             tmp = strtok(cmdtext, idx);
  246.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma7 [armaID]");
  247.             eArma = strval(tmp);
  248.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  249.             EventoInfo[eArmas][6] = eArma;
  250.             return 0x01;
  251.         }
  252.         if(strcmp(r_r,"arma8",true) == 0)
  253.         {
  254.             if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, eCor, "[AD:Evento]: Você não é administrador Rcon.");
  255.             tmp = strtok(cmdtext, idx);
  256.             if(!strlen(tmp)) return SendClientMessage(playerid, eCor, "<!> Use: /evento arma8 [armaID]");
  257.             eArma = strval(tmp);
  258.             if(eArma < 1 || eArma > 49) return SendClientMessage(playerid, eCor, "[AD:Evento]: Arma inválida.");
  259.             EventoInfo[eArmas][7] = eArma;
  260.             return 0x01;
  261.         }
  262.         return 0x01;
  263.     }
  264.     return 0;
  265. }
  266.  
  267. stock resetarEvento()
  268. {
  269.     for(new r = 0; r <= 7; ++r) EventoInfo[eArmas][r] = 0;
  270.     EventoInfo[eUseSkin] = false;
  271.     EventoInfo[eSkin] = 1;
  272.     EventoInfo[eVagas] = 10;
  273.     EventoInfo[eQuantidadeVagas] = 0;
  274.     EventoInfo[eVida] = 100.0;
  275.     EventoInfo[eColete] = 0.0;
  276.     EventoInfo[ePos][0] = 0.0;
  277.     EventoInfo[ePos][1] = 0.0;
  278.     EventoInfo[ePos][2] = 0.0;
  279.     EventoInfo[eInterior] = 0;
  280.     EventoInfo[eVirWorld] = 0;
  281.     EventoInfo[eStatus] = 0;
  282.     return ricop;
  283. }
  284. stock entrarEvento(playerid)
  285. {
  286.     if(eEntrou[playerid] == false) return 1;
  287.     if(EventoInfo[eQuantidadeVagas] == EventoInfo[eVagas])
  288.     {
  289.         format(eString, sizeof(eString), "[AD:Evento] o evento já atingiu a quantidade de %i vagas!", EventoInfo[eVagas]);
  290.         SendClientMessageToAll(eCor, eString);
  291.         EventoInfo[eStatus] = false;
  292.         return 1;
  293.     }
  294.     format(eString, sizeof(eString), "[AD:Evento] %s entrou no evento!", eNome(playerid));
  295.     SendClientMessageToAll(eCor, eString);
  296.     entrarEvento(playerid);
  297.     SetPlayerPos(playerid, EventoInfo[ePos][0],EventoInfo[ePos][1],EventoInfo[ePos][2]);
  298.     SetPlayerInterior(playerid, EventoInfo[eInterior]);
  299.     SetPlayerVirtualWorld(playerid, EventoInfo[eVirWorld]);
  300.     SetPlayerHealth(playerid, EventoInfo[eVida]);
  301.     SetPlayerArmour(playerid, EventoInfo[eColete]);
  302.     if(EventoInfo[eUseSkin] == true) SetPlayerSkin(playerid, EventoInfo[eSkin]);
  303.     EventoInfo[eQuantidadeVagas]++;
  304.     return 0x01;
  305. }
  306. stock eNome(playerid)
  307. {
  308.     new nome[MAX_PLAYER_NAME]; GetPlayerName(playerid, nome, sizeof(nome));
  309.     return nome;
  310. }
  311.  
  312. strtok(const string[], &index)
  313. {
  314.     new length = strlen(string);
  315.     while ((index < length) && (string[index] <= ' ')) index++;
  316.     new offset = index;
  317.     new result[20];
  318.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; }
  319.     result[index - offset] = EOS; return result;
  320. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement