· 10 years ago · May 27, 2016, 03:00 AM
1--[[
2Name: "init.lua".
3Product: "EvoRP (Roleplay)".
4--]]
5require("tmysql4")
6SetGlobalInt("evorp_cycle", 1)
7
8-- Include the shared gamemode file.
9include("sh_init.lua");
10
11-- Add the Lua files that we need to send to the client.
12AddCSLuaFile("cl_init.lua");
13AddCSLuaFile("sh_init.lua");
14AddCSLuaFile("core/sh_configuration.lua");
15AddCSLuaFile("core/sh_enumerations.lua");
16AddCSLuaFile("core/scoreboard/admin_buttons.lua");
17AddCSLuaFile("core/scoreboard/player_frame.lua");
18AddCSLuaFile("core/scoreboard/player_infocard.lua");
19AddCSLuaFile("core/scoreboard/player_row.lua");
20AddCSLuaFile("core/scoreboard/scoreboard.lua");
21AddCSLuaFile("core/scoreboard/vote_button.lua");
22
23-- Enable realistic fall damage for this gamemode.
24game.ConsoleCommand("mp_falldamage 1\n");
25game.ConsoleCommand("sbox_godmode 0\n");
26
27-- Check to see if local voice is enabled.
28if (evorp.configuration["Local Voice"]) then
29 game.ConsoleCommand("sv_voiceenable 1\n");
30 game.ConsoleCommand("sv_alltalk 1\n");
31 game.ConsoleCommand("sv_voicecodec vaudio_speex\n");
32 --game.ConsoleCommand("sv_voicequality 5\n");
33end;
34
35-- Some useful ConVars that can be changed in game.
36CreateConVar("evorp_ooc", 1);
37
38-- Store the old hook.Call function.
39hookCall = hook.Call;
40
41
42
43-- Overwrite the hook.Call function.
44function hook.Call(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)
45 if (a == "PlayerSay") then d = string.Replace(d, "$q", "\""); end;
46
47 -- Call the original hook.Call function.
48 return hookCall(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
49end;
50
51-- A table that will hold entities that were there when the map started.
52GM.entities = {};
53local DBConn = nil
54
55function GetCManagerID() -- Community Manager ID (This guy will have some power on the server!!)
56 return 'STEAM_0:0:13657884';
57end
58
59-- Called when the server initializes.
60function GM:Initialize()
61 local host = evorp.configuration["MySQL Host"];
62 local username = evorp.configuration["MySQL Username"];
63 local password = evorp.configuration["MySQL Password"];
64 local database = evorp.configuration["MySQL Database"];
65
66 -- Initialize a connection to the MySQL database.
67 local db, err = tmysql.initialize(host, username, password, database, 3306, 5, 5);
68 DBConn = db
69 local scode = GetConVar("sv_logdownloadlist"):GetString();
70 resource.AddFile("maps/"..string.lower(game.GetMap())..".bsp")
71 print("SERVER CODE: "..scode)
72
73 -- Call the base class function.
74 return self.BaseClass:Initialize();
75end;
76
77function GetDBConnection()
78 return DBConn or nil;
79end
80
81-- Called when a player switches their flashlight on or off.
82function GM:PlayerSwitchFlashlight(player, on)
83 if (player.evorp._Arrested or player._KnockedOut) then
84 return false;
85 else
86 return true;
87 end;
88end;
89
90function GM:ScalePlayerDamage(ply, hitgroup, dmginfo)
91 if (hitgroup == HITGROUP_HEAD) then
92 dmginfo:ScaleDamage(5)
93 elseif (hitgroup == HITGROUP_CHEST) then
94 dmginfo:ScaleDamage(1)
95 else
96 dmginfo:ScaleDamage(0.7)
97 end
98end
99
100-- Called when a player attempts to use an entity.
101function GM:PlayerUse(player, entity)
102 if (player._KnockedOut) then
103 return false;
104 elseif (player.evorp._Arrested and entity:GetClass() != "prop_vehicle_jeep" and (evorp.entity.isDoor(entity) or entity:GetClass() == "prop_dynamic") ) then
105 if ( !player._NextNotify or player._NextNotify < CurTime() ) then
106 evorp.player.notify(player, "You cannot do that in this state!", 1);
107
108 -- Set their next notify so that they don't get spammed with the message.
109 player._NextNotify = CurTime() + 2;
110 end;
111
112 -- Return false because they are arrested.
113 return false;
114 elseif (evorp.entity.isDoor(entity) or entity:GetClass() == "prop_dynamic") then
115 if (evorp.player.hasDoorAccess(player, entity)) then
116 evorp.entity.openDoor(entity, 0);
117 end;
118 end;
119
120 -- Call the base class function.
121 return self.BaseClass:PlayerUse(player, entity);
122end;
123
124-- Called when a player's warrant has expired.
125function GM:PlayerWarrantExpired(player, class) end;
126
127-- Called when a player demotes another player.
128function GM:PlayerDemote(player, target, team) end;
129
130-- Called when a player knocks out another player.
131function GM:PlayerKnockOut(player, target) end;
132
133-- Called when a player wakes up another player.
134function GM:PlayerWakeUp(player, target) end;
135
136-- Called when a player arrests another player.
137function GM:PlayerArrest(player, target) end;
138
139-- Called when a player unarrests another player.
140function GM:PlayerUnarrest(player, target) end;
141
142-- Called when a player warrants another player.
143function GM:PlayerWarrant(player, target, class) end;
144
145-- Called when a player unwarrants another player.
146function GM:PlayerUnwarrant(player, target) end;
147
148-- Called when a player attempts to own a door.
149function GM:PlayerCanOwnDoor(player, door) return true; end;
150
151-- Called when a player attempts to view a door.
152function GM:PlayerCanViewDoor(player, door) return true; end;
153
154-- Called when a player attempts to holster a weapon.
155function GM:PlayerCanHolster(player, weapon, silent) return true; end;
156
157-- Called when a player attempts to drop a weapon.
158function GM:PlayerCanDrop(player, weapon, silent, attacker) return true; end;
159
160-- Called when a player attempts to use an item.
161function GM:PlayerCanUseItem(player, item, silent) return true; end;
162
163-- Called when a player attempts to warrant a player.
164function GM:PlayerCanWarrant(player, target) return true; end;
165
166-- Called when a player attempts to use a door.
167function GM:PlayerCanUseDoor(player, door)
168 if ( IsValid(door._Owner) ) then
169 if (!door._Owner._Warranted and door._Owner != player) then
170 return false;
171 end;
172 end;
173
174 -- Return true because we can use this door.
175 return true;
176end;
177
178-- Called when a player enters a vehicle.
179function GM:PlayerEnteredVehicle(player, vehicle, role)
180 if (vehicle:GetClass() == "prop_vehicle_jeep") then
181 player.nextHyd = CurTime() + 5
182 if not (evorp.player.hasDoorAccess(player, vehicle) or vehicle:GetNetworkedBool("HotWired") or vehicle:GetNetworkedBool("NeedsFix")) then
183 vehicle:Fire("TurnOff", "" , 0)
184 evorp.player.notify(player, "You're not in the access list, you might need to hotwire the car.", 0);
185 else
186 vehicle:Fire("TurnOn", "" , 0)
187 end
188 player:SetNetworkedInt("nextHyd", player.nextHyd )
189 player:ConCommand("enteredvehicle")
190 end
191end;
192
193function GM:CheckPassword(SteamID, IP, sv_logdownloadlist, ClientPassword, PlayerName)
194 return true;
195end
196
197-- Called when a player attempts to join a team.
198function GM:PlayerCanJoinTeam(player, team)
199 team = evorp.team.get(team);
200
201 -- Check if this is a valid team.
202 if (team) then
203 if (player._NextChangeTeam[team.index]) then
204 if ( player._NextChangeTeam[team.index] > CurTime() ) then
205 local seconds = math.floor( player._NextChangeTeam[team.index] - CurTime() );
206
207 -- Notify them that they cannot change to this team yet.
208 evorp.player.notify(player, "You must wait "..seconds.." second(s) to become a "..team.name.."!", 1);
209
210 -- Return here because they can't become this team.
211 return false;
212 end;
213 end;
214 end;
215
216 -- Check if the player is warranted.
217 if (player._Warranted) then
218 evorp.player.notify(player, "You cannot do that while you are warranted!", 1);
219
220 -- Return here because they can't become this team.
221 return false;
222 end;
223
224 -- Check if the player is knocked out.
225 if (player._KnockedOut) then
226 evorp.player.notify(player, "You can't change team in your current state!", 1);
227
228 -- Return here because they can't become this team.
229 return false;
230 end;
231
232 -- Return true because they can join this team.
233 return true;
234end;
235
236-- Called when a player earns contraband money.
237function GM:PlayerCanEarnContraband(player) return true; end;
238
239-- Called when a player attempts to unwarrant a player.
240function GM:PlayerCanUnwarrant(player, target)
241 if ( player:IsAdmin() ) then
242 return true;
243 end
244end;
245
246
247-- Called when a player attempts to demote another player.
248function GM:PlayerCanDemote(player, target)
249 if ( !player:IsAdmin() ) then
250 evorp.player.notify(player, "You do not have access to demote this player!", 1);
251
252 -- Return false because they cannot demote this player.
253 return false;
254 else
255 return true;
256 end;
257end;
258
259-- Called when all of the map entities have been initialized.
260function GM:InitPostEntity()
261 --It's always sunny in EVORP :)
262 if string.lower(game.GetMap()) == "rp_evocity_v33x" then
263 engine.LightStyle(0, "t")
264 print("Made things a little brighter today.")
265 end
266
267 for k, v in pairs( ents.GetAll() ) do self.entities[v] = v; end;
268
269 -- Call the base class function.
270 return self.BaseClass:InitPostEntity();
271end;
272
273-- Called when a player attempts to say something in-character.
274function GM:PlayerCanSayIC(player, text)
275 if (!player:Alive() or player._KnockedOut and string.sub(text, 1, 6) != "/admin") then
276 evorp.player.notify(player, "You cannot talk in this state!", 1);
277
278 -- Return false because we can't say anything.
279 return false;
280 else
281 return true;
282 end;
283end;
284
285-- Called when a player attempts to say something in OOC.
286function GM:PlayerCanSayOOC(player, text)
287 if (player:IsAdmin()) then return true end
288 if not (player._NextOOC) then player._NextOOC = 0; end
289 if not (CurTime() > player._NextOOC) then
290 evorp.player.notify(player, "You may not use this command yet!", 1);
291 return false;
292 end
293 if (evorp.player.hasAccess(player, "u")) then
294 player._NextOOC = CurTime() + 10;
295 return true;
296 else
297 evorp.player.notify(player, "You are banned from using OOC chat.", 1);
298
299 -- Return false because we cannot talk out-of-character.
300 return false;
301 end;
302end;
303
304-- Called when a player attempts to say something in local OOC.
305function GM:PlayerCanSayLOOC(player, text) return true; end;
306
307-- Called when attempts to use a command.
308function GM:PlayerCanUseCommand(player, command, arguments)
309 if (command == "admin") then return true end
310 if (command == "wakeup" and player:Alive() and !player.evorp._Arrested and player._Sleeping) then
311 return true;
312 else
313 if (!player:Alive() or player._KnockedOut or player.evorp._Arrested) then
314 evorp.player.notify(player, "You cannot do that in this state!", 1);
315
316 -- Return false because we can't say anything.
317 return false;
318 else
319 return true;
320 end;
321 end;
322end;
323
324-- Called when a player says something.
325function GM:PlayerSay(player, text, public)
326
327 -- Fix Valve's errors.
328 text = string.Replace(text, " ' ", "'");
329 text = string.Replace(text, " : ", ":");
330
331 -- Check if we're speaking on OOC.
332 if (string.sub(text, 1, 2) == "//") then
333 if (string.Trim( string.sub(text, 3) ) != "") then
334 if ( hook.Call("PlayerCanSayOOC", GAMEMODE, player, text) ) then
335 EVPlayerLog(player, text, public);
336 evorp.chatBox.add( nil, player, "ooc", string.Trim( string.sub(text, 3) ) );
337 end;
338 end;
339 elseif (string.sub(text, 1, 3) == ".//") then
340 if (string.Trim( string.sub(text, 4) ) != "") then
341 if ( hook.Call("PlayerCanSayLOOC", GAMEMODE, player, text) ) then
342 EVPlayerLog(player, text, public);
343 evorp.chatBox.addInRadius(player, "looc", string.Trim( string.sub(text, 4) ), player:GetPos(), evorp.configuration["Talk Radius"]);
344 end;
345 end;
346 else
347 if ( string.sub(text, 1, 1) == evorp.configuration["Command Prefix"] ) then
348 evorp.command.ConCommand(player, string.sub(text, 2));
349 else
350 if ( hook.Call("PlayerCanSayIC", GAMEMODE, player, text) ) then
351 EVPlayerLog(player, text, public);
352 if (player.evorp._Arrested) then
353 evorp.chatBox.addInRadius(player, "arrested", text, player:GetPos(), evorp.configuration["Talk Radius"]);
354 else
355 evorp.chatBox.addInRadius(player, "ic", text, player:GetPos(), evorp.configuration["Talk Radius"]);
356 end;
357 end;
358 end;
359
360 end;
361
362 -- Return an empty string so the text doesn't show.
363 return "";
364end;
365
366-- Called when a player attempts suicide.
367function GM:CanPlayerSuicide(player) return false; end;
368
369hook.Add( "CanProperty", "canprophook", function( ply, property, ent )
370 ret = false;
371 if (ply.evorp._Donator > os.time() or ply.evorp._AdminLevel > 2) and (property == "skin" or property == "bodygroups") and (ent:CPPIGetOwner() == ply) then
372 ret = true;
373 end
374 if (ply.evorp._AdminLevel > 4) then ret = true end
375 return ret;
376end )
377
378function GM:CanProperty( ply, property, ent ) end
379
380-- Called when a player attempts to punt an entity with the gravity gun.
381function GM:GravGunPunt(player, entity) return false; end;
382
383-- Called when a player attempts to pick up an entity with the physics gun.
384function GM:PhysgunPickup(player, entity)
385 if (self.entities[entity]) then return false; end;
386
387 -- Check if the player is an administrator.
388 if ( player:IsAdmin() ) then
389 if ( entity:IsPlayer() ) then
390 if ( !entity:InVehicle() ) then
391 entity:SetMoveType(MOVETYPE_NOCLIP);
392 else
393 return false;
394 end;
395 end;
396
397 -- Return true because administrators can pickup any entity.
398 return true;
399 end;
400
401 -- Check if this entity is a player's ragdoll.
402 if ( IsValid(entity._Player) ) then return false; end;
403
404 -- Check if the entity is a forbidden class.
405 if ( string.find(entity:GetClass(), "npc_" or entity:IsRagdoll( ))
406 or string.find(entity:GetClass(), "prop_dynamic") ) then
407 return false;
408 end;
409
410 -- Call the base class function.
411 return self.BaseClass:PhysgunPickup(player, entity);
412end;
413
414-- Called when a player attempts to drop an entity with the physics gun.
415function GM:PhysgunDrop(player, entity)
416 if ( entity:IsPlayer() ) then entity:SetMoveType(MOVETYPE_WALK); end;
417end;
418
419-- Called when a player attempts to spawn an NPC.
420function GM:PlayerSpawnNPC(player, model)
421 -- Check if the player is an administrator.
422 if ( player:IsSuperAdmin() ) then
423 return true;
424 else
425 return false;
426 end;
427end;
428
429-- Called when a player attempts to spawn a prop.
430function GM:PlayerSpawnProp(player, model)
431 local hours = math.floor((player:GetNetworkedInt("evorp_PlayTime", 0) + (os.time() - player:GetNetworkedInt("evorp_JoinCurTime", 0))) / 3600)
432 if (hours < 2) then
433 evorp.player.notify(player, "You need atleast two hours of playtime to spawn props.", 0)
434 return false;
435 end
436 if ( !evorp.player.hasAccess(player, "e") ) then
437 evorp.player.notify(player, "You are banned from spawning props.", 1)
438 return false;
439 end;
440
441 -- Check if the player can spawn this prop.
442 if (!player:Alive() or player.evorp._Arrested or player._KnockedOut) then
443 evorp.player.notify(player, "You cannot do that in this state!", 1);
444
445 -- Return false because we cannot spawn it.
446 return false;
447 end;
448
449 -- Check if the player is an administrator.
450 if ( player:IsSuperAdmin() ) then return true; end;
451
452 local maxprops = 15;
453 if (player.evorp._Donator > os.time()) then maxprops = 20 end;
454 if (player:IsAdmin()) then maxprops = 20; end
455 if (player:GetCount("props") >= maxprops) then evorp.player.notify(player, "You have hit the prop limit!", 1); return false; end;
456
457 -- Escape the bad characters from the model.
458 model = string.Replace(model, "\\", "/");
459 model = string.Replace(model, "//", "/");
460
461 -- Loop through our banned props to see if this one is banned.
462 if ( evorp.configuration["Banned Props"][string.lower(model)] ) or string.find(string.lower(model), "models/xqm/coastertrack") or string.find(string.lower(model), "models/props_explosive") then
463 evorp.player.notify(player, "This prop is banned!", 1);
464 -- Return false because we cannot spawn it.
465 return false;
466 end;
467
468 -- Call the base class function.
469 return self.BaseClass:PlayerSpawnProp(player, model);
470end;
471
472function GM:PlayerSpawnedRagdoll(ply, model, ent )
473 if (IsValid(ent)) then
474 ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
475 end
476end
477
478-- Called when a player attempts to spawn a ragdoll.
479function GM:PlayerSpawnRagdoll(player, model)
480 return false;
481
482 --[[
483 if (!player:Alive() or player.evorp._Arrested or player._KnockedOut) then
484 evorp.player.notify(player, "You cannot do that in this state!", 1);
485
486 -- Return false because we cannot spawn it.
487 return false;
488 end;
489
490 -- Check if the player is an administrator.
491 if ( !player:IsSuperAdmin() ) then
492 return false;
493 else
494 return true;
495 end;]]
496end;
497
498-- Called when a player attempts to spawn an effect.
499function GM:PlayerSpawnEffect(player, model)
500 if (!player:Alive() or player.evorp._Arrested or player._KnockedOut) then
501 evorp.player.notify(player, "You cannot do that in this state!", 1);
502
503 -- Return false because we cannot spawn it.
504 return false;
505 end;
506
507 -- Check if the player is an administrator.
508 if ( !player:IsAdmin() ) then
509 return false;
510 else
511 return true;
512 end;
513end;
514
515function GM:PlayerSpawnedVehicle(player, vehicle)
516 local model = vehicle:GetModel()
517 if (model == "models/nova/airboat_seat.mdl" or model == "models/nova/jeep_seat.mdl" or model == "models/nova/chair_wood01.mdl" or model == "models/nova/chair_office02.mdl" or model == "models/nova/chair_plastic01.mdl") then
518 --if not (player.evorp._Donator > os.time()) then
519 player._SpawnedChair = vehicle;
520 --end
521 end
522end
523
524-- Called when a player attempts to spawn a vehicle.
525function GM:PlayerSpawnVehicle(player, model)
526 if (model == "models/nova/airboat_seat.mdl" or model == "models/nova/jeep_seat.mdl" or model == "models/nova/chair_wood01.mdl" or model == "models/nova/chair_office02.mdl" or model == "models/nova/chair_plastic01.mdl") then
527 if ( !evorp.player.hasAccess(player, "e") ) then
528 evorp.player.notify(player, "You are banned from spawning.", 1)
529 return false;
530 end;
531 if IsValid(player._SpawnedChair) then
532 evorp.player.notify(player, "You already have a spawned chair!", 1);
533 return false;
534 else
535 return true;
536 end
537 end
538 if (player.evorp._AdminLevel > 4) then
539 return true
540 else
541 return false
542 end
543end;
544
545
546-- A function to check whether we're running on a listen server.
547function GM:IsListenServer()
548 for k, v in pairs( g_Player.GetAll() ) do
549 if ( v:IsListenServerHost() ) then return true; end;
550 end;
551
552 -- Check if we're running on single player.
553 if ( game.SinglePlayer() ) then return true; end;
554
555 -- Return false because there is no listen server host and it isn't single player.
556 return false;
557end;
558
559-- Called when a player attempts to use a tool.
560function GM:CanTool(player, trace, tool)
561 if (IsValid(trace.Entity)) then
562 if tool == "remover" and !trace.Entity:GetOwner():IsWorld() and player.evorp._AdminLevel > 0 then return true end;
563 if trace.Entity.nodupe then return false end
564 local constraints = constraint.GetAllConstrainedEntities(trace.Entity);
565
566 -- Loop through the constained entities.
567 for k, v in pairs(constraints) do
568 if (IsValid(v) and v.nodupe) then return false; end;
569 end
570 end
571
572 --if ( player:IsAdmin() ) then return true; end;
573
574 -- Check if the trace entity is valid.
575 if ( IsValid(trace.Entity) ) then
576 if (tool == "nail") then
577 local line = {};
578
579 -- Set the information for the trace line.
580 line.start = trace.HitPos;
581 line.endpos = trace.HitPos + player:GetAimVector() * 16;
582 line.filter = {player, trace.Entity};
583
584 -- Perform the trace line.
585 line = util.TraceLine(line);
586
587 -- Check if the trace entity is valid.
588 if ( IsValid(line.Entity) ) then
589 if (self.entities[line.Entity]) then return false; end;
590 end;
591 end
592
593 -- Check if we're using the remover tool and we're trying to remove constrained entities.
594 if ( tool == "remover" and player:KeyDown(IN_ATTACK2) and !player:KeyDownLast(IN_ATTACK2) ) then
595 local entities = constraint.GetAllConstrainedEntities(trace.Entity);
596
597 -- Loop through the constained entities.
598 for k, v in pairs(entities) do
599 if (self.entities[v]) then return false; end;
600 end
601 end
602
603 -- Check if this entity cannot be used by the tool.
604 if (self.entities[trace.Entity]) then return false; end;
605
606 -- Check if this entity is a player's ragdoll.
607 if ( IsValid(trace.Entity._Player) ) then return false; end;
608 end;
609
610 -- Call the base class function.
611 return self.BaseClass:CanTool(player, trace, tool);
612end;
613
614-- Called when a player attempts to noclip.
615function GM:PlayerNoClip(player)
616 if ( player:IsAdmin() or player:GetUserGroup() == "moderator") then
617 return true;
618 else
619 return false;
620 end;
621end;
622
623-- Called when the player has initialized.
624function GM:PlayerInitialized(player) end;
625
626local celebrateseventy = false;
627
628timer.Create("Salary", evorp.configuration["Salary Interval"], 0, function()
629 local timeStart = SysTime()
630 local totalplayers = table.Count(g_Player.GetAll( ))
631 --Remember to remove
632 if (totalplayers == 70 and !celebrateseventy) then
633 celebrateseventy = true;
634
635 for k, player in pairs( g_Player.GetAll() ) do
636 if (IsValid(player)) then
637 if (player._Initialized) then
638 evorp.player.giveMoney(player, 10000);
639
640 -- Print a message to the player letting them know they received their salary.
641 evorp.player.notify(player, "You received $10000!! WE HIT 70 PLAYERS!.", 0);
642 end;
643 end
644 end;
645 end
646
647
648 local govplayers = g_Team.NumPlayers(TEAM_SS) + g_Team.NumPlayers(TEAM_HOSS) + g_Team.NumPlayers(TEAM_PRESIDENT) + g_Team.NumPlayers(TEAM_COMMANDER) + g_Team.NumPlayers(TEAM_OFFICER) + g_Team.NumPlayers(TEAM_SECRETARY) + g_Team.NumPlayers(TEAM_PARAMEDIC) + g_Team.NumPlayers(TEAM_FIREMAN)
649 local taxsplit = math.floor(((totalplayers - govplayers) * 25) / govplayers);
650 for k, player in pairs( g_Player.GetAll() ) do
651 if (IsValid(player)) then
652 if (player._Initialized and player:Alive() and !player.evorp._Arrested) then
653 local payable = player._Salary;
654 if (evorp.team.query(player:Team(), "radio", "") != "R_GOV") then
655 payable = payable - 25;
656 else
657 payable = payable + taxsplit;
658 end
659 evorp.player.giveMoney(player, payable);
660
661 -- Print a message to the player letting them know they received their salary.
662 evorp.player.notify(player, "You received $"..payable.." as salary.", 0);
663 evorp.player.saveData(player);
664 end;
665 end
666 end;
667 local text = "EVORP CYCLE #"..GetGlobalInt( "evorp_cycle" ).." COMPLETED IN "..SysTime()-timeStart.." WITH "..totalplayers.." players.";
668 exsto.GetPlugin("logs"):SaveEvent(text, "evorp")
669 --print(text)
670 SetGlobalInt( "evorp_cycle", GetGlobalInt( "evorp_cycle" ) + 1 )
671end);
672
673
674
675
676-- Called when a player's data is loaded.
677function GM:PlayerDataLoaded(player, success)
678 player._Job = evorp.configuration["Default Job"];
679 player._Ammo = {};
680 player._Gender = "Male";
681 player._Salary = 0;
682 player._Ragdoll = {};
683 player._Sleeping = false;
684 player._Warranted = false;
685 player._LightSpawn = false;
686 player._ScaleDamage = false;
687 player._Initialized = true;
688 player._ChangeTeam = false;
689 player._NextChangeTeam = {};
690 player._NextSpawnGender = "";
691 player._HideHealthEffects = false;
692 player._CannotBeWarranted = 0;
693
694 -- Some player variables based on configuration.
695 player._SpawnTime = evorp.configuration["Spawn Time"];
696 player._KnockOutTime = evorp.configuration["Knock Out Time"];
697 player._ArrestTime = 360;
698
699 -- Call a hook for the gamemode.
700 hook.Call("PlayerInitialized", GAMEMODE, player);
701
702 -- Respawn them now that they have initialized and then freeze them.
703 player:Spawn();
704 player:Freeze(true);
705
706 -- Unfreeze them in a second from now.
707 timer.Simple(1, function()
708 if ( IsValid(player) ) then
709 player:Freeze(false);
710
711 -- We can now start updating the player's data.
712 if (success) then
713 player._UpdateData = true;
714 end
715
716 player:SetNetworkedInt("evorp_PlayTime", player.evorp._PlayTime);
717 player:SetNetworkedInt("evorp_JoinCurTime", os.time());
718 NettyPlayerConnect(player)
719 -- Send a user message to remove the loading screen.
720 umsg.Start("evorp.player.initialized", player); umsg.End();
721 end;
722 end);
723
724 -- Check if the player is arrested.
725 if (player.evorp._Arrested) then evorp.player.arrest(player, true, true); end;
726end;
727
728-- Called when a player initially spawns.
729function GM:PlayerInitialSpawn(player)
730
731 if ( IsValid(player) ) then
732
733 evorp.player.loadData(player);
734
735
736 player:SetNetworkedInt("LastRevive", -300)
737 -- A table of valid door classes.
738 local doorClasses = {
739 "func_door",
740 "func_door_rotating",
741 "prop_door_rotating",
742 "prop_dynamic",
743 "prop_vehicle_jeep"
744 };
745
746 -- Loop through our table of valid door classes.
747 for k, v in pairs(doorClasses) do
748 for k2, v2 in pairs( ents.FindByClass(v) ) do
749 if ( evorp.entity.isDoor(v2) ) then
750 if (player:UniqueID() == v2._UniqueID) then
751 v2._Owner = player;
752
753 -- Set the networked owner so that the client can get it.
754 v2:SetNetworkedEntity("evorp_Owner", player);
755 end;
756 end;
757 end;
758 end;
759
760 -- A table to store every contraband entity.
761 local contraband = {};
762
763 -- Loop through each contraband class.
764 for k, v in pairs( evorp.configuration["Contraband"] ) do
765 table.Add( contraband, ents.FindByClass(k) );
766 end;
767
768 -- Loop through all of the contraband.
769 for k, v in pairs(contraband) do
770 if (player:UniqueID() == v._UniqueID) then v:SetPlayer(player); end;
771 end;
772
773 -- Kill them silently until we've loaded the data.
774 --player:KillSilent();
775 end;
776end
777
778-- Called every frame that a player is dead.
779function GM:PlayerDeathThink(player)
780 if (!player._Initialized) then return true; end;
781
782 -- Check if the player is a bot.
783 if (player:SteamID() == "BOT") then
784 if (player.NextSpawnTime and CurTime() >= player.NextSpawnTime) then player:Spawn(); end;
785 end;
786
787 -- Return the base class function.
788 return self.BaseClass:PlayerDeathThink(player);
789end;
790
791-- Called when a player's salary should be adjusted.
792function GM:PlayerAdjustSalary(player) end;
793--[[
794function GM:ShouldCollide( ent1, ent2 )
795 if (ent1.GST and IsValid(ent1) and IsValid(ent2)) then
796 local ret = true;
797 local class = string.lower(ent2:GetClass());
798 if (class == "player" or string.find(class, "prop_vehicle")) then
799 ret = false;
800 end
801 return ret;
802 end
803 return self.BaseClass:ShouldCollide(ent1, ent2)
804end]]
805
806-- Called when a player should gain a frag.
807function GM:PlayerCanGainFrag(player, victim) return true; end;
808
809-- Called when a player's model should be set.
810function GM:PlayerSetModel(player)
811 local models = evorp.team.query(player:Team(), "models");
812
813 -- Check if the models table exists.
814 if (models) then
815 models = models[ string.lower(player._Gender) ];
816
817 -- Check if the models table exists for this gender.
818 if (models) then
819 local model = models[ math.random(1, #models) ];
820
821 -- Set the player's model to the we got.
822 player:SetModel(model);
823 end;
824 end;
825end;
826
827-- Called when a player spawns.
828function GM:PlayerSpawn(player)
829 if (player._Initialized) then
830 if (player._NextSpawnGender != "") then
831 player._Gender = player._NextSpawnGender; player._NextSpawnGender = "";
832 end;
833
834 -- Set it so that the player does not drop weapons.
835 player:ShouldDropWeapon(false);
836
837 -- Check if we're not doing a light spawn.
838 if (!player._LightSpawn) then
839 -- Set some of the player's variables.
840
841 player._Ammo = {};
842 player._Sleeping = false;
843 player._ScaleDamage = false;
844 player._HideHealthEffects = false;
845 player._CannotBeWarranted = CurTime() + 30;
846 player:SetNetworkedBool("cuffed", false);
847 player:SetNetworkedBool("hostaged", false)
848 player:SetNetworkedBool("FakeDeathing", false)
849 timer.Destroy("RealDeath_"..player:UniqueID())
850 -- Make the player become conscious again.
851 evorp.player.knockOut(player, false, nil, true);
852
853 -- Set the player's model and give them their loadout.
854 self:PlayerSetModel(player);
855 self:PlayerLoadout(player);
856 player._AttachmentKit = false;
857
858 if (player._ChangeTeam and player._EVORPVehicle and IsValid(player._EVORPVehicle) and player._EVORPVehicle._Class) then
859 player._EVORPVehicle:Remove()
860 end
861 end;
862 if IsValid(player.BackGun) then
863 player.BackGun:Remove()
864 end
865
866 local oldhands = player:GetHands()
867 if ( IsValid( oldhands ) ) then oldhands:Remove() end
868
869 local hands = ents.Create( "gmod_hands" )
870 if ( IsValid( hands ) ) then
871 player:SetHands( hands )
872 hands:SetOwner( player )
873
874 -- Which hands should we use?
875 local cl_playermodel = player:GetInfo( "cl_playermodel" )
876 local info = player_manager.TranslatePlayerHands( cl_playermodel )
877 if ( info ) then
878 hands:SetModel( info.model )
879 hands:SetSkin( info.skin )
880 hands:SetBodyGroups( info.body )
881 end
882
883 -- Attach them to the viewmodel
884 local vm = player:GetViewModel( 0 )
885 hands:AttachToViewmodel( vm )
886
887 vm:DeleteOnRemove( hands )
888 player:DeleteOnRemove( hands )
889
890 hands:Spawn()
891 end
892
893 -- Call a gamemode hook for when the player has finished spawning.
894 hook.Call("PostPlayerSpawn", GAMEMODE, player, player._LightSpawn, player._ChangeTeam);
895
896 -- Set some of the player's variables.
897 player._LightSpawn = false;
898 player._ChangeTeam = false;
899 else
900 player:KillSilent();
901 end;
902end;
903
904function GM:ShouldKnockOut(player, attacker)
905 if (attacker and IsValid(attacker) and attacker:GetClass() == "prop_physics" or attacker:GetClass() == "worldspawn") then
906 return true
907 end
908end
909
910-- Called when a player should take damage.
911function NoPropDMG(player, attacker)
912 --if (IsValid(attacker) and attacker:GetClass() == "prop_physics") or (attacker:GetClass() == "worldspawn") then
913 -- return false
914 --end
915end
916
917hook.Add( "PlayerShouldTakeDamage", "NoPropDMG", NoPropDMG)
918
919function GM:ShouldAct( ply, actname, actid )
920 if not (ply:GetActiveWeapon() and ply:GetActiveWeapon() == "evorp_hands") then
921 evorp.player.notify(player, "You can only use act commands with your hands out.", 0)
922 return false;
923 elseif (ply:InVehicle()) then
924 evorp.player.notify(player, "You can't use act commands while you're inside a vehile or while sitting in a chair.", 0)
925 return false;
926 else
927 return true;
928 end
929end
930hook.Add( "PlayerShouldAct", "CanAct", ShouldAct );
931
932-- Called when a player is attacked by a trace.
933function GM:PlayerTraceAttack(player, damageInfo, direction, trace)
934 player._LastHitGroup = trace.HitGroup;
935
936 -- Return false so that we don't override internals.
937 return false;
938end;
939
940-- Called just before a player dies.
941function GM:DoPlayerDeath(player, attacker, damageInfo)
942 --[[
943 for k, v in pairs( player:GetWeapons() ) do
944 local class = v:GetClass();
945
946 -- Check if this is a valid item.
947 if (evorp.item.stored[class]) then
948 if ( hook.Call("PlayerCanDrop", GAMEMODE, player, class, true, attacker) ) then
949 evorp.item.make( class.."Broken", player:GetPos(), 1 );
950 end;
951 end;
952 end;
953
954 -- Loop through the player's weapons drop them.
955 if (player._Ragdoll.weapons) then
956 for k, v in pairs(player._Ragdoll.weapons) do
957 if (player._Ragdoll.weapons[v] and evorp.item.stored[ v[1] ]) then
958 if ( hook.Call("PlayerCanDrop", GAMEMODE, player, v[1], true, attacker) ) then
959 evorp.item.make( v[1].."Broken", player:GetPos(), 1 );
960 end;
961 player._Ragdoll.weapons[v] = 72;
962 end;
963 end
964 end
965 ]]
966 -- Strip the player's weapons and ammo.
967 player:StripWeapons();
968 player.evorp._Weps = "";
969
970 -- Add a death to the player's death count.
971 player:AddDeaths(1);
972
973 -- Check it the attacker is a valid entity and is a player.
974 if ( IsValid(attacker) and attacker:IsPlayer() ) then
975 if (player != attacker) then
976 if ( hook.Call("PlayerCanGainFrag", GAMEMODE, attacker, player) ) then
977 attacker:AddFrags(1);
978 end;
979 end;
980 end;
981end;
982
983-- Called when a player dies.
984function GM:PlayerDeath(player, inflictor, attacker, ragdoll)
985 evorp.player.warrant(player, false);
986 evorp.player.arrest(player, false, true);
987 evorp.player.bleed(player, false);
988 player:StripAmmo();
989 if (ragdoll != false) then
990 player._Ragdoll.weapons = {};
991 player._Ragdoll.health = player:Health();
992 player._Ragdoll.model = player:GetModel();
993 player._Ragdoll.team = player:Team();
994
995 -- Knockout the player to simulate their death.
996 evorp.player.knockOut(player, true);
997 end;
998 player._LastDeathTime = os.time();
999 player._LastDeathLocation = player:GetPos();
1000 player:ConCommand("DrawDeathMsg")
1001 evorp.chatBox.add( nil, player, "nlr", player.evorp._NameIC.." ("..player:Nick()..") died." );
1002 -- Set their next spawn time.
1003 player.NextSpawnTime = CurTime() + player._SpawnTime;
1004
1005 -- Set it so that we can the next spawn time client side.
1006 evorp.player.setLocalPlayerVariable(player, CLASS_LONG, "_NextSpawnTime", player.NextSpawnTime);
1007
1008 if (player:Team() == TEAM_PRESIDENT) then
1009 if not (IsValid(attacker) and attacker:IsPlayer() and evorp.team.query(attacker:Team(), "radio", "") == "R_GOV" and !attacker:Team() == TEAM_PRESIDENT) then
1010 evorp.team.make(player, "Unemployed");
1011 end
1012 end
1013end;
1014
1015-- Called when a player's weapons should be given.
1016function GM:PlayerLoadout(player)
1017 -- Give the player the camera, the hands and the physics cannon.
1018 player:Give("evorp_hands"); -- Random placement? Yes.
1019 player:Give("gmod_camera");
1020 if (evorp.player.hasAccess(player, "t")) then player:Give("gmod_tool"); else evorp.player.notify(player, "You are temporarily banned from using the tool gun, you will not receive it.", 1); end;
1021 if (evorp.player.hasAccess(player, "p")) then player:Give("weapon_physgun"); else evorp.player.notify(player, "You are temporarily banned from using the physics gun, you will not receive it.", 1); end;
1022 -- Call the player loadout hook.
1023 evorp.plugin.call("playerLoadout", player);
1024end
1025
1026-- Called when the server shuts down or the map changes.
1027function GM:ShutDown()
1028 for k, v in pairs( g_Player.GetAll() ) do
1029 --Contrarefund?
1030
1031 -- Save the player's data.
1032 evorp.player.saveData(v);
1033 end;
1034end;
1035
1036-- Called when a player presses F1.
1037function GM:ShowHelp(player) end;
1038
1039-- Called when a player presses F2.
1040function GM:ShowTeam(player)
1041 local door = player:GetEyeTrace().Entity;
1042
1043 -- Check if the player is aiming at a door.
1044 if ( IsValid(door) and evorp.entity.isDoor(door) ) then
1045 if (door:GetPos():Distance( player:GetPos() ) <= 128) then
1046 if ( hook.Call("PlayerCanViewDoor", GAMEMODE, player, door) ) then
1047 umsg.Start("evorp_Door", player);
1048 umsg.Bool(door._Unsellable or false);
1049
1050 -- Check if the owner is a valid entity.
1051 if ( IsValid(door._Owner) ) then
1052 umsg.Entity(door._Owner);
1053 else
1054 umsg.Entity(NULL);
1055 end;
1056
1057 -- Send the door as an entity and unsellable as a bool.
1058 umsg.Entity(door);
1059
1060 -- Check if the door has access.
1061 if (door._Access) then
1062 for k, v in pairs( g_Player.GetAll() ) do
1063 if (v != door._Owner) then
1064 local uniqueID = v:UniqueID();
1065
1066 -- Check if they have access.
1067 if (door._Access[uniqueID]) then
1068 umsg.Short( v:EntIndex() );
1069 umsg.Short(1);
1070 else
1071 umsg.Short( v:EntIndex() );
1072 umsg.Short(0);
1073 end;
1074 end;
1075 end;
1076 end;
1077 umsg.End();
1078 end;
1079 end;
1080 end;
1081end;
1082
1083-- Called when an entity takes damage.
1084function GM:EntityTakeDamage(entity, damageInfo)
1085 local inflictor = damageInfo:GetInflictor();
1086 local attacker = damageInfo:GetAttacker();
1087 local amount= damageInfo:GetDamage();
1088
1089 if (attacker and attacker:IsPlayer() and IsValid( attacker:GetActiveWeapon() )) then
1090 if attacker:GetActiveWeapon():GetClass() == "weapon_crowbar" then
1091 damageInfo:ScaleDamage(0.35);
1092 elseif attacker:GetActiveWeapon():GetClass() == "evorp_hands" then
1093 damageInfo:ScaleDamage(1);
1094 end
1095 end
1096
1097 if (entity:GetClass() == "prop_vehicle_jeep") then
1098 if not (IsValid(attacker) and attacker:IsPlayer() and IsValid( attacker:GetActiveWeapon() ) and (attacker:GetActiveWeapon():GetClass() == "weapon_crowbar")) then
1099 --VehicleHealth(entity, damageInfo)
1100 if IsValid(entity:GetDriver()) then
1101 entity:GetDriver():TakeDamage(amount, attacker, inflictor)
1102 end
1103 end
1104 end
1105
1106 -- Check if the entity that got damaged is a player.
1107 if ( entity:IsPlayer() ) then
1108 if not (entity:GetNetworkedBool("FakeDeathing")) then
1109 if (attacker:IsVehicle()) then
1110 --AMB_KillVelocity(attacker)
1111 evorp.player.knockOut(entity, true, 10);
1112 if (attacker:IsVehicle() and IsValid(attacker:GetDriver())) then
1113 --notifyAllAdm(attacker:GetDriver():Nick().." knocked out "..entity:Name().." with a car.", 0)
1114 evorp.player.printConsoleAccess(attacker:GetDriver():Nick().." knocked out "..entity:Name().." with a car.", "a", "kills", attacker);
1115 else
1116 evorp.player.printConsoleAccess(entity:Nick().." got knocked out by "..attacker:GetClass().." ["..attacker:EntIndex().."]", "a", "kills", attacker);
1117 end
1118 return
1119 end
1120 if (entity._KnockedOut) then
1121 if ( IsValid(entity._Ragdoll.entity) ) then
1122 hook.Call("EntityTakeDamage", GAMEMODE, entity._Ragdoll.entity, damageInfo);
1123 end;
1124 else
1125 if ( entity:InVehicle() and damageInfo:IsExplosionDamage() ) then
1126 if (!damageInfo:GetDamage() or damageInfo:GetDamage() == 0) then
1127 damageInfo:SetDamage(100);
1128 end;
1129 end;
1130 -- Check if the player has a last hit group defined.
1131 --[[
1132 if (entity._LastHitGroup) then
1133 if (entity._LastHitGroup == HITGROUP_HEAD) then
1134 damageInfo:ScaleDamage( evorp.configuration["Scale Head Damage"] );
1135 elseif (entity._LastHitGroup == HITGROUP_CHEST or entity._LastHitGroup == HITGROUP_GENERIC) then
1136 damageInfo:ScaleDamage( evorp.configuration["Scale Chest Damage"] );
1137 elseif (entity._LastHitGroup == HITGROUP_LEFTARM or
1138 entity._LastHitGroup == HITGROUP_RIGHTARM or
1139 entity._LastHitGroup == HITGROUP_LEFTLEG or
1140 entity._LastHitGroup == HITGROUP_RIGHTLEG or
1141 entity._LastHitGroup == HITGROUP_GEAR) then
1142 damageInfo:ScaleDamage( evorp.configuration["Scale Limb Damage"] );
1143 end;
1144
1145 -- Set the last hit group to nil so that we don't use it again.
1146 entity._LastHitGroup = nil;
1147 end;
1148
1149 -- Check if the player is supposed to scale damage.
1150 if (entity._ScaleDamage) then damageInfo:ScaleDamage(entity._ScaleDamage); end;
1151 ]]
1152 -- Make the player bleed.
1153 evorp.player.bleed( entity, true, evorp.configuration["Bleed Time"] );
1154 local player = entity;
1155 if player:InVehicle() then player:SetHealth( math.max(player:Health() - damageInfo:GetDamage(), 0) ) damageInfo:SetDamage(0) end
1156 if (player:Health() - damageInfo:GetDamage() <= 0 and player:Alive()) then
1157 if not (hook.Call( "PlayerShouldTakeDamage", GAMEMODE, player, attacker )) then return end
1158 if (IsValid(attacker)) then
1159 if ( attacker:IsPlayer() ) then
1160 if ( IsValid( attacker:GetActiveWeapon() ) ) then
1161 evorp.player.printConsoleAccess(attacker:Name().. " [".. attacker:SteamID() .. "] killed "..player:Name().. " [".. player:SteamID() .. "] with "..attacker:GetActiveWeapon():GetClass()..".", "a", "kills", attacker);
1162 else
1163 evorp.player.printConsoleAccess(attacker:Name().. " [".. attacker:SteamID() .. "] killed "..player:Name().. " [".. player:SteamID() .. "].", "a", "kills", attacker);
1164 end;
1165 else
1166 local str = attacker:GetClass();
1167 if (IsValid(attacker) and string.find(str, "prop_vehicle_jeep") and IsValid(attacker:GetDriver())) then
1168 evorp.player.printConsoleAccess(attacker:GetDriver():Nick().." killed "..player:Name().." with a car.", "a", "kills", attacker);
1169 notifyAllAdm(attacker:GetDriver():Nick().." killed "..player:Name().." with a car.", 1)
1170 end
1171 evorp.player.printConsoleAccess(str.." killed "..player:Name().. " [".. player:SteamID() .. "]"..".", "a", attacker);
1172 end;
1173 end
1174 if (CurTime() > player:GetNetworkedInt("LastRevive") + 150) then
1175 player:SetNetworkedBool("FakeDeathing", true)
1176 player:SetNetworkedInt("FakeDeathTimer", CurTime() + 120)
1177 evorp.player.knockOut(player, true);
1178 player._FakePlayer = player;
1179 player._FakeAttacker = attacker;
1180 player._FakeDmgInfo = damageInfo;
1181 player._FakeInflictor = inflictor;
1182 hook.Call("DoPlayerDeath", GAMEMODE, player, attacker, damageInfo);
1183 timer.Create( "RealDeath_"..player:UniqueID(), 120, 1, function()
1184 if not (IsValid (player)) then return end
1185 player:KillSilent();
1186 player:SetNetworkedBool("FakeDeathing", false)
1187 -- Call some gamemode hooks to fake the player's death.
1188 hook.Call("PlayerDeath", GAMEMODE, player, inflictor, attacker, true);
1189 player.NextSpawnTime = CurTime();
1190 evorp.player.setLocalPlayerVariable(player, CLASS_LONG, "_NextSpawnTime", player.NextSpawnTime);
1191 end)
1192 player:SetHealth(0);
1193 else
1194 player:KillSilent();
1195 hook.Call("DoPlayerDeath", GAMEMODE, player, attacker, damageInfo);
1196 hook.Call("PlayerDeath", GAMEMODE, player, inflictor, attacker, true);
1197 end
1198 return
1199 end
1200 end;
1201 end
1202 elseif ( entity:IsNPC() ) then
1203 if (attacker and attacker:IsPlayer() and IsValid( attacker:GetActiveWeapon() )
1204 and attacker:GetActiveWeapon():GetClass() == "weapon_crowbar") then
1205 damageInfo:ScaleDamage(0.25);
1206 end;
1207 end;
1208
1209 -- Check if the entity is a knocked out player.
1210 if ( IsValid(entity._Player) ) then
1211 local player = entity._Player;
1212 if not (entity:GetNetworkedBool("FakeDeathing")) then
1213 -- Set the damage to the amount we're given.
1214 if (damageInfo) then
1215 damageInfo:SetDamage(amount);
1216 end
1217 -- Check if the attacker is not a player.
1218 if ( !attacker:IsPlayer() ) then
1219 if ( attacker == game.GetWorld() ) then
1220 if ( ( entity._NextWorldDamage and entity._NextWorldDamage > CurTime() )
1221 or damageInfo:GetDamage() <= 10 ) then return; end;
1222
1223 -- Set the next world damage to be 1 second from now.
1224 entity._NextWorldDamage = CurTime() + 1;
1225 else
1226 if (damageInfo:GetDamage() <= 25) then return; end;
1227 end;
1228 else
1229 damageInfo:ScaleDamage( evorp.configuration["Scale Ragdoll Damage"] );
1230 end;
1231
1232 -- Check if the player is supposed to scale damage.
1233 if (entity._Player._ScaleDamage) then damageInfo:ScaleDamage(entity._Player._ScaleDamage); end;
1234
1235 -- Take the damage from the player's health.
1236 player:SetHealth( math.max(player:Health() - damageInfo:GetDamage(), 0) );
1237
1238 -- Set the player's conscious health.
1239 player._Ragdoll.health = player:Health();
1240
1241 -- Create new effect data so that we can create a blood impact at the damage position.
1242 local effectData = EffectData();
1243 effectData:SetOrigin( damageInfo:GetDamagePosition() );
1244 util.Effect("BloodImpact", effectData);
1245
1246 -- Loop from 1 to 4 so that we can draw some blood decals around the ragdoll.
1247 for i = 1, 2 do
1248 local trace = {};
1249
1250 -- Set some settings and information for the trace.
1251 trace.start = damageInfo:GetDamagePosition();
1252 trace.endpos = trace.start + (damageInfo:GetDamageForce() + (VectorRand() * 16) * 128);
1253 trace.filter = entity;
1254
1255 -- Create the trace line from the set information.
1256 trace = util.TraceLine(trace);
1257
1258 -- Draw a blood decal at the hit position.
1259 util.Decal("Blood", trace.HitPos + trace.HitNormal, trace.HitPos - trace.HitNormal);
1260 end;
1261
1262 -- Check to see if the player's health is less than 0 and that the player is alive.
1263 if ( player:Health() <= 0 and player:Alive() ) then
1264 if not (player:GetNetworkedBool("FakeDeathing")) then
1265 if not (hook.Call( "PlayerShouldTakeDamage", GAMEMODE, player, attacker )) then return end
1266 -- Check if the attacker is a player.
1267 if (IsValid(attacker)) then
1268 if ( attacker:IsPlayer() ) then
1269 if ( IsValid( attacker:GetActiveWeapon() ) ) then
1270 evorp.player.printConsoleAccess(attacker:Name().. " [".. attacker:SteamID() .. "] killed "..player:Name().. " [".. player:SteamID() .. "] with "..attacker:GetActiveWeapon():GetClass()..".", "a", "kills", attacker);
1271 else
1272 evorp.player.printConsoleAccess(attacker:Name().. " [".. attacker:SteamID() .. "] killed "..player:Name().. " [".. player:SteamID() .. "].", "a", "kills", attacker);
1273 end;
1274 else
1275 local str = attacker:GetClass();
1276 if (IsValid(attacker) and string.find(str, "prop_vehicle_jeep") and IsValid(attacker:GetDriver())) then
1277 notifyAllAdm(attacker:GetDriver():Nick().." killed "..player:Name().." with a car.", 1)
1278 end
1279 evorp.player.printConsoleAccess(str.." killed "..player:Name().. " [".. player:SteamID() .. "]"..".", "a", "kills", attacker);
1280 end;
1281 end
1282 if (CurTime() > player:GetNetworkedInt("LastRevive") + 150) then
1283 player._FakePlayer = player;
1284 player._FakeAttacker = attacker;
1285 player._FakeDmgInfo = damageInfo;
1286 player._FakeInflictor = inflictor;
1287 player:SetNetworkedBool("FakeDeathing", true)
1288 player:SetNetworkedInt("FakeDeathTimer", CurTime() + 120)
1289 timer.Destroy("Become Conscious: "..player:UniqueID())
1290 hook.Call("DoPlayerDeath", GAMEMODE, player, attacker, damageInfo);
1291 timer.Create( "RealDeath_"..player:UniqueID(), 120, 1, function()
1292 if not (IsValid (player)) then return end
1293 player:KillSilent();
1294 player:SetNetworkedBool("FakeDeathing", false)
1295 -- Call some gamemode hooks to fake the player's death.
1296 hook.Call("PlayerDeath", GAMEMODE, player, inflictor, attacker, true);
1297 player.NextSpawnTime = CurTime();
1298 evorp.player.setLocalPlayerVariable(player, CLASS_LONG, "_NextSpawnTime", player.NextSpawnTime);
1299 end)
1300 else
1301 player:KillSilent();
1302 hook.Call("DoPlayerDeath", GAMEMODE, player, attacker, damageInfo);
1303 hook.Call("PlayerDeath", GAMEMODE, player, inflictor, attacker, true);
1304 end
1305 end
1306 end;
1307 end
1308 end;
1309end;
1310
1311-- Called when a player has disconnected.
1312function GM:PlayerDisconnected(player)
1313 if not (!player:Alive() or player:GetNetworkedBool("hostaged") or player:GetNetworkedBool("FakeDeathing") or player:GetNetworkedBool("cuffed") or player._KnockedOut) then
1314 evorp.player.holsterAll(player);
1315 end
1316 if (player._Ragdoll and player._Ragdoll.weapons) then
1317 player._Ragdoll.weapons = false;
1318 end
1319
1320 evorp.player.knockOut(player, false, nil, true);
1321
1322 -- Save the player's data.
1323 evorp.player.saveData(player);
1324
1325 -- Call the base class function.
1326 self.BaseClass:PlayerDisconnected(player);
1327end;
1328
1329-- Called when a player attempts to spawn a SWEP.
1330function GM:PlayerSpawnSWEP(player, class, weapon)
1331 if not ( player.evorp._AdminLevel > 4 ) then
1332 return false;
1333 else
1334 return true;
1335 end;
1336end;
1337
1338-- Called when a player is given a SWEP.
1339function GM:PlayerGiveSWEP(player, class, weapon)
1340 if not ( player.evorp._AdminLevel > 4 ) then
1341 return false;
1342 else
1343 player._SpawnWeapons[class] = true;
1344 return true;
1345 end;
1346end;
1347
1348-- Called when attempts to spawn a SENT.
1349function GM:PlayerSpawnSENT(player, class)
1350 if not ( player.evorp._AdminLevel > 4) then
1351 return false;
1352 else
1353 return true;
1354 end;
1355end;
1356
1357-- Called when a player presses a key.
1358function GM:KeyPress(player, key)
1359 if (player.LastControl and player.LastControl + .5 > CurTime()) then
1360 return
1361 end
1362 player.LastControl = CurTime()
1363 if (key == IN_WALK and player:InVehicle()) then
1364 local dist1 = 0;
1365 local dist2 = 0;
1366 if string.lower(game.GetMap()) == "rp_evocity_v2d_sexy_v2" then
1367 dist1 = player:GetPos():Distance(Vector( -6498, -6615, 72 ))
1368 dist2 =player:GetPos():Distance(Vector( -6494, -6320, 72 ))
1369 end
1370 if string.lower(game.GetMap()) == "rp_evocity_v2d" then
1371 dist1 = player:GetPos():Distance(Vector( -6494, -6550, 72 ))
1372 dist2 =player:GetPos():Distance(Vector( -6494, -6255, 72 ))
1373 end
1374 if string.lower(game.GetMap()) == "rp_evocity_v33x" then
1375 dist1 = player:GetPos():Distance(Vector( -6485, -6555, 72 ))
1376 dist2 =player:GetPos():Distance(Vector( -6485, -6320, 72 ))
1377 if (player:GetPos():Distance(Vector( 10796, 13418, 58 )) < 325 or player:GetPos():Distance(Vector( 9991, 13419, 58 )) < 325) then
1378 dist1 = 1; dist2 = 1;
1379 end
1380 end
1381 if string.lower(game.GetMap()) == "rp_chaos_city_v33x_03" then
1382 dist1 = player:GetPos():Distance(Vector( 4131, 535, -1876 ))
1383 dist2 =player:GetPos():Distance(Vector( 4124, 288, -1876 ))
1384 if (player:GetPos():Distance(Vector( -7361, 5234, -1489 )) < 500 or player:GetPos():Distance(Vector( -8282, 5223, -1489 )) < 500) then
1385 dist1 = 1; dist2 = 1;
1386 end
1387 end
1388 if (dist1 > 250 and dist2 > 250) then
1389 return
1390 end
1391 local fee = 300
1392 if (player.evorp._Donator > os.time()) then fee = 150 end;
1393 if evorp.player.canAfford(player, fee) then
1394 evorp.player.giveMoney(player, -fee);
1395 player:GetVehicle()._Fuel = 100;
1396 player:GetVehicle():SetNetworkedInt("fuel", 100)
1397 evorp.player.notify(player, "Your vehicle has been refueled!", 0)
1398 else
1399 evorp.player.notify(player, "Not enough money!", 1)
1400 end
1401 end
1402 if (key == IN_USE) then
1403 local trace = player:GetEyeTrace();
1404 if ( IsValid(trace.Entity) and trace.Entity.iDoorSID ) then
1405 if (evorp.player.hasDoorAccess(player, trace.Entity) ) then
1406 if not (trace.Entity:GetNetworkedBool("dlocked")) then
1407 if (trace.Entity.iOpen) then
1408 trace.Entity:Fire("setanimation", "close", "0");
1409 trace.Entity.iOpen = false
1410 else
1411 trace.Entity:Fire("setanimation", "open", "0");
1412 trace.Entity.iOpen = true
1413 end
1414 else
1415 trace.Entity:EmitSound("doors/door_latch3.wav")
1416 end
1417 end
1418 end
1419 end
1420 if (key == IN_JUMP and player._StuckInWorld) then
1421 UnstuckPlayer(player)
1422 --evorp.player.holsterAll(player);
1423
1424 -- Spawn them lightly now that we holstered their weapons.
1425 --evorp.player.lightSpawn(player);
1426 end;
1427end;
1428
1429-- Create a timer to automatically clean up decals.
1430timer.Create("Cleanup Decals", 60, 0, function()
1431 if ( evorp.configuration["Cleanup Decals"] ) then
1432 for k, v in pairs( g_Player.GetAll() ) do v:ConCommand("r_cleardecals\n"); end;
1433 end;
1434end);
1435
1436-- Create a timer to give players money for their contraband.
1437timer.Create("Contraband", evorp.configuration["Contraband Interval"], 0, function()
1438 local players = {};
1439 local contraband = {};
1440
1441 -- Loop through each contraband class.
1442 for k, v in pairs( evorp.configuration["Contraband"] ) do
1443 table.Add( contraband, ents.FindByClass(k) );
1444 end;
1445
1446 -- Loop through all of the contraband.
1447 for k, v in pairs(contraband) do
1448 local player = v:GetPlayer();
1449
1450 -- Check if the player is a valid entity,
1451 if ( IsValid(player) and player:Team() != TEAM_PRESIDENT and player:Team() != TEAM_HOSS and player:Team() != TEAM_SS and player:Team() != TEAM_COMMANDER and player:Team() != TEAM_OFFICER) then
1452 players[player] = players[player] or {refill = 0, money = 0};
1453
1454 -- Decrease the energy of the contraband.
1455 v._Energy = math.Clamp(v._Energy - 1, 0, 5);
1456
1457 -- Set the networked variable so that the client can use it.
1458 v:SetNetworkedInt("evorp_Energy", v._Energy);
1459 v:SetNetworkedInt("evorp_CMoney", (5-v._Energy) * evorp.configuration["Contraband"][ v:GetClass() ].money);
1460
1461 -- Check the energy of the contraband.
1462 if (v._Energy == 0) then
1463 players[player].refill = players[player].refill + 1;
1464 else
1465 --players[player].money = players[player].money + evorp.configuration["Contraband"][ v:GetClass() ].money;
1466 end;
1467 end;
1468 end;
1469
1470 -- Loop through our players list.
1471 for k, v in pairs(players) do
1472 if ( hook.Call("PlayerCanContraband", GAMEMODE, k) ) then
1473 if (v.refill > 0) then
1474 evorp.player.notify(k, v.refill.." of your contraband need refilling!", 1);
1475 elseif (v.money > 0) then
1476 --evorp.player.notify(k, "You earned $"..v.money.." from contraband.", 0);
1477
1478 -- Give the player their money.
1479 --evorp.player.giveMoney(k, v.money);
1480 end;
1481 end;
1482 end;
1483
1484end);
1485
1486timer.Create("SpawnPropPhysRemover", 20, 0, function()
1487 local mapname = string.lower(game.GetMap());
1488 if mapname == "rp_chaos_city_v33x_03" then
1489 for _, ent in pairs(ents.FindInSphere(Vector( 6765, -5554, -1868 ), 700)) do
1490 if (string.find( ent:GetClass( ), "prop_physics" )) then
1491 ent:Remove()
1492 end
1493 end
1494 for _, ent in pairs(ents.FindInSphere(Vector( 6413, -5552, -1868 ), 700)) do
1495 if (string.find( ent:GetClass( ), "prop_physics" )) then
1496 ent:Remove()
1497 end
1498 end
1499 for _, ent in pairs(ents.FindInSphere(Vector( 6038, -5548, -1868 ), 700)) do
1500 if (string.find( ent:GetClass( ), "prop_physics" )) then
1501 ent:Remove()
1502 end
1503 end
1504 for _, ent in pairs(ents.FindInSphere(Vector( 5765, -5495, -1868 ), 700)) do
1505 if (string.find( ent:GetClass( ), "prop_physics" )) then
1506 ent:Remove()
1507 end
1508 end
1509 for _, ent in pairs(ents.FindInSphere(Vector( 5325, -5289, 1868 ), 300)) do
1510 if (string.find( ent:GetClass( ), "prop_physics" )) then
1511 ent:Remove()
1512 end
1513 end
1514 end
1515 if mapname == "rp_evocity_v2d" or mapname == "rp_evocity_v33x" or mapname == "rp_evocity_v2d_sexy_v2" then
1516 for _, ent in pairs(ents.FindInSphere(Vector( -3427, -10392, 71 ), 700)) do
1517 if (string.find( ent:GetClass( ), "prop_physics" )) then
1518 ent:Remove()
1519 end
1520 end
1521 for _, ent in pairs(ents.FindInSphere(Vector( -4062, -10399, 71 ), 700)) do
1522 if (string.find( ent:GetClass( ), "prop_physics" )) then
1523 ent:Remove()
1524 end
1525 end
1526 for _, ent in pairs(ents.FindInSphere(Vector( -4645, -10404, 71 ), 700)) do
1527 if (string.find( ent:GetClass( ), "prop_physics" )) then
1528 ent:Remove()
1529 end
1530 end
1531 for _, ent in pairs(ents.FindInSphere(Vector( -5170, -10384, 71 ), 700)) do
1532 if (string.find( ent:GetClass( ), "prop_physics" )) then
1533 ent:Remove()
1534 end
1535 end
1536 for _, ent in pairs(ents.FindInSphere(Vector( -5531, -10094, 71 ), 300)) do
1537 if (string.find( ent:GetClass( ), "prop_physics" )) then
1538 ent:Remove()
1539 end
1540 end
1541 end
1542end)
1543
1544timer.Create("Vehicles", 2, 0, function()
1545 for _, v in ipairs( g_Player.GetAll() ) do
1546 --print(v:GetPos())
1547 if (IsValid(v) and v:InVehicle()) then
1548 local vehicle = v:GetVehicle()
1549 if (vehicle._Fuel) then
1550 local eph = math.abs(math.floor(vehicle:GetVelocity():Length()/ 25.33));
1551 if eph < 5 then eph = 0 end --Meh..Didn't even test if it was going to bug, but this doesn't hurt.
1552 vehicle._Fuel = math.Clamp(vehicle._Fuel - (math.Clamp(eph * (0.01), .1, 100)), 0, 100);
1553 vehicle:SetNetworkedInt("fuel", vehicle._Fuel)
1554 if vehicle._Fuel < 1 then
1555 vehicle:Fire("TurnOff", "" , 0)
1556 vehicle._Off = true
1557 else
1558 if (vehicle._Off and !vehicle:GetNetworkedBool("punched")) then vehicle:Fire("TurnOn", "" , 0); v._Off = false; end
1559 end
1560 end
1561 end
1562 end
1563 if string.lower(game.GetMap()) == "rp_chaos_city_v33x_03" then
1564 for _, ent in pairs(ents.FindInSphere(Vector( 3207, -99, -1876 ), 400)) do
1565 if (string.find( ent:GetClass( ), "prop_vehicle_jeep" )) then
1566 if (IsValid(ent:GetDriver())) then
1567 if (ent:GetNetworkedBool("NeedsFix")) then
1568 evorp.player.notify(ent:GetDriver(), "You need to repair this vehicle before parking it!", 0)
1569 return;
1570 end
1571 ent:GetDriver():ExitVehicle();
1572 evorp.player.notify(ent:GetDriver(), "Your vehicle has been parked!", 0)
1573 end
1574 ent:Remove()
1575 end
1576 end
1577 for _, ent in pairs(ents.FindInSphere(Vector( 4131, 749, -1868 ), 100)) do
1578 if (string.find( ent:GetClass( ), "prop_vehicle_jeep") and ent:GetDriver() and IsValid(ent:GetDriver())) then
1579 if not (ent.VehicleTable.nopaint) then
1580 local rand = evorp.configuration["Default Colors"][ math.random( #evorp.configuration["Default Colors"] ) ]
1581 ent:SetColor(rand);
1582 --ent:SetSkin(math.random(11, 15))
1583 ent:EmitSound("carStools/spray.wav",80,70)
1584 end
1585 end
1586 end
1587 end
1588 if string.lower(game.GetMap()) == "rp_evocity_v33x" then
1589 for _, ent in pairs(ents.FindInSphere(Vector( -7572, -7226, 64 ), 350)) do
1590 if (string.find( ent:GetClass( ), "prop_vehicle_jeep" )) then
1591 if (IsValid(ent:GetDriver())) then
1592 if (ent:GetNetworkedBool("NeedsFix")) then
1593 evorp.player.notify(ent:GetDriver(), "You need to repair this vehicle before parking it!", 0)
1594 return;
1595 end
1596 ent:GetDriver():ExitVehicle();
1597 evorp.player.notify(ent:GetDriver(), "Your vehicle has been parked!", 0)
1598 end
1599 ent:Remove()
1600 end
1601 end
1602 for _, ent in pairs(ents.FindInSphere(Vector( -6489, -5959, 72 ), 100)) do
1603 if (string.find( ent:GetClass( ), "prop_vehicle_jeep") and ent:GetDriver() and IsValid(ent:GetDriver())) then
1604 if not (ent.VehicleTable.nopaint) then
1605 local rand = evorp.configuration["Default Colors"][ math.random( #evorp.configuration["Default Colors"] ) ]
1606 ent:SetColor(rand);
1607 --ent:SetSkin(math.random(11, 15))
1608 ent:EmitSound("carStools/spray.wav",80,70)
1609 end
1610 end
1611 end
1612 end
1613 if string.lower(game.GetMap()) == "rp_evocity_v2d" then
1614 for _, ent in pairs(ents.FindInSphere(Vector( -7209, -7056, 64 ), 40)) do
1615 if (string.find( ent:GetClass( ), "prop_vehicle_jeep" )) then
1616 if (IsValid(ent:GetDriver())) then
1617 if (ent:GetNetworkedBool("NeedsFix")) then
1618 evorp.player.notify(ent:GetDriver(), "You need to repair this vehicle before parking it!", 0)
1619 return;
1620 end
1621 ent:GetDriver():ExitVehicle();
1622 evorp.player.notify(ent:GetDriver(), "Your vehicle has been parked!", 0)
1623 end
1624 ent:Remove()
1625 end
1626 end
1627 for _, ent in pairs(ents.FindInSphere(Vector( -6493, -5960, 72 ), 100)) do
1628 if (string.find( ent:GetClass( ), "prop_vehicle_jeep") and ent:GetDriver() and IsValid(ent:GetDriver())) then
1629 if not (ent.VehicleTable.nopaint) then
1630 local rand = evorp.configuration["Default Colors"][ math.random( #evorp.configuration["Default Colors"] ) ]
1631 ent:SetColor(rand);
1632 --ent:SetSkin(math.random(11, 15))
1633 ent:EmitSound("carStools/spray.wav",80,70)
1634 end
1635 end
1636 end
1637 end
1638 if string.lower(game.GetMap()) == "rp_evocity_v2d_sexy_v2" then
1639 for _, ent in pairs(ents.FindInSphere(Vector( -7230, -6735, 64 ), 40)) do
1640 if (string.find( ent:GetClass( ), "prop_vehicle_jeep" )) then
1641 if (IsValid(ent:GetDriver())) then
1642 if (ent:GetNetworkedBool("NeedsFix")) then
1643 evorp.player.notify(ent:GetDriver(), "You need to repair this vehicle before parking it!", 0)
1644 return;
1645 end
1646 ent:GetDriver():ExitVehicle();
1647 evorp.player.notify(ent:GetDriver(), "Your vehicle has been parked!", 0)
1648 end
1649 ent:Remove()
1650 end
1651 end
1652 for _, ent in pairs(ents.FindInSphere(Vector( -6491, -5960, 72 ), 100)) do
1653 if (string.find( ent:GetClass( ), "prop_vehicle_jeep") and ent:GetDriver() and IsValid(ent:GetDriver())) then
1654 if not (ent.VehicleTable.nopaint) then
1655 local rand = evorp.configuration["Default Colors"][ math.random( #evorp.configuration["Default Colors"] ) ]
1656 ent:SetColor(rand);
1657 --ent:SetSkin(math.random(11, 15))
1658 ent:EmitSound("carStools/spray.wav",80,70)
1659 end
1660 end
1661 end
1662 end
1663end);
1664
1665timer.Create("WalkAdvice", 1, 0, function()
1666 if string.lower(game.GetMap()) == "rp_chaos_city_v33x_03" then
1667 for _, ent in pairs(ents.FindInSphere(Vector( 3207, -99, -1876 ), 450)) do
1668 if (ent:IsPlayer()) then
1669 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to park it.")
1670 end
1671 end
1672 for _, ent in pairs(ents.FindInSphere(Vector( 4131, 535, -1876 ), 200)) do
1673 if (ent:IsPlayer()) then
1674 if (ent:InVehicle()) then
1675 if not (ent.evorp._Donator > os.time()) then
1676 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1677 else
1678 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1679 end
1680 else
1681 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1682 end
1683 end
1684 end
1685 for _, ent in pairs(ents.FindInSphere(Vector( 4124, 288, -1876 ), 200)) do
1686 if (ent:IsPlayer()) then
1687 if (ent:InVehicle()) then
1688 if not (ent.evorp._Donator > os.time()) then
1689 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1690 else
1691 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1692 end
1693 else
1694 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1695 end
1696 end
1697 end
1698 for _, ent in pairs(ents.FindInSphere(Vector( -7361, 5234, -1489 ), 500)) do
1699 if (ent:IsPlayer()) then
1700 if (ent:InVehicle()) then
1701 if not (ent.evorp._Donator > os.time()) then
1702 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1703 else
1704 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1705 end
1706 else
1707 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1708 end
1709 end
1710 end
1711 for _, ent in pairs(ents.FindInSphere(Vector( -8282, 5223, -1489 ), 500)) do
1712 if (ent:IsPlayer()) then
1713 if (ent:InVehicle()) then
1714 if not (ent.evorp._Donator > os.time()) then
1715 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1716 else
1717 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1718 end
1719 else
1720 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1721 end
1722 end
1723 end
1724
1725 for _, ent in pairs(ents.FindInSphere(Vector( 4131, 749, -1868 ), 200)) do
1726 if (ent:IsPlayer() and !ent:InVehicle()) then
1727 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here for a paint job.")
1728 end
1729 end
1730 end
1731 if string.lower(game.GetMap()) == "rp_evocity_v33x" then
1732 for _, ent in pairs(ents.FindInSphere(Vector( -7571, -7201, 64 ), 350)) do
1733 if (ent:IsPlayer()) then
1734 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to park it.")
1735 end
1736 end
1737 for _, ent in pairs(ents.FindInSphere(Vector( -6503, -6614, 72 ), 200)) do
1738 if (ent:IsPlayer()) then
1739 if (ent:InVehicle()) then
1740 if not (ent.evorp._Donator > os.time()) then
1741 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1742 else
1743 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1744 end
1745 else
1746 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1747 end
1748 end
1749 end
1750 for _, ent in pairs(ents.FindInSphere(Vector( -6494, -6315, 72 ), 200)) do
1751 if (ent:IsPlayer()) then
1752 if (ent:InVehicle()) then
1753 if not (ent.evorp._Donator > os.time()) then
1754 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1755 else
1756 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1757 end
1758 else
1759 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1760 end
1761 end
1762 end
1763 for _, ent in pairs(ents.FindInSphere(Vector( 10796, 13418, 58 ), 200)) do
1764 if (ent:IsPlayer()) then
1765 if (ent:InVehicle()) then
1766 if not (ent.evorp._Donator > os.time()) then
1767 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1768 else
1769 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1770 end
1771 else
1772 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1773 end
1774 end
1775 end
1776 for _, ent in pairs(ents.FindInSphere(Vector( 9991, 13419, 58 ), 200)) do
1777 if (ent:IsPlayer()) then
1778 if (ent:InVehicle()) then
1779 if not (ent.evorp._Donator > os.time()) then
1780 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1781 else
1782 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1783 end
1784 else
1785 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1786 end
1787 end
1788 end
1789 for _, ent in pairs(ents.FindInSphere(Vector( -6484, -6024, 72 ), 200)) do
1790 if (ent:IsPlayer() and !ent:InVehicle()) then
1791 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here for a paint job.")
1792 end
1793 end
1794 end
1795 if string.lower(game.GetMap()) == "rp_evocity_v2d" then
1796 for _, ent in pairs(ents.FindInSphere(Vector( -7209, -7056, 64 ), 150)) do
1797 if (ent:IsPlayer()) then
1798 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to park it.")
1799 end
1800 end
1801 for _, ent in pairs(ents.FindInSphere(Vector( -6494, -6550, 72 ), 200)) do
1802 if (ent:IsPlayer()) then
1803 if (ent:InVehicle()) then
1804 if not (ent.evorp._Donator > os.time()) then
1805 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1806 else
1807 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1808 end
1809 else
1810 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1811 end
1812 end
1813 end
1814 for _, ent in pairs(ents.FindInSphere(Vector( -6494, -6255, 72 ), 200)) do
1815 if (ent:IsPlayer()) then
1816 if (ent:InVehicle()) then
1817 if not (ent.evorp._Donator > os.time()) then
1818 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1819 else
1820 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1821 end
1822 else
1823 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1824 end
1825 end
1826 end
1827 for _, ent in pairs(ents.FindInSphere(Vector( -6493, -5960, 72 ), 100)) do
1828 if (ent:IsPlayer() and !ent:InVehicle()) then
1829 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here for a paint job.")
1830 end
1831 end
1832 end
1833 if string.lower(game.GetMap()) == "rp_evocity_v2d_sexy_v2" then
1834 for _, ent in pairs(ents.FindInSphere(Vector( -7230, -6735, 64 ), 150)) do
1835 if (ent:IsPlayer()) then
1836 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to park it.")
1837 end
1838 end
1839 for _, ent in pairs(ents.FindInSphere(Vector( -6498, -6615, 72 ), 200)) do
1840 if (ent:IsPlayer()) then
1841 if (ent:InVehicle()) then
1842 if not (ent.evorp._Donator > os.time()) then
1843 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1844 else
1845 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1846 end
1847 else
1848 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1849 end
1850 end
1851 end
1852 for _, ent in pairs(ents.FindInSphere(Vector( -6494, -6320, 72 ), 200)) do
1853 if (ent:IsPlayer()) then
1854 if (ent:InVehicle()) then
1855 if not (ent.evorp._Donator > os.time()) then
1856 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $300.")
1857 else
1858 ent:PrintMessage(HUD_PRINTCENTER, "Tap 'ALT' to refill car for $150.")
1859 end
1860 else
1861 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here to refuel it.")
1862 end
1863 end
1864 end
1865 for _, ent in pairs(ents.FindInSphere(Vector( -6491, -5960, 72 ), 100)) do
1866 if (ent:IsPlayer() and !ent:InVehicle()) then
1867 ent:PrintMessage(HUD_PRINTCENTER, "Bring your car here for a paint job.")
1868 end
1869 end
1870 end
1871end);
1872
1873hook.Add("KeyPress", "InVehicleLock", function(ply, key)
1874 if (ply:GetNetworkedBool("FakeDeathing") and key == 1) then
1875 if not (CurTime() > ply:GetNetworkedInt("FakeDeathTimer") - 120 + ply._SpawnTime) then return end
1876 local player = ply
1877 ply:SetNetworkedBool("FakeDeathing", false)
1878 timer.Destroy( "RealDeath_"..player:UniqueID())
1879 player:KillSilent();
1880 -- Call some gamemode hooks to fake the player's death.
1881 --hook.Call("DoPlayerDeath", GAMEMODE, player._FakePlayer, player._FakeAttacker, player._FakeDmgInfo);
1882 hook.Call("PlayerDeath", GAMEMODE, player._FakePlayer, player._FakeInflictor , player._FakeAttacker, true);
1883 player.NextSpawnTime = CurTime();
1884 evorp.player.setLocalPlayerVariable(player, CLASS_LONG, "_NextSpawnTime", player.NextSpawnTime);
1885 end
1886 if !ply:InVehicle() || key != 1 then return end -- 1 is IN_ATTACK
1887 --local trace = ply:GetEyeTrace();
1888 if !( IsValid(ply:GetVehicle()) ) then
1889 return;
1890 end
1891 if !(string.find( ply:GetVehicle():GetClass(), "prop_vehicle_jeep" )) then
1892 return
1893 end
1894 local car = ply:GetVehicle();
1895 if (car:GetNetworkedBool("locked")) then
1896 car:SetNetworkedBool("locked", false)
1897 car:EmitSound("doors/door_latch3.wav")
1898 else
1899 car:SetNetworkedBool("locked", true)
1900 car:EmitSound("doors/door_latch3.wav")
1901 end
1902end)
1903
1904timer.Create("UpdateOnline", 20, 0, function()
1905 local steamids = "('EX1', 'EX2'" -- Logic fail, this is the fix.
1906 for _, v in ipairs( g_Player.GetAll() ) do
1907 steamids = steamids..", '"..v:SteamID().."'"
1908 end
1909 steamids = steamids..")"
1910 GetDBConnection():Query("UPDATE players SET _Online = 'NO' WHERE _SteamID NOT IN "..steamids.." AND _Online = '"..GetConVar("sv_logdownloadlist"):GetString().."'")
1911end)
1912
1913timer.Create("NLR Reminder", 10, 0, function()
1914 for _, v in ipairs( g_Player.GetAll() ) do
1915 if (!v:Alive()) then return end
1916 if (v._LastDeathLocation and v._LastDeathTime) then
1917 if (os.time() - v._LastDeathTime < 330 and os.time() - v._LastDeathTime > 60) then
1918 for _, ent in pairs(ents.FindInSphere(v._LastDeathLocation, 650)) do
1919 if (ent:IsPlayer() and ent:UniqueID() == v:UniqueID()) then
1920 evorp.player.printConsoleAccess(v:Nick().." is breaking NLR.", 1, "a", "kills", v);
1921 --notifyAllAdm(v:Nick().." is breaking NLR.", 1)
1922 end
1923 end
1924 end
1925 end
1926 end
1927end)
1928
1929timer.Create("DonationCheck", 60, 0, function()
1930 GetDBConnection():Query("SELECT * FROM donations WHERE _Credited = '0'", function(result)
1931 if (result and type(result) == "table" and #result > 0) then
1932 for index,value in ipairs(result) do
1933 local column = result[index];
1934 local steamID = column._SteamID
1935 local credits = tonumber(column._Credits)
1936
1937 for _, player in ipairs( g_Player.GetAll() ) do
1938 if (player._Initialized and string.lower(player:SteamID()) == string.lower(steamID)) then
1939 player.evorp._DonorCredits = player.evorp._DonorCredits + credits;
1940 GetDBConnection():Query("UPDATE donations SET _Credited = '1' WHERE _Key = "..column._Key)
1941 evorp.player.saveData(player)
1942 evorp.player.notify(player, "You have been credited for you donation!", 0)
1943 end
1944 end
1945 end
1946 end;
1947 end, 1);
1948end)
1949
1950timer.Create("BansCheck", 120, 0, function()
1951 for _, player in ipairs( g_Player.GetAll() ) do
1952 if (player._Initialized and player._Bans) then
1953 for k, column in ipairs(player._Bans) do
1954 if not (os.time() < tonumber(column._Until) or tonumber(column._Until) == 0) then
1955 if not (evorp.player.hasAccess(player, column._Access)) then
1956 evorp.player.giveAccess(player, column._Access)
1957 evorp.player.notify(player, "A ban on you has been lifted!", 0)
1958 end
1959 end
1960 end
1961 end
1962 end
1963end)
1964
1965function notifyAllAdm(txt, type)
1966 for __, vv in ipairs( g_Player.GetAll() ) do
1967 if(vv:IsAdmin()) then
1968 evorp.player.notify(vv , txt, type)
1969 end
1970 end
1971end