Advertisement
Guest User

Block Pandemonium

a guest
Jul 3rd, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.50 KB | None | 0 0
  1. /*
  2.     Block Pandemonium - Do it Yourself
  3.     By Youarex
  4.  
  5.     Date: 3.7.2013
  6.     http://www.youtube.com/watch?v=gzRQiSBik1k
  7.  
  8. **************
  9.  
  10. Callbacks:
  11.  
  12. **************
  13.  
  14.     OnPlayerCaptureBlock:
  15.         Called when a player captures a block.
  16.  
  17.     Paremeters:
  18.         playerid -  The player that captured the block.
  19.         blockid -  The block that was captured.
  20.  
  21.     Returns:
  22.         Doesn't return a specific value.
  23.  
  24. public OnPlayerCaptureBlock(playerid, blockid)
  25. {
  26.     return 1;
  27. }
  28.  
  29. **************
  30.  
  31. Functions:
  32.  
  33. **************
  34.  
  35.     Arena_Create:
  36.         Creates the arena.
  37.  
  38.     Paremeters:
  39.         Float:x -  The X coordinate to create the arena at.
  40.         Float:y -  The Y coordinate to create the arena at.
  41.         Float:z -  The Z coordinate to create the arena at.
  42.  
  43.     Returns:
  44.         Doesn't return a specific value.
  45.  
  46. Arena_Create(Float:x, Float:y, Float:z);
  47.  
  48. **************
  49.  
  50.     Arena_Destroy:
  51.         Destroys the arena.
  52.  
  53.     Paremeters:
  54.         No parameters.
  55.  
  56.     Returns:
  57.         Doesn't return a specific value.
  58.  
  59. Arena_Destroy();
  60.  
  61. **************
  62.  
  63.     SetBlockColor:
  64.         Changes the color of the block.
  65.  
  66.     Paremeters:
  67.         blockid -  The block to change the color of.
  68.         color -  The color to set, as an integer or hex (ARGB).
  69.  
  70.     Returns:
  71.         Doesn't return a specific value.
  72.  
  73. SetBlockColor(blockid, color);
  74.  
  75. **************
  76.  
  77.     GetBlockColor:
  78.         Returns the color of the block.
  79.  
  80.     Paremeters:
  81.         blockid -  The block you want to know the color of.
  82.  
  83. GetBlockColor(blockid);
  84.  
  85. **************
  86.  
  87.     SetBlockUniqueID
  88.         Sets the unique ID to the block.
  89.  
  90.     Paremeters:
  91.         blockid -  The block to change the unique ID of.
  92.         uniqueid -  The unique ID to be set for the block.
  93.  
  94.     Returns:
  95.         Doesn't return a specific value.
  96.  
  97. SetBlockUniqueID(blockid, uniqueid);
  98.  
  99. **************
  100.  
  101.     SetBlockUniqueID
  102.         Returns the unique id of the block.
  103.  
  104.     Paremeters:
  105.         blockid -  The block you want to know the unique ID of.
  106.  
  107. GetBlockUniqueID(blockid);
  108.  
  109. **************
  110.  
  111. */
  112.  
  113. #define ARENA_SIZE  8 * 8
  114. #define blocks(%0)  for(new %0; %0 < ARENA_SIZE; %0++)
  115.  
  116. forward OnPlayerCaptureBlock(playerid, blockid);
  117.  
  118. new stock
  119.     bp_aGround[4],
  120.     bp_aBtn[ARENA_SIZE],
  121.     bp_aPickup[ARENA_SIZE],
  122.     bp_aObject[ARENA_SIZE],
  123.     bp_aColor[ARENA_SIZE],
  124.     bp_aUniqueID[ARENA_SIZE],
  125.     bool:bp_aCreated = false;
  126.  
  127. static stock
  128.     bool:s_gHasOPPP = false;
  129.  
  130. static stock
  131.     g_Filterscript;
  132.  
  133. public OnFilterScriptInit()
  134. {
  135.     bp_OnScriptInit();
  136.     g_Filterscript = 1;
  137.     if(funcidx("bp_OnFilterScriptInit") != -1)
  138.     {
  139.         return CallLocalFunction("bp_OnFilterScriptInit", "");
  140.     }
  141.     return 1;
  142. }
  143.  
  144. #if defined _ALS_OnFilterScriptInit
  145.     #undef OnFilterScriptInit
  146. #else
  147.     #define _ALS_OnFilterScriptInit
  148. #endif
  149. #define OnFilterScriptInit bp_OnFilterScriptInit
  150. forward bp_OnFilterScriptInit();
  151.  
  152. public OnGameModeInit()
  153. {
  154.     if (!g_Filterscript)
  155.     {
  156.         bp_OnScriptInit();
  157.     }
  158.     if(funcidx("bp_OnGameModeInit") != -1)
  159.     {
  160.         return CallLocalFunction("bp_OnGameModeInit", "");
  161.     }
  162.     return 1;
  163. }
  164.  
  165. #if defined _ALS_OnGameModeInit
  166.     #undef OnGameModeInit
  167. #else
  168.     #define _ALS_OnGameModeInit
  169. #endif
  170. #define OnGameModeInit bp_OnGameModeInit
  171. forward bp_OnGameModeInit();
  172.  
  173. stock bp_OnScriptInit()
  174. {
  175.     s_gHasOPPP = funcidx("bp_OnPlayerPickUpPickup") != -1;
  176. }
  177.  
  178.  
  179. public OnPlayerPickUpPickup(playerid, pickupid)
  180. {
  181.     if(bp_aCreated)
  182.     {
  183.         for(new blockid; blockid < ARENA_SIZE; blockid++)
  184.         {
  185.             if(pickupid == bp_aPickup[blockid])
  186.             {
  187.                 CallRemoteFunction("OnPlayerCaptureBlock", "ii", playerid, blockid);
  188.                 break;
  189.             }
  190.         }
  191.     }
  192.     if(s_gHasOPPP)
  193.     {
  194.         return CallLocalFunction("bp_OnPlayerPickUpPickup", "ii", playerid, pickupid);
  195.     }
  196.     return 1;
  197. }
  198.  
  199. #if defined _ALS_OnPlayerPickUpPickup
  200.     #undef OnPlayerPickUpPickup
  201. #else
  202.     #define _ALS_OnPlayerPickUpPickup
  203. #endif
  204. #define OnPlayerPickUpPickup bp_OnPlayerPickUpPickup
  205. forward bp_OnPlayerPickUpPickup(playerid, pickupid);
  206.  
  207.  
  208. stock SetBlockColor(blockid, color)
  209. {
  210.     if(bp_aCreated)
  211.     {
  212.         bp_aColor[blockid] = color;
  213.         SetObjectMaterial(bp_aObject[blockid], 0, 8398, "luxorland", "des_dirt1", color);
  214.     }
  215. }
  216.  
  217. stock GetBlockColor(blockid)
  218. {
  219.     if(bp_aCreated)
  220.     {
  221.         return bp_aColor[blockid];
  222.     }
  223.     return -1;
  224. }
  225.  
  226. stock SetBlockUniqueID(blockid, uniqueid)
  227. {
  228.     if(bp_aCreated)
  229.     {
  230.         bp_aUniqueID[blockid] = uniqueid;
  231.     }
  232. }
  233.  
  234. stock GetBlockUniqueID(blockid)
  235. {
  236.     if(bp_aCreated)
  237.     {
  238.         return bp_aUniqueID[blockid];
  239.     }
  240.     return -1;
  241. }
  242.  
  243.  
  244. stock Arena_Create(Float:bp_pos_x, Float:bp_pos_y, Float:bp_pos_z)
  245. {
  246.     if(!bp_aCreated)
  247.     {
  248.         new
  249.             Float:tmp_x = bp_pos_x;
  250.  
  251.         bp_aGround[0] = CreateObject(18981, bp_pos_x -12.499999, bp_pos_y -12.499998, bp_pos_z +1.970000, 0.000000, 90.000000, 0.000000, 400.00);
  252.         SetObjectMaterial(bp_aGround[0], 0, 19373, "all_walls", "desgreengrass", 0);
  253.         bp_aGround[1]= CreateObject(18981, bp_pos_x -12.499999, bp_pos_y +12.500001, bp_pos_z +1.970000, 0.000007, 89.999992, 270.000000, 400.00);
  254.         SetObjectMaterial(bp_aGround[1], 0, 19373, "all_walls", "desgreengrass", 0);
  255.         bp_aGround[2] = CreateObject(18981, bp_pos_x +12.500000, bp_pos_y +12.500004, bp_pos_z +1.970000, 0.000006, 90.000000, 180.000030, 400.00);
  256.         SetObjectMaterial(bp_aGround[2], 0, 19373, "all_walls", "desgreengrass", 0);
  257.         bp_aGround[3] = CreateObject(18981, bp_pos_x +12.500014, bp_pos_y -12.499995, bp_pos_z +1.970000, 0.000005, 90.000000, 90.000068, 400.00);
  258.         SetObjectMaterial(bp_aGround[3], 0, 19373, "all_walls", "desgreengrass", 0);
  259.  
  260.         for(new i; i < ARENA_SIZE; i++)
  261.         {
  262.             bp_aColor[i] = 0xFFFFFFFF;
  263.             bp_aUniqueID[i] = -1;
  264.             if(i % 8 == 0 && i != 0)
  265.             {
  266.                 bp_pos_x = tmp_x;
  267.                 bp_pos_y += 5.7;
  268.             }
  269.             bp_aObject[i] = CreateObject(18764, bp_pos_x -19.991994, bp_pos_y -19.991994, bp_pos_z +0.005, 0.00, 0.00, 0.00, 400.00);
  270.             bp_aBtn[i] = CreateObject(18762, bp_pos_x -19.991994, bp_pos_y -19.991994, bp_pos_z +0.009, 0.00, 0.00, 0.00, 400.00);
  271.             SetObjectMaterial(bp_aObject[i], 0, 8398, "luxorland", "des_dirt1", 0xFFFFFFFF);
  272.             bp_aPickup[i] = CreatePickup(19300, 1, bp_pos_x -19.991994, bp_pos_y -19.991994, bp_pos_z +4.00, -1);
  273.             bp_pos_x += 5.7;
  274.         }
  275.  
  276.         bp_aCreated = true;
  277.     }
  278. }
  279.  
  280. stock Arena_Destroy()
  281. {
  282.     if(bp_aCreated)
  283.     {
  284.         for(new i; i < ARENA_SIZE; i++)
  285.         {
  286.             DestroyObject(bp_aObject[i]);
  287.             DestroyObject(bp_aBtn[i]);
  288.             DestroyPickup(bp_aPickup[i]);
  289.  
  290.             if(i < sizeof bp_aGround)
  291.             {
  292.                 DestroyObject(bp_aGround[i]);
  293.             }
  294.         }
  295.         bp_aCreated = false;
  296.     }
  297. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement