• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release [SOURCE] DOOR V2.0
#1
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using Addon;
  4. using System.Collections;
  5. using System.IO;
  6. using System.Timers;
  7. using System.Runtime.InteropServices;
  8.  
  9. namespace Door
  10. {
  11. public class Door : CPlugin
  12. {
  13. Dictionary<int, int> Client_HudElem_lm = new Dictionary<int, int>();
  14. int fx = 0;
  15. enum DoorState
  16. {
  17. Button,
  18. Top,
  19. Destroy
  20. };
  21.  
  22. public int DoorHealth = 750;
  23. int Interval = 0;
  24.  
  25. public int State = 0;
  26. public bool DoorWork = false;
  27.  
  28. List<Entity> Boxes = new List<Entity>();
  29.  
  30. public override void OnServerLoad()
  31. {
  32.  
  33.  
  34. Th.Elapsed += new ElapsedEventHandler(Event);
  35. Th.Interval = 150;
  36. }
  37.  
  38. Timer Th = new Timer();
  39.  
  40. int Counter = 0;
  41.  
  42. public override void OnMapChange()
  43. {
  44. Counter = 0;
  45.  
  46.  
  47.  
  48. Th.Stop();
  49. Boxes.Clear();
  50. Interval = 0;
  51. DoorHealth = 100;
  52. State = 0;
  53. DoorWork = false;
  54.  
  55. string map = GetDvar("mapname");
  56. if (map == "mp_lambeth")
  57. {
  58.  
  59. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(2850f, 703.719f, -281.875f)));
  60. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(2850f, 703.583f, -210.0819f)));
  61.  
  62.  
  63.  
  64.  
  65. for (int i = 0; i < Boxes.Count; i++)
  66. {
  67. Extensions.CloneBrushModelToScriptModel(Boxes[i], Extensions.FindAirdropCrateCollisionId());
  68.  
  69. }
  70. }
  71. if (map == "mp_lambeth")
  72. {
  73.  
  74. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(1887.093f, -520.5082f, -241.7929f)));
  75. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(1890.825f, -520.6057f, -172.9306f)));
  76.  
  77.  
  78.  
  79.  
  80. for (int i = 0; i < Boxes.Count; i++)
  81. {
  82. Extensions.CloneBrushModelToScriptModel(Boxes[i], Extensions.FindAirdropCrateCollisionId());
  83. Vector vector = Extensions.GetAngles(Boxes[i]); vector.Y += 90; Extensions.SetAngles(Boxes[i], vector);
  84.  
  85. }
  86. }
  87.  
  88. if (map == "mp_terminal_cls")
  89. {
  90.  
  91.  
  92. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3538.042f, 204.125f)));
  93. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3481.042f, 204.125f)));
  94. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3424.042f, 204.125f)));
  95.  
  96. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3538.042f, 270.125f)));
  97. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3481.042f, 270.125f)));
  98. Boxes.Add(SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(3861.388f, 3424.042f, 270.125f)));
  99.  
  100.  
  101. for (int i = 0; i < Boxes.Count; i++)
  102. {
  103. Extensions.CloneBrushModelToScriptModel(Boxes[i], Extensions.FindAirdropCrateCollisionId());
  104. Vector vector = Extensions.GetAngles(Boxes[i]); vector.Y += 90; Extensions.SetAngles(Boxes[i], vector);
  105. }
  106.  
  107. }
  108. }
  109.  
  110. public override void OnServerFrame()
  111. {
  112. if (Interval == 0)
  113. {
  114. Interval = 10;
  115. }
  116. else
  117. {
  118. Interval--;
  119. }
  120. }
  121.  
  122. public void Event(object source, ElapsedEventArgs e)
  123. {
  124. //Counter - количество смещений
  125. if (Counter <= 17)
  126. {
  127. if (State == (int)DoorState.Button)
  128. {
  129. for (int i = 0; i < Boxes.Count; i++)
  130. {
  131. // 5 = сколько смещять по Z на один цикл
  132. Boxes[i].OriginY += 10;
  133. }
  134. }
  135. else if (State == (int)DoorState.Top)
  136. {
  137. for (int i = 0; i < Boxes.Count; i++)
  138. {
  139. Boxes[i].OriginY -= 10;
  140. }
  141. }
  142. Counter++;
  143. }
  144. else
  145. {
  146. if (State == (int)DoorState.Button)
  147. {
  148. State = (int)DoorState.Top;
  149. }
  150. else
  151. {
  152. for (int i = 0; i < Boxes.Count; i++)
  153. {
  154. Extensions.CloneBrushModelToScriptModel(Boxes[i], Extensions.FindAirdropCrateCollisionId());
  155. }
  156. State = (int)DoorState.Button;
  157. }
  158.  
  159. DoorWork = false;
  160. Counter = 0;
  161. Th.Stop();
  162. }
  163. }
  164.  
  165. public override void OnAddonFrame()
  166. {
  167. List<ServerClient> clients;
  168. try
  169. {
  170. clients = GetClients();
  171.  
  172. if (clients != null && clients.Count > 0)
  173. {
  174. foreach (ServerClient c in GetClients())
  175. {
  176. if (c.Other.isAlive == true/* && !DoorDestroy*/)
  177. {
  178. HudElem hl = GetHudElement(Client_HudElem_lm[c.ClientNum]);
  179. string map = GetDvar("mapname");
  180. if (map == "mp_lambeth" && State != (int)DoorState.Destroy)
  181. {
  182. if ((Difference(c.OriginY, 703.0484f) <= 150) && (Difference(c.OriginX, 2850.202f) <= 150) && c.OriginZ >= -306.1291f)
  183. {
  184. if (c.Team == Teams.Allies)
  185. {
  186. if (!DoorWork && State == (int)DoorState.Button)
  187. {
  188. hl.SetString("Нажмите ^3F^7 чтобы ^1Открыть");
  189. }
  190. if (!DoorWork && State == (int)DoorState.Top)
  191. {
  192. hl.SetString("Нажмите ^3F^7 чтобы ^1Зыкрыть");
  193. }
  194.  
  195. if (c.Other.ButtonPressed(Buttons.Activate) && !DoorWork)
  196. {
  197. if (State == (int)DoorState.Button)
  198. {
  199. PlaySoundOnPlayer(c, "elev_door_close");
  200. for (int i = 0; i < Boxes.Count; i++)
  201. {
  202. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  203. }
  204. }
  205. if (State == (int)DoorState.Top)
  206. {
  207. PlaySoundOnPlayer(c, "elev_door_interupt");
  208. }
  209.  
  210. DoorWork = true;
  211. Counter = 0;
  212. Th.Start();
  213. }
  214. }
  215. else
  216. {
  217. hl.SetString("Бейте ножом что-бы^1 уничтожить ^7дверь!");
  218. if (c.Other.ButtonPressed(Buttons.Knife) && !DoorWork && State == (int)DoorState.Button)
  219. {
  220. if (DoorHealth > 5)
  221. {
  222. if (Interval == 0)
  223. {
  224. DoorHealth -= 5;
  225. iPrintLnBold("Осталось: ^2 " + DoorHealth, c);
  226. }
  227. }
  228. else
  229. {
  230. hl.SetString("");
  231. State = (int)DoorState.Destroy;
  232. for (int i = 0; i < Boxes.Count; i++)
  233. {
  234. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  235. Boxes[i].Delete();
  236. }
  237. Boxes.Clear();
  238. }
  239. }
  240. }
  241. }
  242. else
  243. {
  244. hl.SetString("");
  245. }
  246. }
  247. /////////
  248. if (map == "mp_terminal_cls" && State != (int)DoorState.Destroy)
  249. {
  250. if ((Difference(c.OriginY, 3490.191f) <= 150) && (Difference(c.OriginX, 3864.955f) <= 150) && c.OriginZ >= 100.125f)
  251. {
  252. if (c.Team == Teams.Allies)
  253. {
  254. if (!DoorWork && State == (int)DoorState.Button)
  255. {
  256. hl.SetString("Нажмите ^3F^7 чтобы ^1Открыть");
  257. }
  258. if (!DoorWork && State == (int)DoorState.Top)
  259. {
  260. hl.SetString("Нажмите ^3F^7 чтобы ^1Зыкрыть");
  261. }
  262.  
  263. if (c.Other.ButtonPressed(Buttons.Activate) && !DoorWork)
  264. {
  265. if (State == (int)DoorState.Button)
  266. {
  267. PlaySoundOnPlayer(c, "elev_door_close");
  268. for (int i = 0; i < Boxes.Count; i++)
  269. {
  270. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  271. }
  272. }
  273. if (State == (int)DoorState.Top)
  274. {
  275. PlaySoundOnPlayer(c, "elev_door_interupt");
  276. }
  277.  
  278. DoorWork = true;
  279. Counter = 0;
  280. Th.Start();
  281. }
  282. }
  283. else
  284. {
  285. hl.SetString("Бейте ножом что-бы^1 уничтожить ^7дверь!");
  286. if (c.Other.ButtonPressed(Buttons.Knife) && !DoorWork && State == (int)DoorState.Button)
  287. {
  288. if (DoorHealth > 5)
  289. {
  290. if (Interval == 0)
  291. {
  292. DoorHealth -= 5;
  293. iPrintLnBold("Осталось: ^2 " + DoorHealth, c);
  294. }
  295. }
  296. else
  297. {
  298. hl.SetString("");
  299. State = (int)DoorState.Destroy;
  300. for (int i = 0; i < Boxes.Count; i++)
  301. {
  302. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  303. Boxes[i].Delete();
  304. }
  305. Boxes.Clear();
  306. }
  307. }
  308. }
  309. }
  310. else
  311. {
  312. hl.SetString("");
  313. }
  314. }
  315. if (map == "mp_lambeth" && State != (int)DoorState.Destroy)
  316. {
  317. if ((Difference(c.OriginY, -534.8205f) <= 150) && (Difference(c.OriginX, 1895.324f) <= 150) && c.OriginZ >= -253.5872f)
  318. {
  319. if (c.Team == Teams.Allies)
  320. {
  321. if (!DoorWork && State == (int)DoorState.Button)
  322. {
  323. hl.SetString("Нажмите ^3F^7 чтобы ^1Открыть");
  324. }
  325. if (!DoorWork && State == (int)DoorState.Top)
  326. {
  327. hl.SetString("Нажмите ^3F^7 чтобы ^1Зыкрыть");
  328. }
  329.  
  330. if (c.Other.ButtonPressed(Buttons.Activate) && !DoorWork)
  331. {
  332. if (State == (int)DoorState.Button)
  333. {
  334. PlaySoundOnPlayer(c, "elev_door_close");
  335. for (int i = 0; i < Boxes.Count; i++)
  336. {
  337. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  338. }
  339. }
  340. if (State == (int)DoorState.Top)
  341. {
  342. PlaySoundOnPlayer(c, "elev_door_interupt");
  343. }
  344.  
  345. DoorWork = true;
  346. Counter = 0;
  347. Th.Start();
  348. }
  349. }
  350. else
  351. {
  352. hl.SetString("Бейте ножом что-бы^1 уничтожить ^7дверь!");
  353. if (c.Other.ButtonPressed(Buttons.Knife) && !DoorWork && State == (int)DoorState.Button)
  354. {
  355. if (DoorHealth > 3)
  356. {
  357. if (Interval == 0)
  358. {
  359. ;
  360.  
  361. DoorHealth -= 3;
  362. iPrintLnBold("Осталось: ^2 " + DoorHealth, c);
  363. }
  364. }
  365. else
  366. {
  367. hl.SetString("");
  368. State = (int)DoorState.Destroy;
  369. for (int i = 0; i < Boxes.Count; i++)
  370. {
  371. Extensions.PlayFX(fx, new Vector(1895.324f, -534.8205f, -253.5872f));
  372. Extensions.CloneBrushModelToScriptModel(Boxes[i], 0);
  373. Boxes[i].Delete();
  374. }
  375. Boxes.Clear();
  376. }
  377. }
  378. }
  379. }
  380. else
  381. {
  382. hl.SetString("");
  383. }
  384. }
  385. }
  386. }
  387.  
  388. }
  389. }
  390. catch (Exception z)
  391. {
  392. ServerPrint("Error Doors: " + z.Message);
  393. }
  394.  
  395. }
  396.  
  397. public static float Difference(float loc, float loc2)
  398. {
  399. return Math.Abs(loc - loc2);
  400. }
  401.  
  402. public override void OnPlayerDisconnect(ServerClient client)
  403. {
  404. if (Client_HudElem_lm.ContainsKey(client.ClientNum))
  405. {
  406. HudElem info2 = GetHudElement(Client_HudElem_lm[client.ClientNum]);
  407. info2.Type = HudElementTypes.None;
  408. Client_HudElem_lm.Remove(client.ClientNum);
  409. }
  410. }
  411.  
  412. public override void OnPlayerConnect(ServerClient client)
  413. {
  414. int HudElemNum1 = CreateHud_lm(client.ClientNum);
  415. if (Client_HudElem_lm.ContainsKey(client.ClientNum))
  416. {
  417. Client_HudElem_lm[client.ClientNum] = HudElemNum1;
  418. }
  419. else
  420. {
  421. Client_HudElem_lm.Add(client.ClientNum, HudElemNum1);
  422. }
  423. }
  424.  
  425. private int CreateHud_lm(int ClientNum)
  426. {
  427. HudElem hud = CreateNewHudElem();
  428. hud.Type = HudElementTypes.Text;
  429. hud.ShowToEnt = ClientNum;
  430. hud.HideInMenu = true;
  431. hud.Font = HudElementFonts.Default;
  432. hud.FontScale = 1.7f;
  433. hud.PointType = 120;
  434. hud.OriginY = 180f;
  435. hud.OriginX = -100f;
  436. hud.SetString("");
  437. return hud.HudElementNum;
  438. }
  439.  
  440. }
  441. }

powered by http://www.forum.hard-zombie.com
idea @[Z00MBY] Alex
help @extreme2010 (aka [MEM] So Close )
main @master131
creator http://www.forum.hard-zombie.com
[-] The following 1 user says Thank You to [HARD] Tony. for this post:
  • Yamato
  Reply
#2
:trollface:
[-] The following 1 user says Thank You to Slimpy for this post:
  • [HARD] Tony.
  Reply
#3
(09-26-2013, 02:00)Slimpy Wrote: :trollface:

Troll
  Reply
#4
Another stolen code. Troll

Code:
ClientHud_lm
^ this method is from my Killmz mod. That means 'lowermessage'.......
Also please, I recommend you to make this code look more beauty & organised.
C++/Obj-C developer. Neko engine wip
Steam: Click
  Reply
#5
it is removed
  Reply
#6
(09-26-2013, 13:53)[HARD] Tony. Wrote:
(09-26-2013, 12:14)SailorMoon Wrote: Another stolen code. Troll

Code:
ClientHud_lm
^ this method is from my Killmz mod. That means 'lowermessage'.......
Also please, I recommend you to make this code look more beauty & organised.

LAZY (((66(((6((,(6(
lazy lazy
Lazy Lazyzyxyxyxylaztuzlazy

@Retarded Guy
C++/Obj-C developer. Neko engine wip
Steam: Click
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [Release] [SOURCE] Random Weapons. [HARD] Tony. 1 2,261 11-08-2013, 11:11
Last Post: Nekochan
  Help source random weapons [HARD] Tony. 4 2,168 11-08-2013, 05:25
Last Post: [HARD] Tony.
  [Request] Health and Points on hud source robinvm 7 2,639 10-27-2013, 08:23
Last Post: robinvm
Video [Release] DOOR v1.0 [HARD] Tony. 15 3,739 09-19-2013, 17:44
Last Post: Nekochan
  [source] medic E-losev 6 2,672 07-26-2013, 06:18
Last Post: E-losev
  [source] vAmpIr E-losev 5 2,344 07-25-2013, 16:28
Last Post: Bandarigoda123
  DOOR HUD E-losev 2 1,467 07-17-2013, 17:50
Last Post: E-losev
  [Release] Barata's REAL External Console Source C# barata 37 11,019 06-28-2013, 23:47
Last Post: barata
  [Release] Shoutbot + source JariZ 11 2,990 04-05-2013, 18:15
Last Post: SuperNovaAO
Rainbow [News] Valve strikes again (Source Filmmaker) estebespt 25 5,949 04-05-2013, 18:15
Last Post: SuperNovaAO

Forum Jump:


Users browsing this thread: 1 Guest(s)