Advertisement
Guest User

Untitled

a guest
Jun 24th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.92 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 BLACK                   0x000000C7
  11. #define WHITE                   0xFFFFFFBE
  12. #define ORANGE                  0xFF8000B8
  13. #define RED                     0xFF0000C7
  14. #define BLUE                    0x0000FFC5
  15. #define VIOLET                  0x8000FFC9
  16. #define GREEN                   0x00FF00D0
  17. #define YELLOW                  0xFFFF00CC
  18. #define PINK                    0xFF80FFC7
  19. #define SEABLUE                 0x5BB9E6CA
  20. #define BROWN                   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(">> GangZone Creator by  » RyDeR «  has been loaded!");
  41.     return 1;
  42. }
  43.  
  44. public OnFilterScriptExit()
  45. {
  46.     new i;
  47.     while(i != MAX_PLAYERS)
  48.     {
  49.         Spawned[i] = false;
  50.         GangZone[i] = false;
  51.         ++i;
  52.     }
  53.     new g;
  54.     while(g != MAX_ZONES)
  55.     {
  56.         --CreatedZone[g];
  57.         --g;
  58.     }
  59.     return 1;
  60. }
  61.  
  62. dcmd_gzone(playerid, params[])
  63. {
  64.     #pragma unused params
  65.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, ">> You are not an admin!");
  66.     if(Spawned[playerid] == false) return SendClientMessage(playerid, COLOR_ERROR, ">> You are not spawned!");
  67.     if(GangZone[playerid] == true) return SendClientMessage(playerid, COLOR_ERROR, ">> You are already creating a gangzone!");
  68.     if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
  69.     ShowDefaultDialog(playerid);
  70.     return 1;
  71. }
  72.  
  73. ShowDefaultDialog(playerid)
  74. {
  75.     return ShowPlayerDialog(playerid, 9540, DIALOG_STYLE_LIST, "GangZone Creator by RyDeR", "Create Gangzone", "Next", "Exit");
  76. }
  77.  
  78. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  79. {
  80.     switch(dialogid)
  81.     {
  82.         case 9540:
  83.         {
  84.             if(response == 0) return 1;
  85.             switch(listitem)
  86.             {
  87.                 case 0:
  88.                 {
  89.                     ShowPlayerDialog(playerid, 9541, DIALOG_STYLE_LIST, "Select a color", "Black\nWhite\nOrange\nRed\nBlue\nViolet\nGreen\nYellow\nPink\nSeaBlue\nBrown", "Next", "Back");
  90.                 }
  91.             }
  92.         }
  93.         case 9541:
  94.         {
  95.             if(response == 0) return ShowDefaultDialog(playerid);
  96.             switch(listitem)
  97.             {
  98.                 case 0:  gColor = BLACK;
  99.                 case 1:  gColor = WHITE;
  100.                 case 2:  gColor = ORANGE;
  101.                 case 3:  gColor = RED;
  102.                 case 4:  gColor = BLUE;
  103.                 case 5:  gColor = VIOLET;
  104.                 case 6:  gColor = GREEN;
  105.                 case 7:  gColor = YELLOW;
  106.                 case 8:  gColor = PINK;
  107.                 case 9:  gColor = SEABLUE;
  108.                 case 10: gColor = BROWN;
  109.             }
  110.             ShowPlayerDialog(playerid, 9542, DIALOG_STYLE_MSGBOX, "Create your zone", "\
  111.             You are now ready to create your gangzone!\n\
  112.             Use the arrow keys to make the size of the zone bigger.\n\
  113.             You can use shift+arrow keys to make it back less. \n\n\
  114.             >> If you are done press 'ENTER' to save your zone!", "Ok", "Back");
  115.         }
  116.         case 9542:
  117.         {
  118.             if(response == 0) return ShowPlayerDialog(playerid, 9541, DIALOG_STYLE_LIST, "Select a color", "Black\nWhite\nOrange\nRed\nBlue\nViolet\nGreen\nYellow\nPink\nSeaBlue\nBrown", "Next", "Back");
  119.             GangZone[playerid] = true;
  120.             GetPos[playerid] = false;
  121.         }
  122.         case 9545:
  123.         {
  124.             if(response == 0)
  125.             {
  126.                 GangZoneDestroy(GangZone[gCount]);
  127.                 return 1;
  128.             }
  129.             new
  130.                 string[128],
  131.                 string2[256],
  132.                 File:SaveIt;
  133.  
  134.             if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 9546, DIALOG_STYLE_MSGBOX, "Error..", "You did not give the name to save the file under!.", "Again", "Exit");
  135.             format(string, 128, "%s.rZone", inputtext);
  136.             format(string2, sizeof(string2), "//At The Top Of The Script:\r\nnew %s;\r\n\r\n//Under OnGameModeInit\r\n%s = GangZoneCreate(%f, %f, %f, %f);\r\n\r\n//Under OnPlayerSpawn:\r\nGangZoneShowForPlayer(playerid, %s, %d);", inputtext, inputtext, pMinX, pMinY, pMaxX, pMaxY, inputtext, gColor);
  137.             SaveIt = fopen(string, io_write);
  138.             fwrite(SaveIt, string2);
  139.             fclose(SaveIt);
  140.             ShowPlayerDialog(playerid, 9547, DIALOG_STYLE_MSGBOX, "Succesfull..", "Your gangzone has been created and saved succesfull!\n>> Use 'ANOTHER' to create another zone. Press 'EXIT' to exit the wizard!", "Another", "Exit");
  141.             new
  142.                 g;
  143.                
  144.             while(g <sizeof(gCount))
  145.             {
  146.                 ++CreatedZone[g];
  147.                 ++g;
  148.             }
  149.         }
  150.         case 9546:
  151.         {
  152.             if(response == 0)
  153.             {
  154.                 GangZoneDestroy(GangZone[gCount]);
  155.                 return 1;
  156.             }
  157.             ShowPlayerDialog(playerid, 9545, DIALOG_STYLE_INPUT, "Save or delete zone", "To save this give the name for it.\nIf you want to delete this click on 'Exit'", "Save", "Exit");
  158.         }
  159.         case 9547:
  160.         {
  161.             if(response == 0) return 1;
  162.             ShowDefaultDialog(playerid);
  163.         }
  164.     }
  165.     return 1;
  166. }
  167.  
  168. public OnPlayerCommandText(playerid, cmdtext[])
  169. {
  170.     dcmd(gzone, 5, cmdtext);
  171.     return 0;
  172. }
  173.  
  174. public OnPlayerUpdate(playerid)
  175. {
  176.     if(IsPlayerConnected(playerid))
  177.     {
  178.         if(GangZone[playerid] == true)
  179.         {
  180.             new
  181.                 Keys,
  182.                 UpDown,
  183.                 LeftRight;
  184.                
  185.             if(GetPos[playerid] == false) GetPlayerPos(playerid, pMaxX, pMaxY, pZ), GetPlayerPos(playerid, pMinX, pMinY, pZ), GetPos[playerid] = true;
  186.             GetPlayerKeys(playerid, Keys, UpDown, LeftRight);
  187.             TogglePlayerControllable(playerid, false);
  188.            
  189.             if(LeftRight == KEY_LEFT)
  190.             {
  191.                 pMinX -= 8.0;
  192.                 GangZoneDestroy(CreatedZone[gCount]);
  193.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  194.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  195.             }
  196.             else if(LeftRight & KEY_LEFT && Keys & KEY_FIRE)
  197.             {
  198.                 pMinX += 8.0;
  199.                 GangZoneDestroy(CreatedZone[gCount]);
  200.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  201.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  202.             }
  203.             else if(LeftRight == KEY_RIGHT)
  204.             {
  205.                 pMaxX += 8.0;
  206.                 GangZoneDestroy(CreatedZone[gCount]);
  207.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  208.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  209.             }
  210.             else if(LeftRight & KEY_RIGHT && Keys & KEY_FIRE)
  211.             {
  212.                 pMaxX -= 8.0;
  213.                 GangZoneDestroy(CreatedZone[gCount]);
  214.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  215.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  216.             }
  217.             else if(UpDown == KEY_UP)
  218.             {
  219.                 pMaxY += 8.0;
  220.                 GangZoneDestroy(CreatedZone[gCount]);
  221.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  222.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  223.             }
  224.             else if(UpDown & KEY_UP && Keys & KEY_FIRE)
  225.             {
  226.                 pMaxY -= 8.0;
  227.                 GangZoneDestroy(CreatedZone[gCount]);
  228.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  229.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  230.             }
  231.             else if(UpDown == KEY_DOWN)
  232.             {
  233.                 pMinY -= 8.0;
  234.                 GangZoneDestroy(CreatedZone[gCount]);
  235.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  236.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  237.             }
  238.             else if(UpDown & KEY_DOWN && Keys & KEY_FIRE)
  239.             {
  240.                 pMinY += 8.0;
  241.                 GangZoneDestroy(CreatedZone[gCount]);
  242.                 CreatedZone[gCount] = GangZoneCreate(pMinX, pMinY, pMaxX, pMaxY);
  243.                 GangZoneShowForPlayer(playerid, CreatedZone[gCount], gColor);
  244.             }
  245.             else if(Keys & KEY_SECONDARY_ATTACK)
  246.             {
  247.                 TogglePlayerControllable(playerid, true);
  248.                 GangZone[playerid] = false;
  249.                 GetPos[playerid] = false;
  250.                 ShowPlayerDialog(playerid, 9545, DIALOG_STYLE_INPUT, "Save or delete zone", "To save this give the name for it.\nIf you want to delete this click on 'exit'", "Save", "Delete");
  251.             }
  252.         }
  253.     }
  254.     return 1;
  255. }
  256.  
  257. public OnPlayerConnect(playerid)
  258. {
  259.     GangZone[playerid] = false;
  260.     Spawned[playerid] = false;
  261.     GetPos[playerid] = false;
  262.     return 1;
  263. }
  264.  
  265. public OnPlayerDisconnect(playerid, reason)
  266. {
  267.     GangZone[playerid] = false;
  268.     Spawned[playerid] = false;
  269.     GetPos[playerid] = false;
  270.     GangZoneDestroy(GangZone[gCount]);
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerSpawn(playerid)
  275. {
  276.     Spawned[playerid] = true;
  277.     return 1;
  278. }
  279.  
  280. public OnPlayerDeath(playerid, killerid, reason)
  281. {
  282.     Spawned[playerid] = false;
  283.     return 1;
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement