Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.91 KB | None | 0 0
  1.  
  2.  
  3. local function sendOnline ( )
  4. if (GAMEMODE.ServerIdentifier == 0) then return end
  5.  
  6. tmysql.query("UPDATE `perp_system` SET `value`='" .. os.time() .. "' WHERE `key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
  7. end
  8. timer.Create("sendOnline", 10, 0, sendOnline);
  9.  
  10. local function forceOnline ( Player )
  11. if (Player && IsValid(Player) && !Player:IsSuperAdmin()) then return end
  12. if (GAMEMODE.ServerIdentifier == 0) then return end
  13.  
  14. tmysql.query("UPDATE `perp_system` SET `value`='" .. os.time() + 600 .. "' WHERE `key`='online_" .. GAMEMODE.ServerIdentifier .. "' LIMIT 1");
  15. end
  16. concommand.Add("force_online", forceOnline);
  17.  
  18. function GM:KeyPress ( Player, Key )
  19. if Key == IN_USE then
  20. local TTable = {}
  21. TTable.start = Player:GetShootPos();
  22. TTable.endpos = TTable.start + Player:GetAimVector() * 100;
  23. TTable.filter = Player;
  24. TTable.mask = MASK_OPAQUE_AND_NPCS;
  25.  
  26. local Tr = util.TraceLine(TTable);
  27.  
  28. if Tr.Entity and Tr.Entity:IsValid() and Tr.Entity:GetClass() == "npc_vendor" then
  29. Tr.Entity:UseFake(Player);
  30. end
  31. end
  32. end
  33.  
  34. function GM:Initialize ( )
  35. Msg("Loading tmysql module... ");
  36. require("tmysql");
  37.  
  38.  
  39. if (tmysql) then
  40. Msg("done!\n");
  41. else
  42. Msg("failed!\n");
  43. end
  44.  
  45. self.ServerIdentifier = 2;
  46. self.ServerDateIdentifier = 1;
  47. self.numPlayers = 128;
  48. self.ReservedSlots = 64;
  49. self.Serious = true;
  50.  
  51. SQL_INFO_1 = "localhost"; -- HOST
  52. SQL_INFO_2 = "root"; -- Username
  53. SQL_INFO_3 = ""; -- Password
  54. SQL_INFO_4 = "perp"; -- DB Name
  55.  
  56. tmysql.initialize(SQL_INFO_1, SQL_INFO_2, SQL_INFO_3, SQL_INFO_4, 3306, 8, 8);
  57.  
  58. RunConsoleCommand("sv_visiblemaxplayers", self.numPlayers-self.ReservedSlots);
  59.  
  60. timer.Simple(1, function ( )
  61. RunConsoleCommand("sv_allowdownload", "1");
  62. RunConsoleCommand("sv_allowupload", "1");
  63. RunConsoleCommand("sv_usermessage_maxsize", "5000");
  64. RunConsoleCommand('lua_log_sv', '1');
  65. RunConsoleCommand('net_maxfilesize', '64');
  66. end);
  67.  
  68. SetGlobalInt("tax_sales", 5);
  69. SetGlobalInt("tax_income", 5);
  70.  
  71. sendOnline();
  72.  
  73. RunConsoleCommand("qcache_gamedesc", "");
  74.  
  75. RunConsoleCommand("sv_max_queries_window", "5");
  76. self.IsSerious = (self.ServerIdentifier == 2);
  77.  
  78. self.HouseAlarms = {};
  79.  
  80. --tmysql.query("SELECT `key`, `value` FROM `perp_system` WHERE `key`='date_year_" .. self.ServerDateIdentifier .. "' OR `key`='date_month_" .. self.ServerDateIdentifier .. "' OR `key`='date_day_" .. self.ServerDateIdentifier .. "'", function ( Whatever )
  81. --for k, v in pairs(Whatever) do
  82. --if (v[1] == "date_year_" .. self.ServerDateIdentifier) then
  83. --GAMEMODE.CurrentYear = tonumber(v[2]);
  84. --elseif (v[1] == "date_month_" .. self.ServerDateIdentifier) then
  85. --GAMEMODE.CurrentMonth = tonumber(v[2]);
  86. --elseif (v[1] == "date_day_" .. self.ServerDateIdentifier) then
  87. --GAMEMODE.CurrentDay = tonumber(v[2]);
  88. --end
  89. --end
  90.  
  91. --GAMEMODE.LastSaveYear = GAMEMODE.CurrentYear;
  92. --GAMEMODE.LastSaveMonth = GAMEMODE.CurrentMonth;
  93. --GAMEMODE.LastSaveDay = GAMEMODE.CurrentDay;
  94.  
  95. --GAMEMODE.CurrentTemperature = (AVERAGE_TEMPERATURES[GAMEMODE.CurrentMonth][1] + AVERAGE_TEMPERATURES[GAMEMODE.CurrentMonth][2]) * .5;
  96. --SetGlobalInt("temp", GAMEMODE.CurrentTemperature);
  97.  
  98. --Msg("Current in-game date: " .. GAMEMODE.CurrentMonth .. "/" .. GAMEMODE.CurrentDay .. "/" .. GAMEMODE.CurrentYear .. "\n");
  99.  
  100. --GAMEMODE.CanSaveDate = true;
  101. --Msg("Date saving authorized.\n");
  102. --end);
  103. SetGlobalInt("tv_status", 0);
  104. end
  105.  
  106. function GM:InitPostEntity ( )
  107. self.GatherInvalidNames();
  108.  
  109. --timer.Simple(1, GAMEMODE.PushNumPlayers);
  110. end
  111.  
  112. function GM:PlayerInitialSpawn ( Player )
  113. Player.PlayerItems = {}
  114. Player.StorageItems = {}
  115. Player:SetTeam(TEAM_CITIZEN)
  116. Player:ConCommand("playx_enabled 0")
  117. Player:ConCommand("cl_playerspraydisable 1")
  118. self.PushNumPlayers();
  119. Player:UnSpectate()
  120. Player:Freeze(false)
  121. Player:SetMoveType(2)
  122. timer.Simple(5, GAMEMODE.SendJobInformation, Player)
  123. end
  124.  
  125. function GM:PlayerConnect ( name, ip )
  126. --self.PushNumPlayers();
  127. for k, ply in pairs( player.GetAll() ) do
  128. if ply:IsAdmin() then
  129. ply:ChatPrint( name .. " Connected | " .. ip )
  130. end
  131. end
  132. end
  133.  
  134. function GM:PlayerDisconnected ( Player )
  135. --timer.Simple(1, GAMEMODE.PushNumPlayers);
  136. if !(timer.Exists(tostring(Player:SteamID() .. "death"))) then
  137. timer.Destroy(tostring(Player:SteamID() .. "death"))
  138. end
  139.  
  140. for k, ply in pairs( player.GetAll() ) do
  141. if ply:IsAdmin() then
  142. ply:ChatPrint( Player:Nick() .. " Disconnected | " .. Player:SteamID() .. " | " .. Player:IPAddress() )
  143. end
  144. end
  145.  
  146. end
  147.  
  148. local spawnPoints = {}
  149. spawnPoints[TEAM_POLICE] = {
  150. {pos= Vector(3635, -4190, -2373), ang = Angle(0.000, 270.314, 0.000)},
  151. }
  152. spawnPoints[TEAM_SWAT] = spawnPoints[TEAM_POLICE]
  153. spawnPoints[TEAM_MEDIC] = {
  154. {pos = Vector(8345, -561, -1743), ang = Angle(0.000, 270.314, 0.000)},
  155. }
  156.  
  157. spawnPoints[TEAM_FIREMAN] = {
  158. {pos = Vector(7398, -2502, -1743), ang = Angle(0.000, 180.000, 0.000)},
  159. }
  160. spawnPoints[TEAM_DISPATCHER] = spawnPoints[TEAM_POLICE]
  161.  
  162. spawnPoints[TEAM_MAYOR] = {
  163. {pos = Vector(3616, -3949, 1850), ang = Angle(0.000, 270.000, 0.000)},
  164. }
  165.  
  166. spawnPoints[TEAM_SECRET_SERVICE] = {
  167. {pos = Vector(4449, -4499, 1850), ang = Angle(0.000, 180.000, 0.000)},
  168. {pos = Vector(4456, -4776, 1850), ang = Angle(0.000, 180.000, 0.000)},
  169. }
  170.  
  171.  
  172. spawnPoints[TEAM_BUSDRIVER] = {
  173. {pos = Vector(5871, -1824, -1869), ang = Angle(0.000, 180.000, 0.000)},
  174. }
  175.  
  176. spawnPoints[TEAM_ROADCREW] = {
  177. {pos = Vector(-10047, 14567, -1482), ang = Angle(0.000, 90.000, 0.000)},
  178. }
  179.  
  180.  
  181. spawnPoints[TEAM_CITIZEN] = {
  182. --[[{pos = Vector(663, -6260, -1869), ang = Angle(0.000, 28.635, 0.000)}, --chaoscity v33x
  183. {pos = Vector(665, -6149, -1869), ang = Angle(0.000, 0.318, 0.000)}, --chaoscity v33x
  184. {pos = Vector(665, -6068, -1869), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  185. {pos = Vector(666, -5942, -1869), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  186. {pos = Vector(-25, -6953, -1868), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  187. {pos = Vector(-23, -6773, -1868), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  188. {pos = Vector(-24, -6452, -1868), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  189. {pos = Vector(676, -5565, -1869), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  190. {oos = Vector(674, -5388, -1869), ang = Angle(0.000, -0.276, 0.000)}, --chaoscity v33x
  191. {pos = Vector(671, -3659, -1868), ang = Angle(0.000, -0.276, 0.000)},]] --chaoscity v33x
  192. {pos = Vector(-5109, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  193. {pos = Vector(-5015, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  194. {pos = Vector(-4923, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  195. {pos = Vector(-4818, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  196. {pos = Vector(-4719, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  197. {pos = Vector(-4616, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  198. {pos = Vector(-4504, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)}, -- Up to date
  199. -- {pos = Vector(-3970, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)},
  200. -- {pos = Vector(-4076, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)},
  201. -- {pos = Vector(-4197, 10056, 480.031250), ang = Angle(0.000, 90.000, -0.000)},
  202.  
  203. }
  204.  
  205. function GM:PlayerSelectSpawn ( user )
  206. local SafeSpawnArea = spawnPoints[user:Team()][math.random(1, table.Count(spawnPoints[user:Team()]))];
  207.  
  208. for _, each in pairs(spawnPoints[user:Team()]) do
  209. local nearbyEnts = ents.FindInSphere(each.pos, 75)
  210.  
  211. local nearbyPlayer = false
  212. for _, ent in pairs(nearbyEnts) do
  213. if (ent && IsValid(ent) && ent:IsPlayer() && ent != user) then
  214. nearbyPlayer = true
  215. end
  216. end
  217.  
  218. if (!nearbyPlayer) then
  219. SafeSpawnArea = each
  220. break
  221. end
  222. end
  223.  
  224. local MobileSpawn = ents.FindByClass('info_mobile_spawn')[1];
  225.  
  226. if !IsValid(MobileSpawn) then
  227. MobileSpawn = ents.Create('info_mobile_spawn');
  228. MobileSpawn:SetPos(Vector(0, 0, 0));
  229. MobileSpawn:SetColor(Color(0,0,0, 0));
  230. MobileSpawn:Spawn();
  231. end
  232.  
  233. MobileSpawn:SetPos(SafeSpawnArea.pos);
  234. MobileSpawn:SetAngles(SafeSpawnArea.ang);
  235. return MobileSpawn;
  236. end
  237.  
  238. function GM:PlayerSpawn ( Player )
  239. if !(timer.Exists(tostring(Player:SteamID() .. "death"))) then
  240. timer.Destroy(tostring(Player:SteamID() .. "death"))
  241. end
  242. if Player.JobModel then Player:SetModel(Player.JobModel);
  243. elseif Player.PlayerModel then Player:SetModel(Player.PlayerModel);
  244. else Player:SetModel(Player:GetModelPath(SEX_MALE, 1, 1)); end
  245.  
  246. if GAMEMODE.PlayerSpawn_Event then GAMEMODE.PlayerSpawn_Event(Player) end
  247. if GAMEMODE.PlayerSetModel_Event and GAMEMODE.PlayerSetModel_Event(Player) then return false; end
  248.  
  249. Player.currentlyRestrained = nil
  250. self.freshLayout = true;
  251. self:PlayerLoadout(Player);
  252.  
  253. if (!Player.DontFixCripple) then
  254. Player.Crippled = nil;
  255.  
  256. umsg.Start("perp_reset_stam", Player); umsg.End();
  257. Player.Stamina = 100;
  258.  
  259. if (Player:Team() == TEAM_CITIZEN && Player.DeathPos && !Player:GetTable().Pos) then
  260. for i = 1, 2 do
  261. if (Player.PlayerItems[i]) then
  262. local itemDrop = ents.Create("ent_item");
  263. itemDrop:SetModel(Player.PlayerItems[i].Table.WorldModel);
  264. itemDrop:SetContents(Player.PlayerItems[i].ID, Player);
  265. itemDrop:SetPos(Player.DeathPos + Vector(0, 0, 10 + 10 * i));
  266. itemDrop:Spawn();
  267.  
  268. Player.PlayerItems[i] = nil;
  269. end
  270. end
  271.  
  272. umsg.Start('perp_strip_main', Player); umsg.End();
  273. elseif (Player:Team() == TEAM_MAYOR && !Player:GetTable().Pos) then
  274. for k, v in pairs(player.GetAll()) do
  275. if (v != Player) then
  276. v:Notify("The mayor has been assassinated.");
  277. end
  278. end
  279.  
  280. Player:Notify("You have been assassinated.");
  281.  
  282. Player:SetModel(Player.PlayerModel);
  283. Player.JobModel = nil;
  284. Player:EquipMains();
  285. Player:SetTeam(TEAM_CITIZEN);
  286. end
  287. else
  288. Player.DontFixCripple = nil;
  289. end
  290.  
  291. Player:FindRunSpeed();
  292.  
  293. if (Player:Team() == TEAM_CITIZEN) then
  294. Player:EquipMains();
  295. end
  296.  
  297. if Player:GetTable().Pos then Player:SetPos(Player:GetTable().Pos); Player:GetTable().Pos = nil end
  298. radar.RemoveAlert(Player:SteamID() .. "Accident")
  299. Player:UnSpectate()
  300. Player:Freeze(false)
  301. Player:SetMoveType(2)
  302. --Player:ScreenFade( 2, color_black, 1, 2 )
  303. end
  304.  
  305. function GM:PlayerDeath ( Player, Inflictor, Killer )
  306. -- here will
  307. --Player:ScreenFade( 1, color_black, 1, 100 )
  308. Player:Freeze(true)
  309. local killerText = tostring(Killer);
  310.  
  311. for k, v in pairs(player.GetAll()) do
  312. if (v:IsAdmin()) then
  313. if Killer:GetClass() == "prop_vehicle_jeep" then
  314. local VehDriver = Killer:GetDriver();
  315. if VehDriver:Nick() != "Console" then
  316. v:PrintMessage(HUD_PRINTTALK, VehDriver:Nick() .. " ran over " .. Player:Nick());
  317. else
  318. v:PrintMessage(HUD_PRINTTALK, Player:Nick() .. " was killed by a driverless car");
  319. end
  320. elseif Killer:GetClass() == "worldspawn" then
  321. v:PrintMessage(HUD_PRINTTALK, Player:Nick() .. " Hit the map too hard");
  322. elseif Killer:GetClass() == "ent_item" || Killer:GetClass() == "ent_prop_item" then
  323. v:PrintMessage(HUD_PRINTTALK, Player:Nick() .. " was prop killed");
  324. elseif Killer == Player then
  325. v:PrintMessage(HUD_PRINTTALK, Player:Nick() .. " killed themself");
  326. elseif (Killer && IsValid(Killer) && Killer:IsPlayer()) then
  327. killerText = Killer:Nick();
  328. v:PrintMessage(HUD_PRINTTALK, killerText .. " killed " .. Player:Nick());
  329. else
  330. v:PrintMessage(HUD_PRINTTALK, "Unknown object killed " .. Player:Nick());
  331. end
  332. end;
  333. end
  334.  
  335. Player.RequiredDefib = math.random(1, 3);
  336. Player.DeathPos = Player:GetPos();
  337. --Player.RespawnTime = CurTime() + 100;
  338.  
  339. if (Inflictor && Inflictor:IsVehicle()) then
  340. Player.waittospawn = 10
  341. Player:Notify('You have been rammed by a vehicle. Paramedics will probably not arrive in time to save you.');
  342. elseif (Inflictor && Inflictor:GetClass() == 'ent_fire') then
  343. Player.waittospawn = 10
  344. Player:Notify('You have been knocked unconcious in a fire. Paramedics will probably not arrive in time to save you.');
  345. elseif Player:WaterLevel() >= 3 then
  346. Player.waittospawn = 10
  347. Player:Notify('You have been knocked unconcious underwater. Paramedics will probably not arrive in time to save you.');
  348. else
  349. if (GAMEMODE.RespawnOverride) then
  350. Player.waittospawn = 5
  351. else
  352. Player.waittospawn = 100
  353. end;
  354.  
  355. // Life alert
  356. if (Player:HasItem("item_lifealert")) then
  357. Player:BroadcastLifeAlert();
  358. radar.AddAlertTeam(Player:SteamID() .. "Accident", {TEAM_FIREMAN, TEAM_MAYOR, TEAM_PARAMEDIC, TEAM_SWAT}, Player:GetPos(), Player:GetRPName(), Color(255, 0, 0, 200))
  359. end
  360. end
  361.  
  362. if !(timer.Exists(tostring(Player:SteamID() .. "death"))) then
  363. timer.Create( tostring(Player:SteamID().. "death"), tonumber(Player.waittospawn), 0, function()
  364. Player:Spawn()
  365. timer.Destroy(tostring(Player:SteamID() .. "death"))
  366. end )
  367. end
  368.  
  369. end
  370.  
  371. --function GM:PlayerDeathThink ( Player )
  372. --print(Player:Nick() .. " Thinking")
  373. --Player:Notify(tostring(Player.RespawnTime))
  374. --Player.RespawnTime = Player.RespawnTime or 0;
  375. --if Player.RespawnTime < CurTime() then
  376. --Player:Spawn();
  377. --Player:Notify('You have passed away... The paramedics were too slow.');
  378. --end
  379. --end
  380.  
  381.  
  382. function GM:PlayerLoadout ( Player )
  383. if (!self.freshLayout) then
  384. Player:StripWeapons();
  385. else self.freshLayout = nil; end
  386.  
  387. Player:Give("roleplay_keys");
  388. Player:Give("roleplay_fists");
  389. --Player:Give("weapon_physcannon");
  390.  
  391. if (Player:GetLevel() <= 11) then
  392. Player:Give("weapon_physgun");
  393. end
  394.  
  395. if (Player:GetLevel() <= 4) then
  396. Player:Give("god_stick");
  397. end
  398.  
  399. if (GAMEMODE.JobEquips[Player:Team()]) then
  400. GAMEMODE.JobEquips[Player:Team()](Player);
  401. end
  402. end
  403.  
  404. function RemoveWeps ( Player )
  405. Player:StripWeapons();
  406. end
  407. concommand.Add("perp_toggle_weapons", RemoveWeps);
  408.  
  409. function GM:PlayerDisconnected ( Player )
  410. Player.RespawnTime = Player.RespawnTime or 0;
  411. Player:Save();
  412.  
  413. // Remove their save timer
  414. local ourID = Player:SteamID();
  415. timer.Remove(ourID);
  416.  
  417. // Remove their properties
  418. for k, v in pairs(PROPERTY_DATABASE) do
  419. local propOwner = GetGlobalEntity("p_" .. k);
  420.  
  421. if (propOwner && IsValid(propOwner) && propOwner == Player) then
  422. SetGlobalEntity("p_" .. k, Entity());
  423. end
  424. end
  425.  
  426. // Delete all of their props
  427. for k, v in pairs(ents.GetAll()) do
  428. if (v.Owner && v.Owner == Player) then
  429. v:Remove();
  430. end
  431.  
  432. if (v.pickupPlayer && v.pickupPlayer == Player) then
  433. v:Remove();
  434. end
  435. end
  436.  
  437. local spawnPos = tostring(Player:GetPos());
  438. local spawnAng = tostring(Player:GetAngles());
  439.  
  440. if Player.RespawnTime > CurTime() then
  441. local deathTime = Player.RespawnTime - CurTime();
  442. Player:SetSpawnPosition(spawnPos, spawnAng, deathTime, Player:SteamID())
  443. else
  444. Player:SetSpawnPosition(spawnPos, spawnAng, 0, Player:SteamID())
  445. end
  446.  
  447. // Remove their vehicle (and rotators)
  448. Player:RemoveCar();
  449.  
  450. // Make sure they're not on the phone with anyone
  451. if (Player.Calling) then DropCall(Player); end
  452.  
  453. --timer.Simple(1, self.PushNumPlayers);
  454. end
  455.  
  456. function GM:ShutDown ( )
  457. for k, v in pairs(player.GetAll()) do
  458. v:Save();
  459. end
  460. end
  461.  
  462. function GM:PlayerNoClip ( Player )
  463.  
  464. if (Player:IsMod()) then
  465. return true;
  466. elseif !game.IsDedicated() then
  467. return true
  468. else
  469. return false;
  470. end
  471.  
  472. end
  473.  
  474. function GM:CanPlayerSuicide ( ) return false; end
  475.  
  476. function GM:ShowHelp ( Player )
  477. umsg.Start("perp_help", Player);
  478. umsg.End();
  479. end
  480.  
  481. function GM:ShowSpare1 ( Player )
  482. umsg.Start("perp_org", Player);
  483. umsg.End();
  484. end
  485.  
  486. function GM:ShowSpare2 ( Player )
  487. local eyeTrace = Player:GetEyeTrace();
  488.  
  489. if (eyeTrace.Entity && eyeTrace.Entity:IsPlayer() && eyeTrace.Entity:GetPos():Distance(Player:GetPos()) < 300) then
  490. Player:TradeWith(eyeTrace.Entity);
  491. return
  492. end
  493.  
  494. umsg.Start("perp_buddies", Player);
  495. umsg.End();
  496. end
  497.  
  498. function GM:GravGunPunt ( Player, Target ) return false; end
  499. function GM:GravGunPickupAllowed ( Player, Target ) return Target && IsValid(Target) && (Player:CanManipulateEnt(Target) || Target:GetClass() == "ent_pot" || Target:GetClass() == "ent_coca" || Target:GetClass() == "ent_towtruck_hook"); end
  500. function GM:PhysgunPickup ( Player, Target )
  501. if Target:IsPlayer() then
  502. Target:SetMoveType(MOVETYPE_NOCLIP)
  503. Target:Freeze(true)
  504. end
  505. return Player:CanManipulateEnt(Target);
  506. end
  507. function GM:ShowTeam ( Player )
  508. if (Player.currentlyRestrained) then
  509. Player:Notify("You cannot use your inventory while cuffed.");
  510. return false;
  511. end;
  512.  
  513. umsg.Start("perp_inventory", Player);
  514. umsg.End();
  515. end
  516.  
  517. function PhysgunDrop(PLAYER, ENTITY)
  518. if ENTITY:IsPlayer() then
  519. ENTITY:SetMoveType(MOVETYPE_WALK)
  520. ENTITY:Freeze(false)
  521. end
  522. end
  523.  
  524. function GM:OnPhysgunFreeze( weapon, phys, ent, ply )
  525. if (
  526. ent:GetClass() != 'ent_prop_item' &&
  527. ent:GetClass() != "prop_clock" &&
  528. ent:GetClass() != "prop_lamp" &&
  529. ent:GetClass() != "prop_lamp_spot" &&
  530. ent:GetClass() != "prop_thermo" &&
  531. ent:GetClass() != "prop_metal_detector" &&
  532. ent:GetClass() != "prop_vehicle_prisoner_pod" &&
  533. ent:GetClass() != "item_doorbuster"
  534. ) then return false; end
  535. if !phys:IsMoveable() then return false; end
  536. phys:EnableMotion(false);
  537. return true;
  538. end
  539.  
  540. function PLAYER:CanManipulateEnt ( Target )
  541. if !self or !self:IsValid() or !self:IsPlayer() then return false; end
  542. if !Target or !Target:IsValid() then return false; end
  543. if self:IsOwner() then return true; end
  544.  
  545. if self:IsAdmin() and Target:GetClass() == 'prop_vehicle_prisoner_pod' then return true; end
  546. if self:IsAdmin() and Target:GetClass() == 'ent_prop_item' then return true; end
  547. if self:IsAdmin() and Target:GetClass() == 'prop_clock' then return true; end
  548. if self:IsAdmin() and Target:GetClass() == 'prop_thermo' then return true; end
  549. if self:IsAdmin() and Target:GetClass() == 'prop_lamp' then return true; end
  550. if self:IsAdmin() and Target:GetClass() == 'prop_case_beer' then return true; end
  551. if self:IsAdmin() and Target:GetClass() == 'prop_metal_detector' then return true; end
  552. if self:IsOwner() and Target:GetClass() == 'prop_vehicle_jeep' then return true; end
  553. if self:IsOwner() and Target:GetClass() == 'ent_pot' then return true; end
  554. if self:IsOwner() and Target:GetClass() == 'ent_coca' then return true; end
  555. if self:IsOwner() and Target:GetClass() == 'ent_pot_leaf' then return true; end
  556. if self:IsOwner() and Target:GetClass() == 'item_doorbuster' then return true; end
  557.  
  558.  
  559. if (Target:GetClass() == 'ent_prop_item' || Target:GetClass() == 'prop_clock' || Target:GetClass() == "prop_thermo" || Target:GetClass() == "prop_thermo" || Target:GetClass() == "prop_lamp" || Target:GetClass() == "prop_lamp_spot" || Target:GetClass() == "prop_case_beer" || Target:GetClass() == "prop_metal_detector") and Target:GetTable().Owner then
  560. if Target:GetTable().Owner == self or Target:GetTable().Owner:HasBuddy(self) then
  561. return true;
  562. end
  563. end
  564.  
  565. if (Target:GetClass() == 'prop_vehicle_prisoner_pod') and Target.pickupPlayer && (!Target:GetDriver() || !IsValid(Target:GetDriver())) then
  566. if Target.pickupPlayer == self or Target.pickupPlayer:HasBuddy(self) then
  567. return true;
  568. end
  569. end
  570.  
  571. if (Target:GetClass() == 'ent_fuelcan') then
  572. if Target.pickupPlayer == self or Target.pickupPlayer:HasBuddy(self) then
  573. return true;
  574. end
  575. end
  576.  
  577. if Target:GetClass() == 'ent_item' then
  578. if (Target:GetNetworkedString("title", "") == "") then
  579. return true;
  580. else
  581. return (self == Target:GetTable().Owner)
  582. end
  583. end
  584.  
  585. return false;
  586. end
  587.  
  588. function GM:GetFallDamage ( Player, flFallSpeed )
  589. return math.Clamp(flFallSpeed / 10, 10, 100);
  590. end
  591.  
  592. function GM:ScalePlayerDamage ( Player, HitGroup, DmgInfo )
  593. local attacker = DmgInfo:GetAttacker()
  594.  
  595. if (attacker && IsValid(attacker) && attacker:IsPlayer()) then
  596. if (!self:PlayerShouldTakeDamage(Player, attacker)) then return DmgInfo end
  597. end
  598.  
  599. if (Player:Alive()) then
  600. if (HitGroup == HITGROUP_HEAD) then
  601. DmgInfo:ScaleDamage(2);
  602. if (Player:GetSex() == SEX_MALE) then
  603. MoanFile = Sound("vo/npc/male01/ow0"..math.random(1, 2)..".wav");
  604. else
  605. MoanFile = Sound("vo/npc/female01/ow0"..math.random(1, 2)..".wav");
  606. end;
  607. elseif (HitGroup == HITGROUP_CHEST or HitGroup == HITGROUP_GENERIC) then
  608. if (Player:GetSex() == SEX_MALE) then
  609. MoanFile = Sound("vo/npc/male01/hitingut0"..math.random(1, 2)..".wav");
  610. else
  611. MoanFile = Sound("vo/npc/female01/hitingut0"..math.random(1, 2)..".wav");
  612. end;
  613. elseif (HitGroup == HITGROUP_LEFTARM or HitGroup == HITGROUP_RIGHTARM) then
  614. if (Player:GetSex() == SEX_MALE) then
  615. MoanFile = Sound("vo/npc/male01/myarm0"..math.random(1, 2)..".wav");
  616. else
  617. MoanFile = Sound("vo/npc/female01/myarm0"..math.random(1, 2)..".wav");
  618. end;
  619. elseif (HitGroup == HITGROUP_GEAR) then
  620. if (Player:GetSex() == SEX_MALE) then
  621. MoanFile = Sound("vo/npc/male01/startle0"..math.random(1, 2)..".wav");
  622. else
  623. MoanFile = Sound("vo/npc/female01/startle0"..math.random(1, 2)..".wav");
  624. end;
  625. elseif (HitGroup == HITGROUP_RIGHTLEG or HitGroup == HITGROUP_LEFTLEG) and !Player:GetTable().Crippled then
  626. if (GAMEMODE.CrippleOverride) then return; end;
  627. Player:GetTable().Crippled = true;
  628. Player:Notify("You've broken your legs!");
  629.  
  630. Player:FindRunSpeed();
  631.  
  632. if (Player:GetSex() == SEX_MALE) then
  633. MoanFile = Sound('vo/npc/male01/myleg0' .. math.random(1, 2) .. '.wav');
  634. else
  635. MoanFile = Sound('vo/npc/female01/myleg0' .. math.random(1, 2) .. '.wav');
  636. end;
  637. else
  638. if (Player:GetSex() == SEX_MALE) then
  639. MoanFile = Sound("vo/npc/male01/pain0"..math.random(1, 9)..".wav");
  640. else
  641. MoanFile = Sound("vo/npc/female01/pain0"..math.random(1, 9)..".wav");
  642. end;
  643. end;
  644.  
  645. sound.Play(MoanFile, Player:GetPos(), 100, 100);
  646. end;
  647.  
  648. if GAMEMODE.IsSerious then
  649. if Player:Team() == TEAM_SWAT then
  650. DmgInfo:ScaleDamage(1.25);
  651. else
  652. DmgInfo:ScaleDamage(1.5);
  653. end
  654. elseif Player:Team() == TEAM_SWAT then
  655. DmgInfo:ScaleDamage(0.75);
  656. end
  657.  
  658. Player:GiveExperience(SKILL_HARDINESS, DmgInfo:GetDamage() * .25);
  659.  
  660. return DmgInfo;
  661. end
  662.  
  663. function GM:PlayerShouldTakeDamage ( victim, attacker )
  664. if (!victim || !IsValid(victim) || !victim:IsPlayer()) then return true end
  665. if (!attacker || !IsValid(attacker) || !attacker:IsPlayer()) then return true end
  666. if (attacker == victim) then return true; end
  667. if (victim:Team() == TEAM_MAYOR && attacker:Team() != TEAM_CITIZEN) then return false end
  668. if (victim:Team() != TEAM_CITIZEN && attacker:Team() != TEAM_CITIZEN) then return false end
  669.  
  670. return true
  671. end
  672.  
  673. local function customUse ( Player, Entity )
  674. if (Player:InVehicle()) then return; end
  675. if (Player.LastLeaveVehicle && Player.LastLeaveVehicle > CurTime()) then return; end
  676.  
  677. if (Player:KeyDown(IN_WALK)) then
  678. if (Entity:GetClass() == "prop_vehicle_prisoner_pod" && Entity.pickupPlayer && Player == Entity.pickupPlayer && !Entity.used) then
  679. Player:GiveItem(Entity.pickupTable, 1, true);
  680. Entity.used = true;
  681. Entity:Remove();
  682. end
  683.  
  684. if ((Entity:GetClass() == "prop_lamp" || Entity:GetClass() == "prop_lamp_spot") && Entity.pickupPlayer && Player == Entity.pickupPlayer && !Entity.used) then
  685. Player:GiveItem(Entity.pickupTable, 1, true);
  686. Entity.used = true;
  687. Entity:Remove();
  688. end
  689. elseif (Entity:GetClass() == "prop_vehicle_prisoner_pod" && Entity.pickupPlayer && !IsValid(Entity:GetDriver())) then
  690. Player:EnterVehicle(Entity);
  691. elseif (Entity:GetClass() == "prop_vehicle_prisoner_pod") then
  692. if Entity.TSeat then
  693. Player:EnterVehicle(Entity);
  694. end
  695. elseif ((Entity:GetClass() == "prop_lamp" || Entity:GetClass() == "prop_lamp_spot") && Entity.flashlight && (!Entity.nextLightFlip || CurTime() > Entity.nextLightFlip)) then
  696. // toggle the lights.
  697. if Entity.broken then
  698. sound.Play("ambient/energy/spark" .. math.random(1, 6) .. ".wav", Entity:GetPos(), 50);
  699. else
  700. if (Entity.lightCurOn) then
  701. Entity.lightCurOn = false;
  702. Entity.flashlight:Fire("TurnOff", "", 0);
  703.  
  704. if (Entity:GetClass() == "prop_lamp_spot") then
  705. Entity:SetSkin(1);
  706. Entity:SetNetworkedBool("show_spot", false);
  707. end
  708. else
  709. Entity.lightCurOn = true;
  710. Entity.flashlight:Fire("TurnOn", "", 0);
  711.  
  712. if (Entity:GetClass() == "prop_lamp_spot") then
  713. Entity:SetSkin(0);
  714. Entity:SetNetworkedBool("show_spot", true);
  715. end
  716. end
  717. end
  718.  
  719. Entity.nextLightFlip = CurTime() + 1;
  720. end
  721. end
  722. hook.Add("PlayerUse", "customUse", customUse);
  723.  
  724. function GM:PlayerSpray ( Player )
  725. Player:Notify("Nope.");
  726. return false;
  727. end;
  728.  
  729. function PlaySound ( Ply, Cmd, Args )
  730. if(not SinglePlayer() and not Ply:IsOwner()) then return end
  731.  
  732. local sound = Args[1]
  733.  
  734. if ( sound ) then
  735. PlaySound(sound)
  736.  
  737. if ( string.match( sound, "^[a-zA-Z0-9/]+.wav$" ) ) then
  738. if ( !file.Exists( "../sound/" .. sound,"GAME" ) ) then
  739. print( "Sound \"" .. sound .. "\" not found!" )
  740. return
  741. end
  742. end
  743.  
  744. for k, v in pairs( player.GetAll() ) do
  745. v:ConCommand( "play " .. sound )
  746. end
  747.  
  748. else
  749. print("No sound was specified yet!" )
  750. end
  751. end
  752. concommand.Add("testsound1", PlaySound);
  753.  
  754. concommand.Add("perpx_giveitembeg", function(objPl, _, tblArgs)
  755. if(not SinglePlayer() and not objPl:IsSuperAdmin()) then return end
  756.  
  757. objPl:GiveItem(tonumber(tblArgs[1]), 1, true)
  758. end)
  759.  
  760. function GM:PlayerSwitchFlashlight( Player )
  761. if(Player:HasItem("item_flashlight")) then
  762. return true;
  763. else
  764. if(Player:FlashlightIsOn()) then
  765. return true;
  766. end
  767.  
  768. return false;
  769. end
  770. end
  771.  
  772. local function FixFlashlights()
  773. for k, v in pairs(player.GetAll()) do
  774. if(v.CanSave) then
  775. if(not v:HasItem("item_flashlight")) then
  776. if(v:FlashlightIsOn()) then
  777. v:Flashlight(false);
  778. end
  779. end
  780. end
  781. end
  782. end
  783. timer.Create("FixFlashlights", 1, 0, FixFlashlights);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement