Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.59 KB | None | 0 0
  1. --[[
  2. � 2013 CloudSixteen.com do not share, re-distribute or modify
  3. without permission of its author (kurozael@gmail.com).
  4. --]]
  5.  
  6. Schema.scannerSounds = {
  7. "npc/scanner/cbot_servochatter.wav",
  8. "npc/scanner/cbot_servoscared.wav",
  9. "npc/scanner/scanner_blip1.wav",
  10. "npc/scanner/scanner_scan1.wav",
  11. "npc/scanner/scanner_scan2.wav",
  12. "npc/scanner/scanner_scan4.wav",
  13. "npc/scanner/scanner_scan5.wav",
  14. "npc/scanner/combat_scan1.wav",
  15. "npc/scanner/combat_scan2.wav",
  16. "npc/scanner/combat_scan3.wav",
  17. "npc/scanner/combat_scan4.wav",
  18. "npc/scanner/combat_scan5.wav"
  19. };
  20. Schema.scanners = {};
  21. Schema.cwuProps = {
  22. "models/props_c17/furniturewashingmachine001a.mdl",
  23. "models/props_interiors/furniture_vanity01a.mdl",
  24. "models/props_interiors/furniture_couch02a.mdl",
  25. "models/props_interiors/furniture_shelf01a.mdl",
  26. "models/props_interiors/furniture_chair01a.mdl",
  27. "models/props_interiors/furniture_desk01a.mdl",
  28. "models/props_interiors/furniture_lamp01a.mdl",
  29. "models/props_c17/furniturecupboard001a.mdl",
  30. "models/props_c17/furnituredresser001a.mdl",
  31. "props/props_c17/furniturefridge001a.mdl",
  32. "models/props_c17/furniturestove001a.mdl",
  33. "models/props_interiors/radiator01a.mdl",
  34. "props/props_c17/furniturecouch001a.mdl",
  35. "models/props_combine/breenclock.mdl",
  36. "props/props_combine/breenchair.mdl",
  37. "models/props_c17/shelfunit01a.mdl",
  38. "props/props_combine/breendesk.mdl",
  39. "models/props_lab/monitor01b.mdl",
  40. "models/props_lab/monitor01a.mdl",
  41. "models/props_lab/monitor02.mdl",
  42. "models/props_c17/frame002a.mdl",
  43. "models/props_c17/bench01a.mdl"
  44. };
  45.  
  46. Clockwork.kernel:AddFile("resource/fonts/mailartrubberstamp.ttf");
  47. Clockwork.kernel:AddFile("models/eliteghostcp.mdl");
  48. Clockwork.kernel:AddFile("models/eliteshockcp.mdl");
  49. Clockwork.kernel:AddFile("models/policetrench.mdl");
  50. Clockwork.kernel:AddFile("models/leet_police2.mdl");
  51. Clockwork.kernel:AddFile("models/sect_police2.mdl");
  52.  
  53. Clockwork.kernel:AddDirectory("materials/models/humans/female/group01/cityadm_sheet.*");
  54. Clockwork.kernel:AddDirectory("materials/models/humans/male/group01/cityadm_sheet.*");
  55. Clockwork.kernel:AddDirectory("models/humans/group17/*.mdl");
  56. Clockwork.kernel:AddDirectory("materials/models/humans/female/group01/cityadm_sheet.*");
  57. Clockwork.kernel:AddDirectory("materials/models/deadbodies/");
  58. Clockwork.kernel:AddDirectory("materials/models/spraycan3.*");
  59. Clockwork.kernel:AddDirectory("materials/models/police/*.*");
  60. Clockwork.kernel:AddDirectory("materials/models/lagmite/");
  61. Clockwork.kernel:AddDirectory("materials/halfliferp/");
  62. Clockwork.kernel:AddDirectory("models/lagmite/");
  63. Clockwork.kernel:AddDirectory("models/deadbodies/");
  64.  
  65. Clockwork.config:Add("server_whitelist_identity", "");
  66. Clockwork.config:Add("combine_lock_overrides", false);
  67. Clockwork.config:Add("intro_text_small", "It is safer here.", true);
  68. Clockwork.config:Add("intro_text_big", "CITY EIGHTEEN, 2016.", true);
  69. Clockwork.config:Add("knockout_time", 60);
  70. Clockwork.config:Add("business_cost", 160, true);
  71. Clockwork.config:Add("cwu_props", true);
  72. Clockwork.config:Add("permits", true, true);
  73.  
  74. Clockwork.config:Get("enable_gravgun_punt"):Set(false);
  75. Clockwork.config:Get("default_inv_weight"):Set(6);
  76. Clockwork.config:Get("enable_crosshair"):Set(false);
  77. Clockwork.config:Get("disable_sprays"):Set(false);
  78. Clockwork.config:Get("prop_cost"):Set(false);
  79. Clockwork.config:Get("door_cost"):Set(0);
  80.  
  81. -- A function to add a human hint.
  82. function Clockwork.hint:AddHumanHint(name, text, combine)
  83. Clockwork.hint:Add(name, text, function(player)
  84. if (player) then
  85. return !Schema:PlayerIsCombine(player, combine);
  86. end;
  87. end);
  88. end;
  89.  
  90. Clockwork.hint:AddHumanHint("Life", "Your character is only human, refrain from jumping off high ledges.", false);
  91. Clockwork.hint:AddHumanHint("Sleep", "Don't forget to sleep, your character does get tired.", false);
  92. Clockwork.hint:AddHumanHint("Eating", "Just because you don't have to eat, it doesn't mean your character isn't hungry.", false);
  93. Clockwork.hint:AddHumanHint("Friends", "Making friends is the basis of a good team", false);
  94.  
  95. Clockwork.hint:AddHumanHint("Prison", "Don't perform an act of criminality if you are not prepared to answer for it");
  96. Clockwork.hint:AddHumanHint("Punching", "Got that feeling you just wanna punch somebody? Don't.");
  97.  
  98. Clockwork.hint:Add("Admins", "The admins are here to help you, please respect them.");
  99. Clockwork.hint:Add("Action", "Action. Stop looking for it, wait until it comes to you.");
  100. Clockwork.hint:Add("Grammar", "Try to speak correctly in-character, and don't use emoticons.");
  101. Clockwork.hint:Add("Firefights", "When engaged in a firefight, shoot to miss to make it enjoyable.");
  102. Clockwork.hint:Add("Metagaming", "Metagaming is when you use OOC information in-character.");
  103. Clockwork.hint:Add("Passive RP", "If you're bored and there's no action, try some passive roleplay.");
  104. Clockwork.hint:Add("Development", "Develop your character, give them a story to tell.");
  105. Clockwork.hint:Add("Powergaming", "Powergaming is when you force your actions on others.");
  106.  
  107. Clockwork.datastream:Hook("EditObjectives", function(player, data)
  108. if (player.editObjectivesAuthorised and type(data) == "string") then
  109. if (Schema.combineObjectives != data) then
  110. Schema:AddCombineDisplayLine("Downloading recent objectives...", Color(255, 100, 255, 255));
  111. Schema.combineObjectives = string.sub(data, 0, 500);
  112.  
  113. Clockwork.kernel:SaveSchemaData("objectives", {
  114. text = Schema.combineObjectives
  115. });
  116. end;
  117.  
  118. player.editObjectivesAuthorised = nil;
  119. end;
  120. end);
  121.  
  122. Clockwork.datastream:Hook("ObjectPhysDesc", function(player, data)
  123. if (type(data) == "table" and type( data[1] ) == "string") then
  124. if (player.objectPhysDesc == data[2]) then
  125. local physDesc = data[1];
  126.  
  127. if (string.len(physDesc) > 80) then
  128. physDesc = string.sub(physDesc, 1, 80).."...";
  129. end;
  130.  
  131. data[2]:SetNetworkedString("physDesc", physDesc);
  132. end;
  133. end;
  134. end);
  135.  
  136. Clockwork.datastream:Hook("EditData", function(player, data)
  137. if (player.editDataAuthorised == data[1] and type( data[2] ) == "string") then
  138. data[1]:SetCharacterData( "combinedata", string.sub(data[2], 0, 500) );
  139.  
  140. player.editDataAuthorised = nil;
  141. end;
  142. end);
  143.  
  144. -- A function to calculate a player's scanner think.
  145. function Schema:CalculateScannerThink(player, curTime)
  146. if (!self.scanners[player]) then return; end;
  147.  
  148. local scanner = self.scanners[player][1];
  149. local marker = self.scanners[player][2];
  150.  
  151. if (IsValid(scanner) and IsValid(marker)) then
  152. scanner:SetMaxHealth( player:GetMaxHealth() );
  153.  
  154. player:SetMoveType(MOVETYPE_OBSERVER);
  155. player:SetHealth( math.max(scanner:Health(), 0) );
  156.  
  157. if (!player.nextScannerSound or curTime >= player.nextScannerSound) then
  158. player.nextScannerSound = curTime + math.random(8, 48);
  159.  
  160. scanner:EmitSound( self.scannerSounds[ math.random(1, #self.scannerSounds) ] );
  161. end;
  162. end;
  163. end;
  164.  
  165. -- A function to reset a player's scanner.
  166. function Schema:ResetPlayerScanner(player, noMessage)
  167. if (self.scanners[player]) then
  168. local scanner = self.scanners[player][1];
  169. local marker = self.scanners[player][2];
  170.  
  171. if (IsValid(scanner)) then
  172. scanner:Remove();
  173. end;
  174.  
  175. if (IsValid(marker)) then
  176. marker:Remove();
  177. end;
  178.  
  179. self.scanners[player] = nil;
  180.  
  181. if (!noMessage) then
  182. player:SetMoveType(MOVETYPE_WALK);
  183. player:UnSpectate();
  184. player:KillSilent();
  185. end;
  186. end;
  187. end;
  188.  
  189. -- A function to make a player a scanner.
  190. function Schema:MakePlayerScanner(player, noMessage, lightSpawn)
  191. self:ResetPlayerScanner(player, noMessage);
  192.  
  193. local scannerClass = "npc_cscanner";
  194.  
  195. if (self:IsPlayerCombineRank(player, "SYNTH")) then
  196. scannerClass = "npc_clawscanner";
  197. end;
  198.  
  199. local position = player:GetShootPos();
  200. local uniqueID = player:UniqueID();
  201. local scanner = ents.Create(scannerClass);
  202. local marker = ents.Create("path_corner");
  203.  
  204. Clockwork.entity:SetPlayer(scanner, player);
  205.  
  206. scanner:SetPos( position + Vector(0, 0, 16) );
  207. scanner:SetAngles( player:GetAimVector():Angle() );
  208. scanner:SetKeyValue("targetname", "scanner_"..uniqueID);
  209. scanner:SetKeyValue("spawnflags", 8592);
  210. scanner:SetKeyValue("renderfx", 0);
  211. scanner:Spawn(); scanner:Activate();
  212.  
  213. marker:SetKeyValue("targetname", "marker_"..uniqueID);
  214. marker:SetPos(position);
  215. marker:Spawn(); marker:Activate();
  216.  
  217. if (!lightSpawn) then
  218. player:Flashlight(false);
  219. player:RunCommand("-duck");
  220.  
  221. if (scannerClass == "npc_clawscanner") then
  222. player:SetHealth(200);
  223. end;
  224. end;
  225.  
  226. player:SetArmor(0);
  227. player:Spectate(OBS_MODE_CHASE);
  228. player:StripWeapons();
  229. player:SetSharedVar("scanner", scanner:EntIndex());
  230. player:SetMoveType(MOVETYPE_OBSERVER);
  231. player:SpectateEntity(scanner);
  232.  
  233. scanner:SetMaxHealth( player:GetMaxHealth() );
  234. scanner:SetHealth( player:Health() );
  235. scanner:Fire("SetDistanceOverride", 64, 0);
  236. scanner:Fire("SetFollowTarget", "marker_"..uniqueID, 0);
  237.  
  238. self.scanners[player] = {scanner, marker};
  239.  
  240. Clockwork.kernel:CreateTimer("scanner_sound_"..uniqueID, 0.01, 1, function()
  241. if (IsValid(scanner)) then
  242. scanner.flyLoop = CreateSound(scanner, "npc/scanner/cbot_fly_loop.wav");
  243. scanner.flyLoop:Play();
  244. end;
  245. end);
  246.  
  247. scanner:CallOnRemove("Scanner Sound", function(scanner)
  248. if (scanner.flyLoop) then
  249. scanner.flyLoop:Stop();
  250. end;
  251. end);
  252. end;
  253.  
  254. -- A function to add a Combine display line.
  255. function Schema:AddCombineDisplayLine(text, color, player, exclude)
  256. if (player) then
  257. Clockwork.datastream:Start( player, "CombineDisplayLine", {text, color} );
  258. else
  259. local players = {};
  260.  
  261. for k, v in ipairs( _player.GetAll() ) do
  262. if (self:PlayerIsCombine(v) and v != exclude) then
  263. players[#players + 1] = v;
  264. end;
  265. end;
  266.  
  267. Clockwork.datastream:Start(players, "CombineDisplayLine", {text, color});
  268. end;
  269. end;
  270.  
  271. -- A function to load the objectives.
  272. function Schema:LoadObjectives()
  273. local combineObjectives = Clockwork.kernel:RestoreSchemaData("objectives");
  274.  
  275. if (combineObjectives and combineObjectives.text) then
  276. self.combineObjectives = combineObjectives.text;
  277. else
  278. self.combineObjectives = "";
  279. end;
  280. end;
  281.  
  282. -- A function to load the NPCs.
  283. function Schema:LoadNPCs()
  284. local npcs = Clockwork.kernel:RestoreSchemaData("plugins/npcs/"..game.GetMap());
  285.  
  286. for k, v in pairs(npcs) do
  287. local entity = ents.Create(v.class);
  288.  
  289. if (IsValid(entity)) then
  290. entity:SetKeyValue("spawnflags", v.spawnFlags or 0);
  291. entity:SetKeyValue("additionalequipment", v.equipment or "");
  292. entity:SetAngles(v.angles);
  293. entity:SetModel(v.model);
  294. entity:SetPos(v.position);
  295. entity:Spawn();
  296.  
  297. if (IsValid(entity)) then
  298. entity:Activate();
  299.  
  300. entity:SetNetworkedString("cw_Name", v.name);
  301. entity:SetNetworkedString("cw_Title", v.title);
  302. end;
  303. end;
  304. end;
  305. end;
  306.  
  307. -- A function to save the NPCs.
  308. function Schema:SaveNPCs()
  309. local npcs = {};
  310.  
  311. for k, v in pairs( ents.FindByClass("npc_*") ) do
  312. local name = v:GetNetworkedString("cw_Name");
  313. local title = v:GetNetworkedString("cw_Title");
  314.  
  315. if (name != "" and title != "") then
  316. local keyValues = table.LowerKeyNames( v:GetKeyValues() );
  317.  
  318. npcs[#npcs + 1] = {
  319. spawnFlags = keyValues["spawnflags"],
  320. equipment = keyValues["additionequipment"],
  321. position = v:GetPos(),
  322. angles = v:GetAngles(),
  323. model = v:GetModel(),
  324. title = title,
  325. class = v:GetClass(),
  326. name = name
  327. };
  328. end;
  329. end;
  330.  
  331. Clockwork.kernel:SaveSchemaData("plugins/npcs/"..game.GetMap(), npcs);
  332. end;
  333.  
  334. -- A function to load the Combine locks.
  335. function Schema:LoadCombineLocks()
  336. local combineLocks = Clockwork.kernel:RestoreSchemaData( "plugins/locks/"..game.GetMap() );
  337.  
  338. for k, v in pairs(combineLocks) do
  339. local entity = ents.FindInSphere(v.doorPosition, 16)[1];
  340.  
  341. if (IsValid(entity)) then
  342. local combineLock = self:ApplyCombineLock(entity);
  343.  
  344. if (combineLock) then
  345. Clockwork.player:GivePropertyOffline(v.key, v.uniqueID, entity);
  346.  
  347. combineLock:SetLocalAngles(v.angles);
  348. combineLock:SetLocalPos(v.position);
  349.  
  350. if (!v.locked) then
  351. combineLock:Unlock();
  352. else
  353. combineLock:Lock();
  354. end;
  355. end;
  356. end;
  357. end;
  358. end;
  359.  
  360. -- A function to save the Combine locks.
  361. function Schema:SaveCombineLocks()
  362. local combineLocks = {};
  363.  
  364. for k, v in pairs( ents.FindByClass("cw_combinelock") ) do
  365. if (IsValid(v.entity)) then
  366. combineLocks[#combineLocks + 1] = {
  367. key = Clockwork.entity:QueryProperty(v, "key"),
  368. locked = v:IsLocked(),
  369. angles = v:GetLocalAngles(),
  370. position = v:GetLocalPos(),
  371. uniqueID = Clockwork.entity:QueryProperty(v, "uniqueID"),
  372. doorPosition = v.entity:GetPos()
  373. };
  374. end;
  375. end;
  376.  
  377. Clockwork.kernel:SaveSchemaData("plugins/locks/"..game.GetMap(), combineLocks);
  378. end;
  379.  
  380. -- A function to load the radios.
  381. function Schema:LoadRadios()
  382. local radios = Clockwork.kernel:RestoreSchemaData( "plugins/radios/"..game.GetMap() );
  383.  
  384. for k, v in pairs(radios) do
  385. local entity = ents.Create("cw_radio");
  386.  
  387. Clockwork.player:GivePropertyOffline(v.key, v.uniqueID, entity);
  388.  
  389. entity:SetAngles(v.angles);
  390. entity:SetPos(v.position);
  391. entity:Spawn();
  392.  
  393. if (IsValid(entity)) then
  394. entity:SetFrequency(v.frequency);
  395. entity:SetOff(v.off);
  396. end;
  397.  
  398. if (!v.moveable) then
  399. local physicsObject = entity:GetPhysicsObject();
  400.  
  401. if (IsValid(physicsObject)) then
  402. physicsObject:EnableMotion(false);
  403. end;
  404. end;
  405. end;
  406. end;
  407.  
  408. -- A function to load the ration dispensers.
  409. function Schema:LoadRationDispensers()
  410. local dispensers = Clockwork.kernel:RestoreSchemaData( "plugins/dispensers/"..game.GetMap() );
  411.  
  412. for k, v in pairs(dispensers) do
  413. local entity = ents.Create("cw_rationdispenser");
  414.  
  415. entity:SetPos(v.position);
  416. entity:Spawn();
  417.  
  418. if (IsValid(entity)) then
  419. entity:SetAngles(v.angles);
  420.  
  421. if (!v.locked) then
  422. entity:Unlock();
  423. else
  424. entity:Lock();
  425. end;
  426. end;
  427. end;
  428. end;
  429.  
  430. -- A function to save the ration dispensers.
  431. function Schema:SaveRationDispensers()
  432. local dispensers = {};
  433.  
  434. for k, v in pairs(ents.FindByClass("cw_rationdispenser")) do
  435. dispensers[#dispensers + 1] = {
  436. locked = v:IsLocked(),
  437. angles = v:GetAngles(),
  438. position = v:GetPos()
  439. };
  440. end;
  441.  
  442. Clockwork.kernel:SaveSchemaData("plugins/dispensers/"..game.GetMap(), dispensers);
  443. end;
  444.  
  445. -- A function to load the ration machines.
  446. function Schema:LoadVendingMachines()
  447. local machines = Clockwork.kernel:RestoreSchemaData("plugins/machines/"..game.GetMap());
  448.  
  449. for k, v in pairs(machines) do
  450. local entity = ents.Create("cw_vendingmachine");
  451.  
  452. entity:SetPos(v.position);
  453. entity:Spawn();
  454.  
  455. if ( IsValid(entity) ) then
  456. entity:SetAngles(v.angles);
  457. entity:SetStock(v.stock, v.defaultStock);
  458. end;
  459. end;
  460. end;
  461.  
  462. -- A function to save the ration machines.
  463. function Schema:SaveVendingMachines()
  464. local machines = {};
  465.  
  466. for k, v in pairs(ents.FindByClass("cw_vendingmachine")) do
  467. machines[#machines + 1] = {
  468. stock = v:GetStock(),
  469. angles = v:GetAngles(),
  470. position = v:GetPos(),
  471. defaultStock = v:GetDefaultStock()
  472. };
  473. end;
  474.  
  475. Clockwork.kernel:SaveSchemaData("plugins/machines/"..game.GetMap(), machines);
  476. end;
  477.  
  478. -- A function to save the radios.
  479. function Schema:SaveRadios()
  480. local radios = {};
  481.  
  482. for k, v in pairs( ents.FindByClass("cw_radio") ) do
  483. local physicsObject = v:GetPhysicsObject();
  484. local moveable;
  485.  
  486. if (IsValid(physicsObject)) then
  487. moveable = physicsObject:IsMoveable();
  488. end;
  489.  
  490. radios[#radios + 1] = {
  491. off = v:IsOff(),
  492. key = Clockwork.entity:QueryProperty(v, "key"),
  493. angles = v:GetAngles(),
  494. moveable = moveable,
  495. uniqueID = Clockwork.entity:QueryProperty(v, "uniqueID"),
  496. position = v:GetPos(),
  497. frequency = v:GetFrequency()
  498. };
  499. end;
  500.  
  501. Clockwork.kernel:SaveSchemaData("plugins/radios/"..game.GetMap(), radios);
  502. end;
  503.  
  504. -- A function to say a message as a request.
  505. function Schema:SayRequest(player, text)
  506. local isCitizen = (player:GetFaction() == FACTION_CITIZEN);
  507. local listeners = { request = {}, eavesdrop = {} };
  508.  
  509. for k, v in ipairs( _player.GetAll() ) do
  510. if (v:HasInitialized()) then
  511. if (v:GetFaction() == FACTION_CITIZEN and isCitizen and player != v) then
  512. if (v:GetShootPos():Distance( player:GetShootPos() ) <= Clockwork.config:Get("talk_radius"):Get()) then
  513. listeners.eavesdrop[v] = v;
  514. end;
  515. else
  516. local isCityAdmin = (v:GetFaction() == FACTION_ADMIN);
  517. local isCombine = self:PlayerIsCombine(v);
  518.  
  519. if (v:HasItemByID("request_device") or isCombine or isCityAdmin) then
  520. listeners.request[v] = v;
  521. end;
  522. end;
  523. end;
  524. end;
  525.  
  526.  
  527. self:AddCombineDisplayLine("Downloading request packet...");
  528.  
  529.  
  530. local info = Clockwork.chatBox:Add(listeners.request, player, "request", text);
  531.  
  532. if (info and IsValid(info.speaker)) then
  533. Clockwork.chatBox:Add(listeners.eavesdrop, info.speaker, "request_eavesdrop", info.text);
  534. end;
  535. end;
  536.  
  537. -- A function to get a player's location.
  538. function Schema:PlayerGetLocation(player)
  539. local areaNames = Clockwork.plugin:FindByID("Area Names");
  540. local closest;
  541.  
  542. if (areaNames) then
  543. for k, v in pairs(areaNames.areaNames) do
  544. if (Clockwork.entity:IsInBox(player, v.minimum, v.maximum)) then
  545. if (string.sub(string.lower(v.name), 1, 4) == "the ") then
  546. return string.sub(v.name, 5);
  547. else
  548. return v.name;
  549. end;
  550. else
  551. local distance = player:GetShootPos():Distance(v.minimum);
  552.  
  553. if (!closest or distance < closest[1]) then
  554. closest = {distance, v.name};
  555. end;
  556. end;
  557. end;
  558.  
  559. if (!completed) then
  560. if (closest) then
  561. if (string.sub(string.lower( closest[2] ), 1, 4) == "the ") then
  562. return string.sub(closest[2], 5);
  563. else
  564. return closest[2];
  565. end;
  566. end;
  567. end;
  568. end;
  569.  
  570. return "unknown location";
  571. end;
  572.  
  573. -- A function to say a message as a broadcast.
  574. function Schema:SayBroadcast(player, text)
  575. Clockwork.chatBox:Add(nil, player, "broadcast", text);
  576. end;
  577.  
  578. -- A function to say a message as a dispatch.
  579. function Schema:SayDispatch(player, text)
  580. Clockwork.chatBox:Add(nil, player, "dispatch", text);
  581. end;
  582.  
  583. -- A function to check if a player is Combine.
  584. function Schema:PlayerIsCombine(player, bHuman)
  585. if (IsValid(player) and player:GetCharacter()) then
  586. local faction = player:GetFaction();
  587.  
  588. if (self:IsCombineFaction(faction)) then
  589. if (bHuman) then
  590. if (faction == FACTION_MPF) then
  591. return true;
  592. end;
  593. elseif (bHuman == false) then
  594. if (faction == FACTION_MPF) then
  595. return false;
  596. else
  597. return true;
  598. end;
  599. else
  600. return true;
  601. end;
  602. end;
  603. end;
  604. end;
  605.  
  606. -- A function to apply a Combine lock.
  607. function Schema:ApplyCombineLock(entity, position, angles)
  608. local combineLock = ents.Create("cw_combinelock");
  609.  
  610. combineLock:SetParent(entity);
  611. combineLock:SetDoor(entity);
  612.  
  613. if (position) then
  614. if (type(position) == "table") then
  615. combineLock:SetLocalPos( Vector(-1.0313, 43.7188, -1.2258) );
  616. combineLock:SetPos( combineLock:GetPos() + (position.HitNormal * 4) );
  617. else
  618. combineLock:SetPos(position);
  619. end;
  620. end;
  621.  
  622. if (angles) then
  623. combineLock:SetAngles(angles);
  624. end;
  625.  
  626. combineLock:Spawn();
  627.  
  628. if (IsValid(combineLock)) then
  629. return combineLock;
  630. end;
  631. end;
  632.  
  633. -- A function to make a player wear clothes.
  634. function Schema:PlayerWearClothes(player, itemTable, noMessage)
  635. local clothes = player:GetCharacterData("clothes");
  636.  
  637. if (itemTable) then
  638. local model = Clockwork.class:GetAppropriateModel(player:Team(), player, true);
  639.  
  640. if (!model) then
  641. itemTable:OnChangeClothes(player, true);
  642.  
  643. player:SetCharacterData("clothes", itemTable.index);
  644. player:SetSharedVar("clothes", itemTable.index);
  645. end;
  646. else
  647. itemTable = Clockwork.item:FindByID(clothes);
  648.  
  649. if (itemTable) then
  650. itemTable:OnChangeClothes(player, false);
  651.  
  652. player:SetCharacterData("clothes", nil);
  653. player:SetSharedVar("clothes", 0);
  654. end;
  655. end;
  656. end;
  657.  
  658. -- A function to get a player's heal amount.
  659. function Schema:GetHealAmount(player, scale)
  660. local medical = Clockwork.attributes:Fraction(player, ATB_MEDICAL, 35);
  661. local healAmount = (15 + medical) * (scale or 1);
  662.  
  663. return healAmount;
  664. end;
  665.  
  666. -- A function to get a player's dexterity time.
  667. function Schema:GetDexterityTime(player)
  668. return 7 - Clockwork.attributes:Fraction(player, ATB_DEXTERITY, 5, 5);
  669. end;
  670.  
  671. -- A function to bust down a door.
  672. function Schema:BustDownDoor(player, door, force)
  673. door.bustedDown = true;
  674.  
  675. door:SetNotSolid(true);
  676. door:DrawShadow(false);
  677. door:SetNoDraw(true);
  678. door:EmitSound("physics/wood/wood_box_impact_hard3.wav");
  679. door:Fire("Unlock", "", 0);
  680.  
  681. if (IsValid(door.combineLock)) then
  682. door.combineLock:Explode();
  683. door.combineLock:Remove();
  684. end;
  685.  
  686. if (IsValid(door.breach)) then
  687. door.breach:BreachEntity();
  688. end;
  689.  
  690. local fakeDoor = ents.Create("prop_physics");
  691.  
  692. fakeDoor:SetCollisionGroup(COLLISION_GROUP_WORLD);
  693. fakeDoor:SetAngles( door:GetAngles() );
  694. fakeDoor:SetModel( door:GetModel() );
  695. fakeDoor:SetSkin( door:GetSkin() );
  696. fakeDoor:SetPos( door:GetPos() );
  697. fakeDoor:Spawn();
  698.  
  699. local physicsObject = fakeDoor:GetPhysicsObject();
  700.  
  701. if (IsValid(physicsObject)) then
  702. if (!force) then
  703. if (IsValid(player)) then
  704. physicsObject:ApplyForceCenter( (door:GetPos() - player:GetPos() ):GetNormal() * 10000 );
  705. end;
  706. else
  707. physicsObject:ApplyForceCenter(force);
  708. end;
  709. end;
  710.  
  711. Clockwork.entity:Decay(fakeDoor, 300);
  712.  
  713. Clockwork.kernel:CreateTimer("reset_door_"..door:EntIndex(), 300, 1, function()
  714. if (IsValid(door)) then
  715. door.bustedDown = nil;
  716. door:SetNotSolid(false);
  717. door:DrawShadow(true);
  718. door:SetNoDraw(false);
  719. end;
  720. end);
  721. end;
  722.  
  723. -- A function to permanently kill a player.
  724. function Schema:PermaKillPlayer(player, ragdoll)
  725. if (player:Alive()) then
  726. player:Kill(); ragdoll = player:GetRagdollEntity();
  727. end;
  728.  
  729. local inventory = player:GetInventory();
  730. local cash = player:GetCash();
  731. local info = {};
  732.  
  733. if (!player:GetCharacterData("permakilled")) then
  734. info.inventory = inventory;
  735. info.cash = cash;
  736.  
  737. if (!IsValid(ragdoll)) then
  738. info.entity = ents.Create("cw_belongings");
  739. end;
  740.  
  741. Clockwork.plugin:Call("PlayerAdjustPermaKillInfo", player, info);
  742.  
  743. for k, v in pairs(info.inventory) do
  744. local itemTable = Clockwork.item:FindByID(k);
  745.  
  746. if (itemTable and itemTable.allowStorage == false) then
  747. info.inventory[k] = nil;
  748. end;
  749. end;
  750.  
  751. player:SetCharacterData("permakilled", true);
  752. player:SetCharacterData("inventory", {}, true);
  753. player:SetCharacterData("cash", 0, true);
  754.  
  755. if (!IsValid(ragdoll)) then
  756. if (table.Count(info.inventory) > 0 or info.cash > 0) then
  757. info.entity:SetData(info.inventory, info.cash);
  758. info.entity:SetPos( player:GetPos() + Vector(0, 0, 48) );
  759. info.entity:Spawn();
  760. else
  761. info.entity:Remove();
  762. end;
  763. else
  764. ragdoll.areBelongings = true;
  765. ragdoll.inventory = info.inventory;
  766. ragdoll.cash = info.cash;
  767. end;
  768.  
  769. Clockwork.player:SaveCharacter(player);
  770. end;
  771. end;
  772.  
  773. -- A function to tie or untie a player.
  774. function Schema:TiePlayer(player, isTied, reset, combine)
  775. if (isTied) then
  776. if (combine) then
  777. player:SetSharedVar("tied", 2);
  778. else
  779. player:SetSharedVar("tied", 1);
  780. end;
  781. else
  782. player:SetSharedVar("tied", 0);
  783. end;
  784.  
  785. if (isTied) then
  786. Clockwork.player:DropWeapons(player);
  787. Clockwork.kernel:PrintLog(LOGTYPE_GENERIC, player:Name().." has been tied.");
  788.  
  789. player:Flashlight(false);
  790. player:StripWeapons();
  791. elseif (!reset) then
  792. if (player:Alive() and !player:IsRagdolled()) then
  793. Clockwork.player:LightSpawn(player, true, true);
  794. end;
  795.  
  796. Clockwork.kernel:PrintLog(LOGTYPE_GENERIC, player:Name().." has been untied.");
  797. end;
  798. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement