Advertisement
Guest User

[FS] Evento System [v0.1b]

a guest
Oct 16th, 2010
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.98 KB | None | 0 0
  1.  
  2.  
  3. #include <a_samp>
  4.  
  5. forward CountDown();
  6.  
  7. #define COR_VERMELHA 0xF66767AA
  8. #define COR_BRANCO   0xFFFFFFAA
  9. #define COR_AZUL     0x447FECAA
  10. enum EventoSystem
  11. {
  12.     bool:Eventoiniciado,//bool irá indicar sim ou não (false or true) melhor doque 0 ou 1
  13.     bool:Eventotrancado,
  14.     bool:Eventodestrancado,
  15.     bool:Entrar,
  16. };
  17. new Airton[MAX_PLAYERS][EventoSystem];
  18. new Float:ex,Float:ey,Float:ez;
  19. new Float:entroux,Float:entrouy,Float:entrouz;
  20. new entraram;
  21. new bool: IsCountdownStarted;
  22. new CountdownTimer;
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     print("--**Evento System Iniciado com sucesso**--");
  27.     print("--**Desenvolvido para o SA-MP 0.3b RC2**--");
  28.     print("--**Progamado por Airton.Vitor**--");
  29.     SendClientMessageToAll(COR_VERMELHA,"Evento System Iniciado com sucesso by Airton");
  30.     return 1;
  31. }
  32.  
  33. public OnFilterScriptExit()
  34. {
  35.     print("--**Evento System Finalizado com sucesso**--");
  36.     SendClientMessageToAll(COR_AZUL,"-**Evento System Finalizado com sucesso by Airton");
  37.     return 1;
  38. }
  39.  
  40. main(){}
  41.  
  42. public OnPlayerConnect(playerid)
  43. {
  44.     Airton[playerid][Eventoiniciado] = false;
  45.     Airton[playerid][Eventodestrancado] = false;
  46.     Airton[playerid][Eventotrancado] = false;
  47.     Airton[playerid][Entrar] = false;
  48.     return 1;
  49. }
  50.  
  51. public OnPlayerSpawn(playerid)
  52. {
  53.     if(IsPlayerAdmin(playerid))
  54.     {
  55.         SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: Uso> /evento para ver os comandos disponiveis");
  56.     }
  57.     return 1;
  58. }
  59. public OnPlayerDeath(playerid, killerid, reason)
  60. {
  61.     Airton[playerid][Entrar] = false;
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerCommandText(playerid, cmdtext[])
  66. {
  67.     new cmd[128]; new streventu[128]; new idcmd;
  68.     new admnick[20];
  69.     cmd = strtok(cmdtext, idcmd);
  70.     if(strcmp(cmd, "/evento", true) == 0&&IsPlayerAdmin(playerid))
  71.     {
  72.         SendClientMessage(playerid, COR_BRANCO, "===============================================================================");
  73.         SendClientMessage(playerid, COR_VERMELHA, "=========================EVENTO SYSTEM COMANDOS DÍSPONIVEIS====================");
  74.         SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: /einiciar,/edestrancar,/etrancar,/edestrancar,/eventoterminar,/ekick");
  75.         SendClientMessage(playerid, COR_AZUL, "[EVENTOS]: /ecarro,/evida,/earma,/ecolete,/econtar,/econgelar,/edescongelar    ");
  76.         SendClientMessage(playerid, COR_BRANCO, "===============================================================================");
  77.         return 1;
  78.     }
  79.     if(strcmp(cmd, "/einiciar", true) == 0&&Airton[playerid][Eventoiniciado] == false &&IsPlayerAdmin(playerid))
  80.     {
  81.         GetPlayerPos(playerid, ex, ey, ez);
  82.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  83.         SendClientMessageToAll(COR_AZUL, "-INFO- Um evento acaba de ser iniciado! Digite /entrar para se teleportar até o evento");
  84.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  85.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
  86.         {
  87.             GameTextForPlayer(possiveis,"~y~novo evento aberto ~n~digite ~b~/entrar", 2200, 1);
  88.             Airton[possiveis][Eventoiniciado] = true;
  89.             Airton[possiveis][Eventotrancado] = false;
  90.             Airton[possiveis][Eventodestrancado] = false;
  91.             Airton[playerid][Entrar] = false;
  92.         }
  93.         return 1;
  94.     }
  95.     if(strcmp(cmd, "/etrancar", true) == 0&&Airton[playerid][Eventoiniciado] == true&&Airton[playerid][Eventotrancado] == false &&IsPlayerAdmin(playerid))
  96.     {
  97.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  98.         format(streventu, 128, "-INFO- O evento foi trancado - %d jogadores(ras) entrarao", entraram);
  99.         SendClientMessageToAll(COR_AZUL, streventu);
  100.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  101.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
  102.         {
  103.             GameTextForPlayer(possiveis,"~y~evento ~r~fechado", 2500, 1);
  104.             Airton[possiveis][Eventotrancado] = true;
  105.             Airton[possiveis][Eventodestrancado] = true;
  106.         }
  107.         return 1;
  108.     }
  109.     if(strcmp(cmd, "/edestrancar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventodestrancado] == true&&IsPlayerAdmin(playerid))
  110.     {
  111.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  112.         SendClientMessageToAll(COR_AZUL, "-INFO- O evento foi destrancado! Digite /entrar");
  113.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  114.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
  115.         {
  116.             GameTextForPlayer(possiveis,"~w~evento ~g~aberto", 2500, 1);
  117.             Airton[possiveis][Eventotrancado] = false;
  118.             Airton[possiveis][Eventodestrancado] = false;
  119.         }
  120.         return 1;
  121.     }
  122.     if(strcmp(cmd, "/efinalizar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  123.     {
  124.         GetPlayerName(playerid,admnick, 24);
  125.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  126.         format(streventu, 128, "-INFO- O Administrador RCON %s evento foi finalizado!", admnick);
  127.         SendClientMessageToAll(COR_AZUL, streventu);
  128.         SendClientMessageToAll(COR_BRANCO, "===============================================================================");
  129.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(IsPlayerConnected(possiveis))
  130.         {
  131.             GameTextForPlayer(possiveis,"~w~evento ~r~finalizado", 2500, 1);
  132.             Airton[possiveis][Eventotrancado] = false;
  133.             Airton[possiveis][Eventoiniciado] = false;
  134.             Airton[possiveis][Eventodestrancado] = false;
  135.         }
  136.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  137.         {
  138.             Airton[possiveis][Entrar] = false;
  139.             SetPlayerPos(playerid, entroux, entrouy, entrouz);
  140.         }
  141.         return 1;
  142.     }
  143.     if(strcmp(cmd, "/entrar", true) == 0&&Airton[playerid][Entrar] == false&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventotrancado] == false&&IsPlayerAdmin(playerid))
  144.     {
  145.         Airton[playerid][Entrar] = true;
  146.         entraram++;
  147.         GetPlayerPos(playerid, entroux, entrouy, entrouz);
  148.         SetPlayerPos(playerid, ex, ey, ez);
  149.         return 1;
  150.     }
  151.     if(strcmp(cmd, "/esair", true) == 0&&Airton[playerid][Entrar] == true&&Airton[playerid][Eventoiniciado] == true &&Airton[playerid][Eventotrancado] == false&&IsPlayerAdmin(playerid))
  152.     {
  153.         Airton[playerid][Entrar] = false;
  154.         entraram--;
  155.         SetPlayerPos(playerid, entroux, entrouy, entrouz);
  156.         return 1;
  157.     }
  158.     if(strcmp(cmd, "/edesarmar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  159.     {
  160.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  161.         {
  162.             ResetPlayerWeapons(possiveis);
  163.             SetPlayerArmedWeapon(possiveis,0);
  164.         }
  165.         GetPlayerName(playerid,admnick, 24);
  166.         format(streventu, 128, "-INFO- O Administrador RCON %s desarmou todos jogadores do evento!", admnick);
  167.         SendClientMessageToAll(COR_AZUL, streventu);
  168.         return 1;
  169.     }
  170.     if(strcmp(cmd, "/ekick", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  171.     {
  172.         new tmp[128];
  173.         new id = strval(tmp);
  174.         tmp = strtok(cmdtext, idcmd);
  175.         if(!strlen(tmp))
  176.         {
  177.             SendClientMessage(playerid, COR_AZUL, "Digite: /ekick [id]");
  178.             return 1;
  179.         }
  180.         if(Airton[id][Entrar] == true)
  181.         {
  182.             ResetPlayerWeapons(id);
  183.             SetPlayerPos(id, entroux, entrouy, entrouz);
  184.             Airton[id][Entrar] = false;
  185.             new jogadornick[24];
  186.             GetPlayerName(playerid,admnick, 24);
  187.             GetPlayerName(id,jogadornick, 24);
  188.             format(streventu, 128, "-INFO- O Administrador RCON %s kickou jogador %s do evento!", admnick,jogadornick);
  189.             SendClientMessageToAll(COR_AZUL, streventu);
  190.         }
  191.         else if(Airton[id][Entrar] == true)
  192.         {
  193.             SendClientMessage(playerid, COR_AZUL, "O jogador selecionado não encontra-se no evento!");
  194.         }
  195.         return 1;
  196.     }
  197.     if(strcmp(cmd, "/earma", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  198.     {
  199.         new gun;
  200.         new ammo;
  201.         new tmp[128];
  202.         tmp = strtok(cmdtext, idcmd);
  203.         gun = strval(tmp);
  204.         if(!strlen(tmp))
  205.         {
  206.             SendClientMessage(playerid, COR_BRANCO, "Digite o id da arma e a munição!");
  207.             return 1;
  208.         }
  209.         tmp = strtok(cmdtext, idcmd);
  210.         ammo = strval(tmp);
  211.         /*if(ammo < 1||ammo > 9999)
  212.         {
  213.             return 1;
  214.         }*/
  215.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  216.         {
  217.             GivePlayerWeapon(possiveis, gun, ammo);
  218.         }
  219.         GetPlayerName(playerid,admnick, 24);
  220.         format(streventu, 128, "-INFO- O Administrador RCON %s deu arma %d munição %d aos jogadores do evento!", admnick,gun,ammo);
  221.         SendClientMessageToAll(COR_AZUL, streventu);
  222.         return 1;
  223.     }
  224.     if(strcmp(cmd, "/ecarro", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  225.     {
  226.         new tmp[128];
  227.         tmp = strtok(cmdtext, idcmd);
  228.         new carro;
  229.         carro = strval(tmp);
  230.         if(!strlen(tmp))
  231.         {
  232.             SendClientMessage(playerid, COR_BRANCO, "Digite o id do carro!");
  233.             return 1;
  234.         }
  235.         if(carro < 400 || carro > 611)
  236.         {
  237.             SendClientMessage(playerid, COR_VERMELHA, "   O ID do veiculo digitado está invalido! veiculos de 400 á 611");
  238.             return 1;
  239.         }
  240.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  241.         {
  242.             new Float:X = 0,Float:Y = 0,Float:Z = 0,Float:Angulo = 0;
  243.             GetPlayerPos(possiveis, X,Y,Z);
  244.             GetPlayerFacingAngle(playerid, Angulo);
  245.             //CreateVehicle(car, X, Y, Z, Angulo, 1, 1, 10000);//cria um veiculo bem no player
  246.             PutPlayerInVehicle(possiveis, CreateVehicle(carro, X,Y,Z, Angulo, 1, 1,10000), 0);//coloca o player num veiculo
  247.         }
  248.         GetPlayerName(playerid,admnick, 24);
  249.         format(streventu, 128, "-INFO- O Administrador RCON %s deu veiculo %d aos jogadores do evento!", admnick,carro);
  250.         SendClientMessageToAll(COR_AZUL, streventu);
  251.         return 1;
  252.     }
  253.     if(strcmp(cmd, "/econtar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  254.     {
  255.         if(IsCountdownStarted == false)
  256.         {
  257.             CountdownTimer = SetTimer("CountDown", 1000, 1);
  258.             IsCountdownStarted = true;
  259.             GetPlayerName(playerid,admnick, 24);
  260.             format(streventu, 128, "-INFO- O Administrador RCON %s iniciou a contagem do evento", admnick);
  261.             SendClientMessageToAll(COR_AZUL, streventu);
  262.         }
  263.         else
  264.         {
  265.             SendClientMessage(playerid, COR_VERMELHA, "Já há uma contagem em andamento");
  266.         }
  267.         return 1;
  268.     }
  269.     if(strcmp(cmd, "/econgelar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  270.     {
  271.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  272.         {
  273.             TogglePlayerControllable(possiveis, false);
  274.         }
  275.         GetPlayerName(playerid,admnick, 24);
  276.         format(streventu, 128, "-INFO- O Administrador RCON %s congelou os jogadores do evento!", admnick);
  277.         SendClientMessageToAll(COR_AZUL, streventu);
  278.         return 1;
  279.     }
  280.     if(strcmp(cmd, "/edescongelar", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  281.     {
  282.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  283.         {
  284.             TogglePlayerControllable(possiveis, true);
  285.         }
  286.         GetPlayerName(playerid,admnick, 24);
  287.         format(streventu, 128, "-INFO- O Administrador RCON %s descongelou os jogadores do evento!", admnick);
  288.         SendClientMessageToAll(COR_AZUL, streventu);
  289.         return 1;
  290.     }
  291.     if(strcmp(cmd, "/evida", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  292.     {
  293.         new tmp[128];
  294.         tmp = strtok(cmdtext, idcmd);
  295.         new vida = strval(tmp);
  296.         if(!strlen(tmp))
  297.         {
  298.             SendClientMessage(playerid, COR_BRANCO, "Digite a quantidade do HP!");
  299.             return 1;
  300.         }
  301.         /*if(vida < 1 || vida > 9999)
  302.         {
  303.             return 1;
  304.         }*/
  305.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  306.         {
  307.             SetPlayerHealth(possiveis,vida);
  308.         }
  309.         GetPlayerName(playerid,admnick, 24);
  310.         format(streventu, 128, "-INFO- O Administrador RCON %s setou HP %d para os jogadores do evento", admnick,vida);
  311.         SendClientMessageToAll(COR_AZUL, streventu);
  312.         return 1;
  313.     }
  314.     if(strcmp(cmd, "/ecolete", true) == 0&&Airton[playerid][Eventoiniciado] == true &&IsPlayerAdmin(playerid))
  315.     {
  316.         new tmp[128];
  317.         tmp = strtok(cmdtext, idcmd);
  318.         new colete = strval(tmp);
  319.         if(!strlen(tmp))
  320.         {
  321.             SendClientMessage(playerid, COR_BRANCO, "Digite a quantidade do Colete!");
  322.             return 1;
  323.         }
  324.         /*if(colete < 1 || colete > 9999)
  325.         {
  326.             return 1;
  327.         }*/
  328.         for(new possiveis = 0; possiveis < MAX_PLAYERS; possiveis++) if(Airton[playerid][Entrar] == true)
  329.         {
  330.             SetPlayerArmour(possiveis, colete);
  331.         }
  332.         GetPlayerName(playerid,admnick, 24);
  333.         format(streventu, 128, "-INFO- O Administrador RCON %s setou Colete %d para os jogadores do evento", admnick, colete);
  334.         SendClientMessageToAll(COR_AZUL, streventu);
  335.         return 1;
  336.     }
  337.     return 1;
  338. }
  339.  
  340. public CountDown()
  341. {
  342.     new Count;
  343.     switch(Count)
  344.     {
  345.         case 5: { GameTextForAll("~n~~b~-~r~ 5 ~b~-", 1100, 3); }
  346.         case 4: { GameTextForAll("~n~~b~-~r~ 4 ~b~-", 1100, 3); }
  347.         case 3: { GameTextForAll("~n~~b~-~r~ 3 ~b~-", 1100, 3); }
  348.         case 2: { GameTextForAll("~n~~b~-~r~ 2 ~b~-", 1100, 3); }
  349.         case 1: { GameTextForAll("~n~~b~-~r~ 1 ~b~-", 1100, 3); }
  350.         case 0:
  351.         {
  352.             GameTextForAll("~n~~b~-~g~ GO! ~b~-", 2000, 3);
  353.             KillTimer(CountdownTimer);
  354.             IsCountdownStarted = false;
  355.         }
  356.     }
  357.     Count--;
  358. }
  359. /*
  360.  
  361.     Discrição: Sistema de eventos v0.1b
  362.     Progamado por: Airton.Vitor
  363.     Manual: Para criar,trancar,setar,etc você deve estar logado como Administrador RCON
  364.     Dica: /rcon login [suasenha]
  365.     Lembrete: Sejá um bom menino e mantenha os créditos :p
  366.  
  367. */
  368. strtok(const string[], &index)
  369. {
  370.     new length = strlen(string);
  371.     while ((index < length) && (string[index] <= ' '))
  372.     {
  373.         index++;
  374.     }
  375.  
  376.     new offset = index;
  377.     new result[20];
  378.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  379.     {
  380.         result[index - offset] = string[index];
  381.         index++;
  382.     }
  383.     result[index - offset] = EOS;
  384.     return result;
  385. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement