Advertisement
hoborific

WeaponBox 4.0 by Hoborific

Dec 21st, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.99 KB | None | 0 0
  1. /*
  2.  
  3. All content enclosed in this document and its compiled clone are property of Adam "Hoborific" M-S
  4.  
  5. This is not to be re-distributed,sold,given,gifted,or any other shape or form of transfer or disclosure.
  6. Any breach of the aforementioned terms will result in legal charges being pressed and your server host being contacted.
  7.  
  8.  
  9. You are to abide and follow these rules as you agreed to on downloading.
  10.  
  11.  
  12. Weaponbox 4.0 (C) 2010 - 2011, Adam "Hoborific" M-S
  13.  
  14. */
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. #include <a_samp>
  23. #include <zcmd>
  24.  
  25.  
  26. #define RED     0xE60000FF
  27. #define ORANGE  0xF97804FF
  28. #define WHITE   0xFFFFFFFF
  29. #define PURPLE  0xB360FDFF
  30.  
  31. new WeaponBox;
  32. new Text3D:BoxLabel;
  33. new isSpawned[MAX_PLAYERS];
  34. new bool: BoxSpawned,bool:AdminBox;
  35.  
  36. stock playername(playerid)
  37. {
  38.     new pName[MAX_PLAYER_NAME];                  
  39.     GetPlayerName(playerid, pName,MAX_PLAYER_NAME);
  40.     return pName;
  41. }
  42.  
  43.  
  44. public OnFilterScriptInit()
  45. {
  46.     print("\n--------------------------------------");
  47.     print(" Weaponbox 4.0 (C) 2010 - 2011, Adam 'Hoborific' M-S loaded.");
  48.     print("--------------------------------------\n");
  49.     WeaponBox = CreateObject(3796,300,300,3000,0.00000000,0.00000000,0.00000000,100);
  50.     SetTimer("BoxSpawnCheck" ,10 * 1000 ,1);
  51.     SetTimer("BoxAutoSpawn", 300 * 1000 ,1);
  52.     BoxSpawned = false;
  53.     AdminBox = false;
  54.     SetTimer("RandomBoxSpawn", 300 * 1000, true);
  55.     SendClientMessageToAll(ORANGE,"Weapon Box 4.0 by Hoborific loaded");
  56.     return 1;
  57. }
  58.  
  59. /*
  60.  
  61. forward BoxAutoSpawn();
  62.  
  63. public BoxAutoSpawn()
  64. {
  65. if (BoxSpawned == true)
  66. {
  67. DestroyObject(WeaponBox);
  68. Delete3DTextLabel(BoxLabel);
  69. spawnbox();
  70. }
  71. printf("stuff","stuff");
  72. }
  73.  
  74. */
  75.  
  76. forward spawnbox();
  77.  
  78.  
  79.  
  80. public OnFilterScriptExit()
  81. {
  82.     print("\n--------------------------------------");
  83.     print(" Weaponbox 4.0 by Hoborific unloaded.");
  84.     print("--------------------------------------\n");
  85.     DestroyObject(WeaponBox);
  86.     Delete3DTextLabel(BoxLabel);
  87.     BoxSpawned = false;
  88.     AdminBox = false;
  89.     SendClientMessageToAll(RED,"Weapon Box 4.0 by Hoborific has been turned off.");
  90.  
  91.     return 1;
  92. }
  93.  
  94.  
  95.  
  96.  
  97. command(box,playerid,params[]) // used to debug things mainly.
  98. {
  99.     new Float:X, Float:Y, Float:Z;
  100.     if (IsPlayerAdmin(playerid)) {
  101.         DestroyObject(WeaponBox);
  102.         Delete3DTextLabel(BoxLabel);
  103.         GetPlayerPos(playerid,X,Y,Z);
  104.         WeaponBox = CreateObject(3796,X,Y,Z-1,0.00000000,0.00000000,0.00000000,100);
  105.         BoxLabel = Create3DTextLabel("Weapon box",ORANGE,X,Y,Z+1,100,0,true);
  106.         BoxSpawned = true;
  107.         AdminBox = true;
  108.         SendClientMessageToAll(PURPLE,"A Weapon box has been spotted in San Andreas!");
  109.         // I did plan to do more here, will do some more shit in the next update.
  110.         return 1;
  111.     }
  112.     {
  113.         SendClientMessage(playerid,RED, "You aren't an admin");
  114.         return 1;
  115.     }
  116. }
  117.  
  118.  
  119. Float:GetDistance( Float: x1, Float: y1, Float: z1, Float: x2, Float: y2, Float: z2 ) //credits to whom ever this came from, I have forgotten.
  120. {
  121.     new Float:d;
  122.     d += floatpower(x1-x2, 2.0 );
  123.     d += floatpower(y1-y2, 2.0 );
  124.     d += floatpower(z1-z2, 2.0 );
  125.     d = floatsqroot(d);
  126.     return d;
  127. }
  128.  
  129. public spawnbox()
  130. {
  131. switch (random(8))
  132. {
  133. case 0:{
  134.         WeaponBox = CreateObject(3796,1989.8403,-1482.7559,9.8281,0,0,270.2540,100);
  135.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  136.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {9933FF}A Weapon box has been spotted around County General Hospital");
  137.         }
  138. case 1:{
  139.         WeaponBox = CreateObject(3796,1956.9316,-1201.4017,16.4500,0,0,95.1888,100);
  140.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  141.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {9933FF}A Weapon box has been spotted around Glen Park");
  142.         }
  143. case 2:{
  144.         WeaponBox = CreateObject(3796,1319.8448,-1239.2180,12.5469,0,0,89.0429,100);
  145.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  146.         SendClientMessageToAll(WHITE,"[WEAPONBOX]:{FF6600}A Weapon box has been delivered to the ammunation, it is hidden across the street.");
  147.         //SendClientMessageToAll(ORANGE,"{FF6600}Go get it before anyone else does!");
  148.         }
  149. case 3:{
  150.         WeaponBox = CreateObject(3796,1035.3901,-1351.1062,17.5141,0,0,262.1001,100);
  151.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  152.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {FF00CC}A Weapon box has been left on the Donut Shop roof (go get it before the pigs realize!)");
  153.         }
  154. case 4:{
  155.         WeaponBox = CreateObject(3796,1542.9207,-1669.8722,12.5554,0,0,86.3137,100);
  156.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  157.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {FFFF00}A Weapon box has been delivered to the LSPD go steal it before they notice it!");
  158.         }
  159. case 5:{
  160.         WeaponBox = CreateObject(3796,756.8765,-1881.4176,1.5403,0,0,33.1117,100);
  161.         BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  162.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {FF9900}A Weapon box has washed up on the beach go find it before someone calls it in!");
  163.         }
  164. case 6:{
  165.         WeaponBox = CreateObject(3796,305.1527,-1895.3317,0.4861,0,0,350.4532,100);
  166.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  167.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {FF9900}A Weapon box has washed up on shore go find it before someone calls it in!");
  168.         }
  169. case 7:{
  170.         WeaponBox = CreateObject(3796,1483.9762,-1732.2932,5.7253,0,0,269.6984,100);
  171.         //BoxLabel = Create3DTextLabel("Weapon box",ORANGE,0,0,0,100,0,true);
  172.         SendClientMessageToAll(WHITE,"[WEAPONBOX]: {00FF00}A Weapon box has been smuggled and is waiting in the underground sewer network!");
  173.         }
  174.  
  175.  
  176. }
  177. return 1;
  178. }
  179.  
  180. command(forcespawn,playerid,params)
  181. {
  182. if (IsPlayerAdmin(playerid))
  183. {
  184. BoxSpawned = true;
  185. AdminBox = true;
  186. spawnbox();
  187. return 1;
  188. }
  189. SendClientMessage(playerid,RED,"You aren't an admin!");
  190. return 1;
  191. }
  192.  
  193. forward RandomBoxSpawn();
  194.  
  195. public RandomBoxSpawn()
  196. {if (BoxSpawned == true)
  197. {
  198. DestroyObject(WeaponBox);
  199. Delete3DTextLabel(BoxLabel);
  200. spawnbox();
  201. }
  202.  if(BoxSpawned == false)
  203. {
  204. BoxSpawned = true;
  205. spawnbox();
  206.  
  207. }
  208. }
  209.  
  210.  
  211. forward BoxSpawnCheck();
  212. public BoxSpawnCheck()  //I didn't know a better way XD
  213. {
  214. if (AdminBox == true)
  215. {
  216. Weaponbox();
  217. }
  218. if (AdminBox == false && BoxSpawned == true)
  219. {
  220. Weaponbox();
  221. return 1;
  222. }
  223. if (AdminBox == false && BoxSpawned == false)
  224. {
  225. // some function here for random box spawn
  226.  
  227. //Changed to auto random spawn function.
  228. }
  229.  
  230. return 1;
  231. }
  232.  
  233.  
  234. forward Weaponbox();
  235. public Weaponbox()
  236. {
  237.     for(new i = 0; i<MAX_PLAYERS; i++) {
  238.         if(!IsPlayerConnected( i )  && isSpawned[i] ==1) continue;
  239.         new Float:X,Float:Y,Float:Z;
  240.         new Float:BX,Float:BY,Float:BZ;
  241.  
  242.         GetPlayerPos(i,X,Y,Z);
  243.         GetObjectPos(WeaponBox,BX,BY,BZ);
  244.         if (GetDistance(X,Y,Z,BX,BY,BZ) <= 12) {
  245.             //new string[128];
  246. // is now sen't via weapon rand             format(string, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained an{FF0000} AK47!", playername(i));
  247.             //SendClientMessageToAll(WHITE,string);
  248.             DestroyObject(WeaponBox);
  249.             Delete3DTextLabel(BoxLabel);
  250.             weaponboxgive(i);
  251.             BoxSpawned = false;
  252.             AdminBox = false;
  253.             return 1;
  254.         }
  255.     }
  256.     return 1;
  257. }
  258.  
  259.  
  260. /*
  261.     if (GetDistance(X,Y,Z,BX,BY,BZ) <= 30)  {
  262.     SendClientMessage(i,YELLOW," Weapon box is near!");
  263.     }
  264. */
  265.  
  266. forward weaponboxgive(i);
  267. public weaponboxgive(i)
  268. {
  269.  
  270.     switch(random(7)) {
  271.         case 0:
  272.         {
  273.             new AK47[128];
  274.             format(AK47, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained an{FF0000} AK47!", playername(i));            GivePlayerWeapon(i,30,999999);
  275.             SendClientMessageToAll(WHITE,AK47);
  276.         }
  277.         case 1:
  278.         {
  279.             new DE[128];
  280.             format(DE, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained a{FF0000} Desert Eagle!", playername(i));           GivePlayerWeapon(i,24,999999);
  281.             SendClientMessageToAll(WHITE,DE);
  282.         }
  283.         case 2:
  284.         {
  285.             new SPAS[128];
  286.             format(SPAS, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained a{FF0000} SPAS-12!", playername(i));
  287.             GivePlayerWeapon(i,27,999999);
  288.             SendClientMessageToAll(WHITE,SPAS);
  289.         }
  290.         case 3:
  291.         {
  292.             new Shotgun[128];
  293.             format(Shotgun, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained a{FF0000} Pump Action Shotgun!", playername(i));
  294.             GivePlayerWeapon(i,25,999999);
  295.             SendClientMessageToAll(WHITE,Shotgun);
  296.         }
  297.         case 4:
  298.         {
  299.             new MP5[128];
  300.             format(MP5, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained an{FF0000} MP5!", playername(i));
  301.             GivePlayerWeapon(i,28,999999);
  302.             SendClientMessageToAll(WHITE,MP5);
  303.         }
  304.         case 5:
  305.         {
  306.             new TRAP[128];
  307.             format(TRAP, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it was a trap! the police are now after {FF0000}%s!",playername(i), playername(i));
  308.             SendClientMessageToAll(WHITE,TRAP);
  309.             SetPlayerWantedLevel(i,4);
  310.         }
  311.         case 6:
  312.         {
  313.             new parachute[128];
  314.             format(parachute, 128, "[WEAPONBOX]: Found by {FF0000}%s{FFFFFF} || it contained a{FF0000} Parachute?", playername(i));
  315.             GivePlayerWeapon(i,46,999999);
  316.             SendClientMessageToAll(WHITE,parachute);
  317.         }
  318.  
  319.     }
  320.     new cash = 3500+random(4500),
  321.         string[128];
  322.     format(string, 128, "{00FF00}You also received {00FF00}$%d! {00FF00}for calling in the Weapon Box to the authorities",cash);
  323.     SendClientMessage(i,WHITE,string);
  324.     GivePlayerMoney(i,cash);
  325.     BoxSpawned = false;
  326.     AdminBox = false;}
  327.  
  328.  
  329. public OnPlayerConnect(playerid)
  330. {
  331.     isSpawned[playerid] = false;
  332.     SetPlayerVirtualWorld(playerid,0);
  333.     return 1;
  334. }
  335.  
  336.  
  337. public OnPlayerSpawn(playerid)
  338. {
  339.     isSpawned[playerid] = true;
  340.     return 1;
  341. }
  342.  
  343. public OnPlayerRequestClass(playerid)
  344. {
  345.     isSpawned[playerid] = false;
  346.     return 1;
  347. }
  348.  
  349.  
  350.  
  351. command(boxadmin,playerid,params[])
  352. {if(IsPlayerAdmin(playerid))
  353. {
  354. ShowPlayerDialog(playerid,42,DIALOG_STYLE_LIST,"Admin settings for the Weapon Box 4.0 by Hoborific","Enable/Disable\r\nErase Custom spawns\r\nToggle Default Spawns \r\n","Cancel","Select");
  355. return 1;
  356. }
  357.  SendClientMessage(playerid,RED," You are not an Rcon Administrator!");
  358.  return 1;
  359. }
  360.  
  361.  
  362.  
  363. new BoxIO;
  364.  
  365. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  366. {
  367. if(response)
  368.     {
  369.         switch(dialogid)
  370.         {
  371.                 case 42:
  372.                 {
  373.                 switch(listitem)
  374.                 {
  375.                 case 0:
  376.                 {
  377.                 if (BoxIO == 1)
  378.                     {
  379.                     BoxIO = 0;
  380.                     SendClientMessageToAll(RED,"{FF6600}[WEAPONBOX]:{FFFFFF} Weapon box 4.0 By Hoborific has been disabled!");
  381.                     return 1;
  382.                     }
  383.                 else
  384.                     {
  385.                     BoxIO = 1;
  386.                     SendClientMessageToAll(RED,"{00FF00}[WEAPONBOX]:{FFFFFF} Weapon box 4.0 By Hoborific has been Enabled!");
  387.                     return 1;
  388.                     }
  389.                 }
  390.  
  391.                 }
  392.                 }
  393.       }
  394.   }
  395. return 1;
  396. }
  397.  
  398. command(weaponboxcredits,playerid,params[])
  399. {
  400.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {FF6600}WeaponBox 4.0 was created by Adam 'Hoborific' M-S");
  401.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {00FF00}Additional Credits to Zeex for Zcmd, Killa[DGZ] for collaborating on the concept, Ryan_Yarrum for being a fuck.");
  402.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {FF00CC}if you feel I have forgotten you, contact me via SA-MP forums, My username is 'Hoborific' ");
  403.     return 1;
  404. }
  405.  
  406. command(weaponboxinfo,playerid,params[])
  407. {
  408.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {FF6600}WeaponBox 4.0 was created by Adam 'Hoborific' M-S");
  409.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {00FF00}Additional Credits to Zeex for Zcmd, Killa[DGZ] for collaborating on the concept, Ryan_Yarrum for being a fuck.");
  410.     SendClientMessage(playerid,RED,"{FFFFFF}[WEAPONBOX]: {FF00CC}if you feel I have forgotten you, contact me via SA-MP forums, My username is 'Hoborific' ");
  411.     return 1;
  412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement