Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 9.45 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <streamer>
  4. #include <a_zones>
  5.  
  6. // DEFINES //
  7.  
  8. // COLOR DEFINES //
  9. #define COLOR_RED 0xFF0000FF
  10. #define COLOR_WHITE 0xFFFFFFFF
  11. #define COLOR_BLUE 0x008CBAFF
  12. #define COLOR_YELLOWGREEN 0xADFF2FFF
  13.  
  14. // CRATE OBJECT ID DEFINE //
  15. #define CRATE_MODEL_ID ( 2358 ) // The crate object ID.
  16.  
  17. // TIME DEFINE //
  18. #define CRATE_SPAWN_TIME 180000 // Time it takes for the crate to spawn (in milliseconds). Change to your liking. Currently set at 180000 (3 minutes)
  19.  
  20. // DIALOG DEFINES //
  21. #define DIALOG_CRATE 1 // Crate dialog once opened.
  22. #define DIALOG_CRATE_HELP 2 // Crate dialog help.
  23.  
  24. new CrateObject; // The crate variable
  25. new Text3D:dynamiccrate3DText; // The 3D Text label variable.
  26.  
  27. // FORWARDS //
  28. forward CrateMessage(playerid); // Forwarding the message function.
  29.  
  30. // CRATE SPAWNS //
  31. // Add all your locations below for where you'd like the crate to spawn.
  32. new Float: g_CrateSpawns[][3] =
  33. {   // X          Y        Z
  34.     {821.9344,-1868.2295,6.7148},
  35.     {1281.3082,-2000.0718,58.2978},
  36.     {1800.3622,-2180.2473,13.5547},
  37.     {1647.9771,-2102.3044,13.5547},
  38.     {2018.6150,-2058.0906,13.5469},
  39.     {2233.3159,-2177.2832,13.5469},
  40.     {2764.3826,-2177.3364,11.0968},
  41.     {2756.0122,-2096.0896,12.1435},
  42.     {2898.8792,-1877.8223,2.5593},
  43.     {2740.0654,-1844.7032,10.3125},
  44.     {2530.7998,-1714.7511,13.4838},
  45.     {2420.2715,-1682.8293,13.7668},
  46.     {2329.4768,-1817.1458,13.5469},
  47.     {2155.0942,-1701.1150,15.0859},
  48.     {2209.6052,-1327.2385,23.9844},
  49.     {2209.4834,-1146.2018,27.7969},
  50.     {2290.6980,-1108.1018,37.9766}
  51. };
  52.  
  53. public OnFilterScriptInit()
  54. {
  55.     print("\n--------------------------------------");
  56.     print("-- Crate system by FreAkeD loaded! --");
  57.     print("--------------------------------------\n");
  58. }
  59.  
  60. public OnFilterScriptExit()
  61. {
  62.     print("\n--------------------------------------");
  63.     print("-- Crate system by FreAkeD un-loaded! --");
  64.     print("--------------------------------------\n");
  65.    
  66.     DestroyDynamicObject(CrateObject); // Destroying the crate object.
  67.     CrateObject = 0;
  68.     DestroyDynamic3DTextLabel( Text3D:dynamiccrate3DText ); // Destroying the 3D Text Label.
  69.     return 1;
  70. }
  71.  
  72. public OnPlayerConnect(playerid)
  73. {
  74.     SetTimer("CrateMessage", CRATE_SPAWN_TIME, false); // Setting the timer for the crate spawn.
  75.     return 1;
  76. }
  77.  
  78. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  79. {
  80.     if(dialogid == DIALOG_CRATE)
  81.     {
  82.         if(response) // If they clicked 'Yes' or pressed enter.
  83.         {
  84.             if(listitem == 0) // Combat Shotgun.
  85.             {
  86.                 GivePlayerWeapon(playerid, 27, 100);
  87.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}Combat Shotgun{FFFFFF}.");
  88.             }
  89.             if(listitem == 1) // MP5.
  90.             {
  91.                 GivePlayerWeapon(playerid, 29, 100);
  92.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}MP5{FFFFFF}.");
  93.             }
  94.             if(listitem == 2) // Rifle.
  95.             {
  96.                 GivePlayerWeapon(playerid, 33, 100);
  97.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}Rifle{FFFFFF}.");
  98.             }
  99.             if(listitem == 3) // Desert Eagle.
  100.             {
  101.                 GivePlayerWeapon(playerid, 24, 100);
  102.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}Desert Eagle{FFFFFF}.");
  103.             }
  104.             if(listitem == 4) // AK-47.
  105.             {
  106.                 GivePlayerWeapon(playerid, 30, 100);
  107.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped an {FFA500}AK-47{FFFFFF}.");
  108.             }
  109.             if(listitem == 5) // M4.
  110.             {
  111.                 GivePlayerWeapon(playerid, 31, 100);
  112.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped an {FFA500}M4{FFFFFF}.");
  113.             }
  114.             if(listitem == 6) // SPAS-12.
  115.             {
  116.                 GivePlayerWeapon(playerid, 27, 100);
  117.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}SPAS-12{FFFFFF}.");
  118.             }
  119.             if(listitem == 7) // Sniper Rifle.
  120.             {
  121.                 GivePlayerWeapon(playerid, 34, 100);
  122.                 SendClientMessage(playerid, COLOR_WHITE,"You have equiped a {FFA500}Sniper Rifle{FFFFFF}.");
  123.             }
  124.             if(listitem == 8) // Health.
  125.             {
  126.                 SetPlayerHealth(playerid, 100); // Setting players health
  127.                 SendClientMessage(playerid, COLOR_BLUE,"You have equiped some Health.");
  128.             }
  129.             if(listitem == 9) // Armour.
  130.             {
  131.                 SetPlayerArmour(playerid, 100.0); // Setting players armour
  132.                 SendClientMessage(playerid, COLOR_BLUE,"You have equiped some Armour.");
  133.             }
  134.             if(listitem == 10) // Destroy crate.
  135.             {
  136.                 DestroyDynamicObject(CrateObject); // Destroying the Crate Object.
  137.                 CrateObject = 0;
  138.                 DestroyDynamic3DTextLabel( Text3D:dynamiccrate3DText ); // Destroying the Crate 3D Text Label.
  139.                 SendClientMessageToAll(COLOR_RED, "[CRATE]: The crate has been destroyed! Another will respawn soon."); // Sending message to all players.
  140.                
  141.                 SetTimer("CrateMessage", CRATE_SPAWN_TIME, false); // Resetting the timer for respawn.
  142.             }
  143.         }
  144.         if(!response) // If they clicked 'Canel'.
  145.         {
  146.             DestroyDynamicObject(CrateObject); // Destroying the Crate Object.
  147.             CrateObject = 0;
  148.             DestroyDynamic3DTextLabel( Text3D:dynamiccrate3DText ); // Destroying the Crate 3D Text Label.
  149.             SendClientMessageToAll(COLOR_RED, "[CRATE]: The crate has been destroyed! Another will respawn soon.");// Sending message to all players.
  150.  
  151.             SetTimer("CrateMessage", CRATE_SPAWN_TIME, false); // Resetting the timer for respawn.
  152.         }
  153.         return 1;
  154.     }
  155.     return 0; // return 0 here!
  156. }
  157.  
  158. CMD:cratehelp(playerid, params[])// Show information about this system.
  159. {
  160.     ShowPlayerDialog(playerid, DIALOG_CRATE_HELP, DIALOG_STYLE_MSGBOX, "Crate Help",
  161.     "{FFFFFF}/opencrate\t\t{FFA500}Open the crate. (must be near it)\n\
  162.     {FFFFFF}/oc\t\t\t{FFA500}Open the crate. (must be near it)\n\
  163.     {FFFFFF}/cratehelp\t\t{FFA500}Open the crate help dialog\n\n\n\
  164.     {FF0000}NOTE: {FFFFFF}The crate will be destroyed at 24:00 if it has NOT been found. Another will respawn after!",
  165.     "Got It!", ""); // Showing the crate help dialog.
  166.     return 1;
  167. }
  168.  
  169. CMD:opencrate(playerid, params[])// To open the crate.
  170. {
  171.     if(CrateObject != 0)
  172.     {
  173.         new rand = random(sizeof(g_CrateSpawns));
  174.  
  175.         if(IsPlayerInRangeOfPoint(playerid, 5.0, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2])) // Checking the position and range of the player.
  176.         {
  177.             new name[MAX_PLAYER_NAME], string[128];
  178.             GetPlayerName(playerid, name, MAX_PLAYER_NAME);// Getting players name.
  179.            
  180.             format(string,sizeof(string),"[CRATE]: %s has found the crate. A new one will spawn soon!", name);
  181.             SendClientMessageToAll(COLOR_YELLOWGREEN, string); // Sending the message to all players.
  182.                
  183.             SendClientMessage(playerid, COLOR_RED, "THE CRATE WILL BE DESTROYED ONCE YOU CLOSE THIS DIALOG!!");// Sending a message to the player.
  184.             ShowPlayerDialog(playerid, DIALOG_CRATE, DIALOG_STYLE_LIST, "Crate Equipment","Shotgun\nMP5\nRifle\nDesert Eagle\nAK-47\nM4\nSPAS-12\nSniper\nHealth\nArmour\nDestroy Crate", "Take", "Destroy"); // Showing the crate dialog.
  185.         }
  186.         else
  187.         {
  188.             SendClientMessage(playerid, COLOR_RED, "You aren't near the crate!"); // If the player isn't near the crate.
  189.         }
  190.     }
  191.     return 1;
  192. }
  193.  
  194. CMD:oc(playerid, params[])// Shorter command for /opencrate
  195. {
  196.     return cmd_opencrate(playerid, params);
  197. }
  198.  
  199. CMD:crate(playerid, params[])// Outputs distance from crate in meters
  200. {
  201.     if(CrateObject != 0)
  202.     {
  203.         new rand = random(sizeof(g_CrateSpawns)),
  204.             Float: CrateDis = GetPlayerDistanceFromPoint(playerid, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2]),
  205.             string[64];
  206.  
  207.         format(string, sizeof(string), "* You're %.0f meters away from the Lost Crate.", CrateDis);
  208.         SendClientMessage(playerid, COLOR_YELLOWGREEN, string);// Sending message to the player.
  209.     }
  210.     else
  211.     {
  212.         SendClientMessage(playerid, COLOR_RED, "The crate hasn't been spawned yet. Check again soon.");// Sending message to the player.
  213.     }
  214.     return 1;
  215. }
  216.  
  217. public CrateMessage(playerid)
  218. {
  219.     new crateloc[30], string[128], rand = random(sizeof(g_CrateSpawns));
  220.     Get2DZone(g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], crateloc, sizeof(crateloc));
  221.  
  222.     if(CrateObject == 0)
  223.     {
  224.         CrateObject = CreateDynamicObject(CRATE_MODEL_ID, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2]-0.4, -1, -1, -1); // Spawning the crate.
  225.    
  226.         dynamiccrate3DText = CreateDynamic3DTextLabel("Open the Crate by using\n/opencrate or /oc", COLOR_RED, g_CrateSpawns[rand][0], g_CrateSpawns[rand][1], g_CrateSpawns[rand][2]+0.0, 10.0);// Creating a text label
  227.  
  228.         format(string,sizeof(string),"[CRATE]: A crate has been spawned at %s. Find it, and you'll be rewarded.", crateloc);
  229.         SendClientMessage(playerid, COLOR_YELLOWGREEN, string);// Sending message to the player.
  230.  
  231.         SendClientMessageToAll(COLOR_YELLOWGREEN, "[CRATE TIP]: Use /crate to see your distance from the crate.");// Sending message to all players.
  232.        
  233.         // DESTROYING IF NOT FOUND BY 24:00
  234.        
  235.         new hour, minutes;
  236.         GetPlayerTime(playerid, hour, minutes);
  237.        
  238.         if(hour == 24 && minutes == 59) // Destroying if the Crate isn't found by certain game time.
  239.         {
  240.             SendClientMessageToAll(COLOR_WHITE, "The Weapon Crate has NOT been found. It was eaten by a deer! A new one will respawn soon!");// Sending the message to all players.
  241.            
  242.             DestroyDynamicObject(CrateObject); // Destroying the Crate Object.
  243.             CrateObject = 0;
  244.             DestroyDynamic3DTextLabel(Text3D:dynamiccrate3DText); // Destroying the Crate 3D Text Label.
  245.                
  246.             SetTimer("CrateMessage", CRATE_SPAWN_TIME, false); // Resetting the timer for respawn.
  247.         }
  248.     }
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement