Advertisement
Guest User

[FS] GangZone Creator

a guest
Aug 27th, 2010
1,866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.09 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1  // Credits go to DracoBlue
  4.  
  5. // Message Colors
  6. #define COLOR_ERROR             0xFB0000FF
  7. #define COLOR_MSG               0xFFFFFF00
  8.  
  9. // GangZone Colors
  10. #define PRETA                   0x000000C7
  11. #define BRANCA                  0xFFFFFFBE
  12. #define LARANJA                 0xFF8000B8
  13. #define VERMELHA                0xFF0000C7
  14. #define AZUL                    0x0000FFC5
  15. #define VIOLETA                 0x8000FFC9
  16. #define VERDE                   0x00FF00D0
  17. #define AMARELA                 0xFFFF00CC
  18. #define ROSA                    0xFF80FFC7
  19. #define AZULMAR                 0x5BB9E6CA
  20. #define MARROM                  0x562C2CD2
  21.  
  22. // Max Zones You Can Create
  23. #define MAX_ZONES               100
  24.  
  25. new
  26.     bool: GangZone[MAX_PLAYERS],
  27.     bool: Spawned[MAX_PLAYERS],
  28.     bool: GetPos[MAX_PLAYERS],
  29.     CreatedZone[MAX_ZONES],
  30.     gColor,
  31.     Float: pMaxX = 0.0,
  32.     Float: pMaxY = 0.0,
  33.     Float: pMinX = 0.0,
  34.     Float: pMinY = 0.0,
  35.     Float: pZ = 0.0,
  36.     gCount;
  37.  
  38. public OnFilterScriptInit()
  39. {
  40.     print("---------------------------------------");
  41.     print(" Criador Gangzone by RyDeR - Carregado ");
  42.     print(" Tradução By: Lucas Nicolas              ");
  43.     print("---------------------------------------");
  44.     return 1;
  45. }
  46.  
  47. public OnFilterScriptExit()
  48. {
  49.     new i;
  50.     while(i != MAX_PLAYERS)
  51.     {
  52.         Spawned[i] = false;
  53.         GangZone[i] = false;
  54.         ++i;
  55.     }
  56.     new g;
  57.     while(g != MAX_ZONES)
  58.     {
  59.         --CreatedZone[g];
  60.         --g;
  61.     }
  62.     return 1;
  63. }
  64.  
  65. dcmd_gzone(playerid, params[])
  66. {
  67.     #pragma unused params
  68.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, ">> Apenas o proprietário do servidor pode fazer gangzones!");
  69.     if(Spawned[playerid] == false) return SendClientMessage(playerid, COLOR_ERROR, ">> Você não pode gerar uma Gangzone ainda!");
  70.     if(GangZone[playerid] == true) return SendClientMessage(playerid, COLOR_ERROR, ">> Você já está criando uma gangzone!");
  71.     if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
  72.     ShowDefaultDialog(playerid);
  73.     return 1;
  74. }
  75.  
  76. ShowDefaultDialog(playerid)
  77. {
  78.     return ShowPlayerDialog(playerid, 9540, DIALOG_STYLE_LIST, "GangZone Creator by RyDeR", "Criar Gangzone", "Selecionar", "Sair");
  79. }
  80.  
  81. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  82. {
  83.     switch(dialogid)
  84.     {
  85.         case 9540:
  86.         {
  87.             if(response == 0) return 1;
  88.             switch(listitem)
  89.             {
  90.                 case 0:
  91.                 {
  92.                     ShowPlayerDialog(playerid, 9541, DIALOG_STYLE_LIST, "Escolha a cor da gangzone", "Preta\nBranca\nLaranja\nVermelha\nAzul\nVioleta\nVerde\nAmarela\nRosa\nAzulMar\nMarrom", "Selecionar", "Voltar");
  93.                 }
  94.             }
  95.         }
  96.         case 9541:
  97.         {
  98.             if(response == 0) return ShowDefaultDialog(playerid);
  99.             switch(listitem)
  100.             {
  101.                 case 0:  gColor = PRETA;
  102.                 case 1:  gColor = BRANCA;
  103.                 case 2:  gColor = LARANJA;
  104.                 case 3:  gColor = VERMELHA;
  105.                 case 4:  gColor = AZUL;
  106.                 case 5:  gColor = VIOLETA;
  107.                 case 6:  gColor = VERDE;
  108.                 case 7:  gColor = AMARELA;
  109.                 case 8:  gColor = ROSA;
  110.                 case 9:  gColor = AZULMAR;
  111.                 case 10: gColor = MARROM;
  112.             }
  113.             ShowPlayerDialog(playerid, 9542, DIALOG_STYLE_MSGBOX, "Gangzone Info", "GangZone Criada! Use as setas para fazer a zona de maior ou menor\nUsando a Fire Key + Setas você menos a altura ou a largura.\nPressione Enter quando tiver terminado!", "Aceitar", "Voltar");
  114.         }
  115.         case 9542:
  116.         {
  117.             if(response == 0) return ShowPlayerDialog(playerid, 9541, DIALOG_STYLE_LIST, "Escolha a cor da gangzone", "Preta\nBranca\nLaranja\nVermelha\nAzul\nVioleta\nVerde\nAmarela\nRosa\nAzulMar\nMarrom", "Selecionar", "Voltar");
  118.             GangZone[playerid] = true;
  119.             GetPos[playerid] = false;
  120.         }
  121.         case 9545:
  122.         {
  123.             if(response == 0)
  124.             {
  125.                 GangZoneDestroy(GangZone[gCount]);
  126.                 return 1;
  127.             }
  128.             new
  129.                 string[128],
  130.                 string2[256],
  131.                 File:SaveIt;
  132.  
  133.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 9546, DIALOG_STYLE_MSGBOX, "Erro", "Você tem que dar um nome para salvá-lo.", "Tentar Novamente", "Não Salvar");
  134.             format(string, 128, "%s.rZone", inputtext);
  135.             format(string2, sizeof(string2), "//No Topo Do Script:\r\nNovo %s;\r\n\r\n//Em OnGameModeInit\r\n%s = GangZoneCreate(%f, %f, %f, %f);\r\n\r\n//Em OnPlayerSpawn:\r\nGangZoneShowForPlayer(playerid, %s, %d);", inputtext, inputtext, pMinX, pMinY, pMaxX, pMaxY, inputtext, gColor);
  136.             SaveIt = fopen(string, io_write);
  137.             fwrite(SaveIt, string2);
  138.             fclose(SaveIt);
  139.             ShowPlayerDialog(playerid, 9547, DIALOG_STYLE_MSGBOX, "Progesso Completado!", "Sua gangzone foi salva. Verifique o diretório scriptfiles!", "Outra", "Sair");
  140.             new
  141.                 g;
  142.                
  143.             while(g <sizeof(gCount))
  144.             {
  145.                 ++CreatedZone[g];
  146.                 ++g;
  147.             }
  148.         }
  149.         case 9546:
  150.         {
  151.             if(response == 0)
  152.             {
  153.                 GangZoneDestroy(GangZone[gCount]);
  154.                 return 1;
  155.             }
  156.             ShowPlayerDialog(playerid, 9545, DIALOG_STYLE_INPUT, "Salvar ou Excluir a GZ", "Para salvar este de o nome para ele.\nSe você quiser excluir isso, clique em 'Sair'", "Salvar", "Excluir");
  157.         }
  158.         case 9547:
  159.         {
  160.             if(response == 0) return 1;
  161.             ShowDefaultDialog(playerid);
  162.         }
  163.     }
  164.     return 1;
  165. }
  166.  
  167. public OnPlayerCommandText(playerid, cmdtext[])
  168. {
  169.     dcmd(gzone, 5, cmdtext);
  170.     return 0;
  171. }
  172.  
  173. public OnPlayerUpdate(playerid)
  174. {
  175.     if(IsPlayerConnected(playerid))
  176.     {
  177.         if(GangZone[playerid] == true)
  178.         {
  179.             new
  180.                 Keys,
  181.                 UpDown,
  182.                 LeftRight;
  183.                
  184.             if(GetPos[playerid] == false) GetPlayerPos(playerid, pMaxX, pMaxY, pZ), GetPlayerPos(playerid, pMinX, pMinY, pZ), GetPos[playerid] = true;
  185.             GetPlayerKeys(playerid, Keys, UpDown, LeftRight);
  186.             TogglePlayerControllable(playerid, false);
  187.            
  188.             if(LeftRight == KEY_LEFT)
  189.             {
  190.                 pMinX -= 8.0;
  191.                 GangZoneDestroy(CreatedZone[gCount]);
  192.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  193.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  194.             }
  195.             else if(LeftRight & KEY_LEFT && Keys & KEY_FIRE)
  196.             {
  197.                 pMinX += 8.0;
  198.                 GangZoneDestroy(CreatedZone[gCount]);
  199.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  200.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  201.             }
  202.             else if(LeftRight == KEY_RIGHT)
  203.             {
  204.                 pMaxX += 8.0;
  205.                 GangZoneDestroy(CreatedZone[gCount]);
  206.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  207.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  208.             }
  209.             else if(LeftRight & KEY_RIGHT && Keys & KEY_FIRE)
  210.             {
  211.                 pMaxX -= 8.0;
  212.                 GangZoneDestroy(CreatedZone[gCount]);
  213.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  214.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  215.             }
  216.             else if(UpDown == KEY_UP)
  217.             {
  218.                 pMaxY += 8.0;
  219.                 GangZoneDestroy(CreatedZone[gCount]);
  220.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  221.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  222.             }
  223.             else if(UpDown & KEY_UP && Keys & KEY_FIRE)
  224.             {
  225.                 pMaxY -= 8.0;
  226.                 GangZoneDestroy(CreatedZone[gCount]);
  227.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  228.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  229.             }
  230.             else if(UpDown == KEY_DOWN)
  231.             {
  232.                 pMinY -= 8.0;
  233.                 GangZoneDestroy(CreatedZone[gCount]);
  234.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  235.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  236.             }
  237.             else if(UpDown & KEY_DOWN && Keys & KEY_FIRE)
  238.             {
  239.                 pMinY += 8.0;
  240.                 GangZoneDestroy(CreatedZone[gCount]);
  241.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  242.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  243.             }
  244.             else if(Keys & KEY_SECONDARY_ATTACK)
  245.             {
  246.                 TogglePlayerControllable(playerid, true);
  247.                 GangZone[playerid] = false;
  248.                 GetPos[playerid] = false;
  249.                 ShowPlayerDialog(playerid, 9545, DIALOG_STYLE_INPUT, "Salvar ou Excluir a GZ", "Para salvar este de o nome para ele.\nSe você quiser excluir isso, clique em 'Sair'", "Salvar", "Excluir");
  250.             }
  251.         }
  252.     }
  253.     return 1;
  254. }
  255.  
  256. public OnPlayerConnect(playerid)
  257. {
  258.     GangZone[playerid] = false;
  259.     Spawned[playerid] = false;
  260.     GetPos[playerid] = false;
  261.     return 1;
  262. }
  263.  
  264. public OnPlayerDisconnect(playerid, reason)
  265. {
  266.     GangZone[playerid] = false;
  267.     Spawned[playerid] = false;
  268.     GetPos[playerid] = false;
  269.     GangZoneDestroy(GangZone[gCount]);
  270.     return 1;
  271. }
  272.  
  273. public OnPlayerSpawn(playerid)
  274. {
  275.     Spawned[playerid] = true;
  276.     return 1;
  277. }
  278.  
  279. public OnPlayerDeath(playerid, killerid, reason)
  280. {
  281.     Spawned[playerid] = false;
  282.     return 1;
  283. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement