· 9 years ago · Dec 09, 2016, 02:49 PM
1--[[
2Name: "cl_init.lua".
3Product: "EvoRP (Roleplay)".
4--]]
5surface.CreateFont("Museo", {font = "Museo Sans 500", size= 24, weight = 400, antialias = true } )
6surface.CreateFont("Franchise", {font = "Franchise", size= 24, weight = 400, antialias = true } )
7surface.CreateFont("EvoFontN1", {font = "Museo Sans 500", size = 20, weight = 600, antialias = true, shadow = false}); -- A slightly bigger font.
8surface.CreateFont("EvoFont", {font = "Museo Sans 500", size = 17, weight = 600, antialias = true, shadow = false}); -- Chat and Char info font
9surface.CreateFont("EvoFont2", {font = "Museo Sans 500", size = 16, weight = 400, antialias = true, shadow = false}); -- F1, readable font
10surface.CreateFont("EvoFont3", {font = "Museo Sans 500", size = 12, weight = 400, antialias = true, shadow = false}); -- Bar Font
11
12include("sh_init.lua");
13include("core/scoreboard/scoreboard.lua");
14
15-- Set some information for the gamemode.
16GM.topTextGradient = {};
17GM.variableQueue = {};
18
19surface.CreateFont("LabelFont", {font = "Museo Sans 500", size = 60, weight = 575, antialias = false, shadow = true});
20
21-- Add a usermessage to recieve a notification.
22usermessage.Hook("evorp_Notification", function(msg)
23 local message = msg:ReadString();
24 local class = msg:ReadShort();
25
26 -- The sound of the notification.
27 local sound = "ambient/water/drip2.wav";
28
29 -- Check the class of the message.
30 if (class == 1) then
31 sound = "buttons/button10.wav";
32 elseif (class == 2) then
33 sound = "buttons/button17.wav";
34 elseif (class == 3) then
35 sound = "buttons/bell1.wav";
36 elseif (class == 4) then
37 sound = "buttons/button15.wav";
38 end
39
40 -- Play the sound to the local player.
41 surface.PlaySound(sound);
42
43 -- Add the notification using Garry's system.
44 GAMEMODE:AddNotify(message, class, 10);
45end);
46
47-- Override the weapon pickup function.
48function GM:HUDWeaponPickedUp(...) end;
49
50-- Override the item pickup function.
51function GM:HUDItemPickedUp(...) end;
52
53-- Override the ammo pickup function.
54function GM:HUDAmmoPickedUp(...) end;
55
56-- Called when an entity is created.
57function GM:OnEntityCreated(entity)
58 if (LocalPlayer() == entity) then
59 for k, v in pairs(self.variableQueue) do LocalPlayer()[k] = v; end;
60 end;
61
62 -- Call the base class function.
63 return self.BaseClass:OnEntityCreated(entity);
64end;
65
66timer.Create( "timePlayed", 1, 0, function()
67 if LocalPlayer():GetNetworkedInt("evorp_PlayTime") then
68 LocalPlayer():SetNetworkedInt("evorp_PlayTime", LocalPlayer():GetNetworkedInt("evorp_PlayTime") + 1)
69 end
70end)
71
72-- Called when a player presses a bind.
73function GM:PlayerBindPress(player, bind, press)
74 if ( !self.playerInitialized and string.find(bind, "+jump") ) then
75 RunConsoleCommand("retry");
76 end;
77
78 -- Check if they're trying to use a binded EvoRP command.
79 if ( string.find(bind, "evorp ") or string.find(bind, "say /") ) then
80 --if ( !player:GetNetworkedBool("evorp_Binds") and !player:IsAdmin() ) then
81 -- player:ChatPrint("Only Donators can use binded commands!");
82
83 -- Return true because they cannot use the command.
84 -- return true;
85 --end;
86 end;
87
88 -- Call the base class function.
89 return self.BaseClass:PlayerBindPress(player, bind, press);
90end;
91
92-- Check if the local player is using the camera.
93function GM:IsUsingCamera()
94 if (IsValid( LocalPlayer():GetActiveWeapon() )
95 and LocalPlayer():GetActiveWeapon():GetClass() == "gmod_camera") then
96 return true;
97 else
98 return false;
99 end;
100end;
101
102-- Hook into when the server sends us a variable for the local player.
103usermessage.Hook("evorp._LocalPlayerVariable", function(message)
104 local class = message:ReadChar();
105 local key = message:ReadString();
106
107 -- Create the variable which we'll store our received variable in.
108 local variable = nil;
109
110 -- Check if we can get what class of variable it is.
111 if (class == CLASS_STRING) then
112 variable = message:ReadString();
113 elseif (class == CLASS_LONG) then
114 variable = message:ReadLong();
115 elseif (class == CLASS_SHORT) then
116 variable = message:ReadShort();
117 elseif (class == CLASS_BOOL) then
118 variable = message:ReadBool();
119 elseif (class == CLASS_VECTOR) then
120 variable = message:ReadVector();
121 elseif (class == CLASS_ENTITY) then
122 variable = message:ReadEntity();
123 elseif (class == CLASS_ANGLE) then
124 variable = message:ReadAngle();
125 elseif (class == CLASS_CHAR) then
126 variable = message:ReadChar();
127 elseif (class == CLASS_FLOAT) then
128 variable = message:ReadFloat();
129 end;
130
131 -- Check if the local player is a valid entity.
132 if ( IsValid( LocalPlayer() ) ) then
133 LocalPlayer()[key] = variable;
134
135 -- Set the variable queue variable to nil so that we don't overwrite it later on.
136 GAMEMODE.variableQueue[key] = nil;
137 else
138 GAMEMODE.variableQueue[key] = variable;
139 end;
140end);
141
142function GM:PostDrawViewModel( vm, ply, weapon )
143 if weapon.UseHands or (not weapon:IsScripted()) then
144 local hands = LocalPlayer():GetHands()
145 if IsValid(hands) then hands:DrawModel() end
146 end
147end
148
149-- A function to override whether a HUD element should draw.
150function GM:HUDShouldDraw(name)
151 if (!self.playerInitialized) then
152 if (name != "CHudGMod") then return false; end;
153 else
154 if (name == "CHudHealth" or name == "CHudBattery" or name == "CHudSuitPower"
155 or name == "CHudAmmo" or name == "CHudSecondaryAmmo") then
156 return false;
157 end;
158
159 -- Return true if it's none of the others.
160 return true;
161 end;
162
163 -- Call the base class function.
164 return self.BaseClass:HUDShouldDraw(name);
165end
166
167-- A function to adjust the width of something by making it slightly more than the width of a text.
168function GM:AdjustMaximumWidth(font, text, width, addition, extra)
169 surface.SetFont(font);
170
171 -- Get the width of the text.
172 local textWidth = surface.GetTextSize( tostring( string.Replace(text, "&", "U") ) ) + (extra or 0);
173
174 -- Check if the width of the text is greater than our current width.
175 if (textWidth > width) then width = textWidth + (addition or 0); end;
176
177 -- Return the new width.
178 return width;
179end;
180
181-- A function to draw a bar with a maximum and a variable.
182function GM:DrawBar(font, x, y, width, height, color, text, maximum, variable, bar)
183 if(LocalPlayer()._NLRTimer) then
184 if(LocalPlayer()._NLRTimer) then
185 draw.WordBox( 8, ScrW() - 140, 16, "NLR Timer: "..(300 - LocalPlayer()._TimeSinceDeath), "EvoFont", Color(255,100,100,200), Color(255,255,255,255));
186 end
187 end
188
189 draw.RoundedBox( 2, x, y, width, height, Color(0, 0, 0, 200) );
190 draw.RoundedBox( 0, x + 2, y + 2, width - 4, height - 4, Color(25, 25, 25, 150) );
191 draw.RoundedBox( 0, x + 2, y + 2, math.Clamp( ( (width - 4) / maximum ) * variable, 0, width - 4 ), height - 4, color );
192
193 -- Set the font of the text to this one.
194 surface.SetFont("EvoFont3");
195
196 -- Adjust the x and y positions so that they don't screw up.
197 x = math.floor( x + (width / 2) );
198 y = math.floor(y + 1);
199
200 -- Draw text on the bar.
201 draw.DrawText(text, "EvoFont3", x + 1, y + 1, Color(0, 0, 0, 255), 1);
202 draw.DrawText(text, "EvoFont3", x, y, Color(255, 255, 255, 255), 1);
203
204 -- Check if a bar table was specified.
205 if (bar) then bar.y = bar.y - (height + 4); end;
206end;
207
208-- Get the bouncing position of the screen's center.
209function GM:GetScreenCenterBounce(bounce)
210 return ScrW() / 2, (ScrH() / 2) + 32 + ( math.sin( CurTime() ) * (bounce or 8) );
211end;
212
213-- Called when the target ID should be drawn.
214function GM:HUDDrawTargetID()
215 if ( LocalPlayer():Alive() and !LocalPlayer():GetNetworkedBool("evorp_KnockedOut") ) then
216 local trace = LocalPlayer():GetEyeTrace();
217
218 -- Set the distance that text will be completely faded to the same as the talk radius.
219 local fadeDistance = evorp.configuration["Talk Radius"];
220
221 -- Check if we hit a valid entity.
222 if ( IsValid(trace.Entity) ) then
223 local class = trace.Entity:GetClass();
224
225 -- Check if the entity is a player.
226 if ( trace.Entity:IsPlayer() or IsValid( trace.Entity:GetNetworkedEntity("evorp_Player") ) ) then
227 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
228
229 -- Get the x and y position.
230 local x, y = self:GetScreenCenterBounce();
231
232 local player = trace.Entity;
233 if IsValid( trace.Entity:GetNetworkedEntity("evorp_Player") ) then player = trace.Entity:GetNetworkedEntity("evorp_Player") end
234
235 if (player == LocalPlayer()) then return end
236 -- Check if the player is alive.
237 if ( player:Alive() and !player:GetNetworkedBool("FakeDeathing") ) then
238 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( player:GetPos() ) ) ), 0, 255);
239
240 -- Get the x and y position.
241 local x, y = self:GetScreenCenterBounce();
242
243 -- Draw the player's name.
244 --y = self:DrawInformation(player:Name(), "EvoFont", x, y, team.GetColor( player:Team() ), alpha);
245
246
247 --if ((LocalPlayer():Team() == TEAM_HOSS or LocalPlayer():Team() == TEAM_SS or LocalPlayer():Team() == TEAM_OFFICER or LocalPlayer():Team() == TEAM_COMMANDER or LocalPlayer():Team()) and trace.Entity:GetNetworkedString("evorp_Warranted") == "search") then
248 if (trace.Entity:GetNetworkedString("evorp_Warranted") == "search") then
249 y = self:DrawInformation("This person has a search warrant!", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
250 end;
251
252 if ((LocalPlayer():Team() == TEAM_OFFICER or LocalPlayer():Team() == TEAM_COMMANDER) and trace.Entity:GetNetworkedString("evorp_Warranted") == "arrest") then
253 y = self:DrawInformation("This person is wanted by the police!", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
254 end;
255
256
257 -- Check if the player is knockedout.
258 if (player:GetNetworkedBool("evorp_KnockedOut")) then
259 y = self:DrawInformation("Unconscious", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
260 end;
261
262 -- Check if the player is hostaged.
263 if (player:GetNetworkedBool("hostaged")) then
264 y = self:DrawInformation("Tied Up: USE + Left Click to untie.", "EvoFont", x, y, Color(255, 0, 0, 255), alpha);
265 end;
266
267 -- Check if the player is handcuffed.
268 if (player:GetNetworkedBool("cuffed")) then
269 y = self:DrawInformation("Handcuffed: Lockpick to unhandcuff.", "EvoFont", x, y, Color(255, 0, 0, 255), alpha);
270 end;
271
272 -- NameIC.
273 if (player:GetNetworkedString("evorp_NameIC") != "") then
274 y = self:DrawInformation("Name: "..player:GetNetworkedString("evorp_NameIC"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
275 end;
276
277 -- Description.
278 if (player:GetNetworkedString("evorp_Description") != "") then
279 y = self:DrawInformation("Description: "..player:GetNetworkedString("evorp_Description"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
280 end;
281
282 -- Description.
283 if (player:GetNetworkedString("evorp_Clan") != "") then
284 y = self:DrawInformation("Guild: "..player:GetNetworkedString("evorp_Clan"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
285 end;
286
287 if (player:GetNetworkedString("evorp_Job") != "") then
288 y = self:DrawInformation("Job: "..player:GetNetworkedString("evorp_Job"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
289 end;
290 elseif (player:GetNetworkedBool("FakeDeathing")) then
291 y = self:DrawInformation(player:Name(), "EvoFont", x, y, team.GetColor( player:Team() ), alpha);
292 if (player:GetNetworkedString("evorp_NameIC") != "") then
293 y = self:DrawInformation("Name: "..player:GetNetworkedString("evorp_NameIC"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
294 end;
295 y = self:DrawInformation("This person might still live if a paramedic reaches here in time!", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
296 end
297 elseif (trace.Entity:GetNetworkedBool("iDoor")) then
298 local name = trace.Entity:GetNetworkedString("evorp_Name");
299 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
300
301 -- Get the x and y position.
302 local x, y = self:GetScreenCenterBounce();
303 y = GAMEMODE:DrawInformation("Dynamic Door (STool)", "EvoFont", x, y, Color(150, 200, 20, 255), alpha);
304 y = GAMEMODE:DrawInformation(name, "EvoFont", x, y, Color(255, 194, 14, 255), alpha);
305 elseif (string.find( class, "prop_vehicle_jeep" )) then
306 if (LocalPlayer():InVehicle()) then return end
307 -- Calculate the alpha from the distance.
308 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
309
310 -- Get the x and y position.
311 local x, y = self:GetScreenCenterBounce();
312
313 -- Draw the information and get the new y position.
314 y = GAMEMODE:DrawInformation(trace.Entity:GetNetworkedString("evorp_Name"), "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
315
316 local eph = math.abs(math.floor(trace.Entity:GetVelocity():Length()/ 25.33));
317
318 if ( trace.Entity:GetNetworkedBool("locked") ) then
319 y = GAMEMODE:DrawInformation("Locked", "EvoFont", x, y, Color(255, 194, 14, 255), alpha);
320 else
321 y = GAMEMODE:DrawInformation("Unlocked", "EvoFont", x, y, Color(255, 194, 14, 255), alpha);
322 end
323
324 if (trace.Entity:GetNetworkedBool("evStolen")) then
325 y = GAMEMODE:DrawInformation("This car has been reported stolen!", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
326 end
327 elseif (class == "evorp_item") then
328 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
329
330 -- Get the x and y position.
331 local x, y = self:GetScreenCenterBounce();
332
333 -- Draw the information and get the new y position.
334
335 y = GAMEMODE:DrawInformation(trace.Entity:GetNetworkedString("evorp_Name"), "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
336 y = GAMEMODE:DrawInformation("Size: "..trace.Entity:GetNetworkedInt("evorp_Size"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
337 y = GAMEMODE:DrawInformation("Amount: "..trace.Entity:GetNetworkedInt("evorp_iAmount"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
338 elseif (class == "evorp_saleitem") then
339 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
340 -- Get the x and y position.
341 local x, y = self:GetScreenCenterBounce();
342 if (trace.Entity:GetNetworkedEntity("saleitem_Player") == LocalPlayer()) then
343 if (trace.Entity:GetNetworkedInt("evorp_Price") > 0) then
344 y = GAMEMODE:DrawInformation("You are selling this item for $"..trace.Entity:GetNetworkedInt("evorp_Price")..".", "EvoFont", x, y, Color(255, 0, 0, 255), alpha);
345 else
346
347 y = GAMEMODE:DrawInformation("Aim at the item and use /setprice <price> to start selling at desired price.", "EvoFont", x, y, Color(255, 0, 0, 255), alpha);
348 end
349 y = GAMEMODE:DrawInformation("Double Tap 'E' to remove sale.", "EvoFont", x, y, Color(150, 200, 20, 255), alpha);
350 else
351 y = GAMEMODE:DrawInformation("FOR SALE: "..trace.Entity:GetNetworkedString("evorp_Name"), "EvoFont", x, y, Color(255, 0, 0, 255), alpha);
352 if (trace.Entity:GetNetworkedInt("evorp_Price") == 0) then
353 y = GAMEMODE:DrawInformation("Unpriced", "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
354 else
355 y = GAMEMODE:DrawInformation("Price: $"..trace.Entity:GetNetworkedInt("evorp_Price"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
356 y = GAMEMODE:DrawInformation("Double Tap 'E' to buy.", "EvoFont", x, y, Color(150, 200, 20, 255), alpha);
357 end
358 end
359 elseif (class == "activated_ammokit") then
360 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
361
362 -- Get the x and y position.
363 local x, y = self:GetScreenCenterBounce();
364
365 -- Draw the information and get the new y position.
366 y = GAMEMODE:DrawInformation("Ammunition Kit", "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
367 y = GAMEMODE:DrawInformation("Charge: "..trace.Entity:GetNetworkedInt("charge"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
368 elseif (class == "activated_medkit") then
369 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
370 -- Get the x and y position.
371 local x, y = self:GetScreenCenterBounce();
372
373 -- Draw the information and get the new y position.
374 y = GAMEMODE:DrawInformation("Health Kit", "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
375 y = GAMEMODE:DrawInformation("Charge: "..trace.Entity:GetNetworkedInt("charge"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
376 elseif ( evorp.configuration["Contraband"][class] ) then
377 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
378
379 -- Get the x position, y position and contraband table.
380 local x, y = self:GetScreenCenterBounce();
381 local contraband = evorp.configuration["Contraband"][class];
382
383 -- Draw the information and get the new y position.
384 y = GAMEMODE:DrawInformation(contraband.name, "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
385 y = GAMEMODE:DrawInformation("Energy: "..trace.Entity:GetNetworkedInt("evorp_Energy").."/"..contraband.energy, "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
386 y = GAMEMODE:DrawInformation("Money: $"..trace.Entity:GetNetworkedInt("evorp_CMoney"), "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
387 elseif ( string.lower( class ) == "evorp_money" ) then
388 local amount = trace.Entity:GetNetworkedInt("evorp_Amount");
389
390 -- Calculate the alpha from the distance.
391 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
392
393 -- Get the x and y position.
394 local x, y = self:GetScreenCenterBounce();
395
396 -- Draw the information and get the new y position.
397 y = GAMEMODE:DrawInformation("Money", "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
398 y = GAMEMODE:DrawInformation("$"..amount, "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
399 elseif ( class == "evorp_breach" ) then
400 local health = trace.Entity:GetNetworkedInt("evorp_Health");
401
402 -- Calculate the alpha from the distance.
403 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
404
405 -- Get the x and y position.
406 local x, y = self:GetScreenCenterBounce();
407
408 -- Draw the information and get the new y position.
409 y = GAMEMODE:DrawInformation("Breach", "EvoFont", x, y, Color(214, 34, 34, 255), alpha);
410 y = GAMEMODE:DrawInformation("Health: "..health.."/100", "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
411 elseif ( class == "evorp_note" ) then
412 local text = "";
413
414 -- Loop through 1 to 10.
415 for i = 1, 10 do
416 local line = trace.Entity:GetNetworkedString("evorp_Text_"..i);
417
418 -- Check if this line exists.
419 if (line != "") then
420 line = string.Replace(line, " ' ", "'");
421 line = string.Replace(line, " : ", ":");
422
423 -- Add the line to our text.
424 text = text..line;
425 end;
426 end;
427
428 -- Create a table to store the wrapped text and then get the wrapped text.
429 local wrapped = {};
430
431 -- Wrap the text into our table.
432 evorp.chatBox.wrapText(text, "EvoFont", 256, nil, wrapped);
433
434 -- Calculate the alpha from the distance.
435 local alpha = math.Clamp(255 - ( (255 / fadeDistance) * ( LocalPlayer():GetPos():Distance( trace.Entity:GetPos() ) ) ), 0, 255);
436
437 -- Get the x and y position.
438 local x, y = self:GetScreenCenterBounce();
439
440 -- Draw the information and get the new y position.
441 y = GAMEMODE:DrawInformation("Note", "EvoFont", x, y, Color(125, 255, 50, 255), alpha);
442
443 -- Loop through our text.
444 for k, v in pairs(wrapped) do
445 y = GAMEMODE:DrawInformation(v, "EvoFont", x, y, Color(255, 255, 255, 255), alpha);
446 end;
447 end;
448 end;
449 end;
450end;
451
452-- Called when screen space effects should be rendered.
453function GM:RenderScreenspaceEffects()
454 local modify = {};
455 local color = 0.8;
456
457 -- Check if the player is low on health.
458 if (LocalPlayer():Health() < 50 and !LocalPlayer()._HideHealthEffects) then
459 if ( LocalPlayer():Alive() ) then
460 color = math.Clamp(color - ( ( 50 - LocalPlayer():Health() ) * 0.025 ), 0, color);
461 else
462 color = 0;
463 end;
464
465 -- Draw the motion blur.
466 DrawMotionBlur(math.Clamp(1 - ( ( 50 - LocalPlayer():Health() ) * 0.025 ), 0.1, 1), 1, 0);
467 end;
468
469 -- Set some color modify settings.
470 modify["$pp_colour_addr"] = 0;
471 modify["$pp_colour_addg"] = 0;
472 modify["$pp_colour_addb"] = 0;
473 modify["$pp_colour_brightness"] = 0;
474 modify["$pp_colour_contrast"] = 1;
475 modify["$pp_colour_colour"] = color;
476 modify["$pp_colour_mulr"] = 0;
477 modify["$pp_colour_mulg"] = 0;
478 modify["$pp_colour_mulb"] = 0;
479
480 -- Draw the modified color.
481 DrawColorModify(modify);
482end;
483
484-- Called when the scoreboard should be drawn.
485function GM:HUDDrawScoreBoard()
486 --self.BaseClass:HUDDrawScoreBoard(player);
487
488 -- Check if the player hasn't initialized yet.
489 if (!self.playerInitialized) then
490 draw.RoundedBox( 2, 0, 0, ScrW(), ScrH(), Color(0, 0, 0, 255) );
491
492 -- Set the font of the text to Chat Font.
493 surface.SetFont("EvoFont");
494
495 -- Get the size of the loading text.
496 local width, height = surface.GetTextSize("Loading!");
497
498 -- Get the x and y position.
499 local x, y = self:GetScreenCenterBounce();
500
501 -- Draw a rounded box for the loading text to go on.
502 draw.RoundedBox( 2, (ScrW() / 2) - (width / 2) - 8, (ScrH() / 2) - 8, width + 16, 30, Color(25, 25, 25, 255) );
503
504 -- Draw the loading text in the middle of the screen.
505 draw.DrawText("Loading!", "EvoFont", ScrW() / 2, ScrH() / 2, Color(255, 255, 255, 255), 1, 1);
506
507 -- Let them know how to rejoin if they are stuck.
508 draw.DrawText("Press 'Jump' to rejoin if you are stuck on this screen!", "EvoFont", ScrW() / 2, ScrH() / 2 + 32, Color(255, 50, 25, 255), 1, 1);
509 end;
510end;
511
512-- Draw Information.
513function GM:DrawInformation(text, font, x, y, color, alpha, left, callback, shadow)
514 surface.SetFont(font);
515
516 -- Get the width and height of the text.
517 local width, height = surface.GetTextSize(text);
518
519 -- Check if we shouldn't left align it, if we have a callback, and if we should draw a shadow.
520 if (!left) then x = x - (width / 2); end;
521 if (callback) then x, y = callback(x, y, width, height); end;
522 if (shadow) then draw.DrawText(text, font, x + 1, y + 1, Color(0, 0, 0, alpha or color.a)); end;
523
524 -- Draw the text on the player.
525 draw.DrawText(text, font, x, y, Color(color.r, color.g, color.b, alpha or color.a));
526
527 -- Return the new y position.
528 return y + height + 8;
529end;
530
531-- Draw the player's information.
532function GM:DrawPlayerInformation()
533 local width = 0;
534 local height = 0;
535
536 -- Create a table to store the text.
537 local text = {};
538 local information = {};
539
540 -- Insert the player's information into the text table.
541 table.insert( text, {"Steam ID: "..LocalPlayer():SteamID(), "icon16/application_form.png"} );
542 table.insert( text, {"Name: "..LocalPlayer():GetNetworkedString("evorp_NameIC", ""), "icon16/user.png"} );
543 table.insert( text, {"Description: "..LocalPlayer():GetNetworkedString("evorp_Description"), "icon16/table_edit.png"} );
544 table.insert( text, {"Guild: "..LocalPlayer():GetNetworkedString("evorp_Clan"), "icon16/group.png"} );
545 table.insert( text, {"Gender: "..(LocalPlayer()._Gender or "Male"), "icon16/heart.png"} );
546 table.insert( text, {"Job: "..LocalPlayer():GetNetworkedString("evorp_Job"), "icon16/brick.png"} );
547 if (evorp.team.query(LocalPlayer():Team(), "radio", "") != "R_GOV") then
548 table.insert( text, {"Salary: $"..(LocalPlayer()._Salary or 0).." - (TAX: $25)", "icon16/money_dollar.png"} );
549 else
550 table.insert( text, {"Salary: $"..(LocalPlayer()._Salary or 0).." + Tax Split", "icon16/money_dollar.png"} );
551 end
552 table.insert( text, {"Money: $"..(LocalPlayer()._Money or 0), "icon16/coins.png"} );
553 table.insert( text, {"Donator Credits: "..(LocalPlayer():GetNetworkedInt("evorp_DCredits")), "icon16/star.png"} );
554 --table.insert( text, {"Experience Points: "..(LocalPlayer():GetNetworkedInt("evorp_PointsRP")), "icon16/anchor.png"} );
555
556
557 local s = LocalPlayer():GetNetworkedInt("evorp_PlayTime"); --How many total seconds do we have
558 local totalm = math.floor( s / 60 ); --How many total minutes do we have
559 local h = math.floor( totalm / 60 ); --How many total hours do we have
560 local m = totalm - h * 60; --Minutes left
561 s = s - totalm * 60; --Seconds left
562
563 table.insert( text, {""..h.." hours, "..m.." minutes, "..s.." seconds", "icon16/time.png"} );
564
565 -- Loop through each of the text and adjust the width.
566 for k, v in pairs(text) do
567 if (string.Explode( ":", v[1] )[2] != " ") then
568 if ( v[2] ) then
569 width = self:AdjustMaximumWidth("EvoFont", v[1], width, nil, 24);
570 else
571 width = self:AdjustMaximumWidth("EvoFont", v[1], width);
572 end;
573
574 -- Insert this text into the information table.
575 table.insert(information, v);
576 end;
577 end;
578
579 -- Add 16 to the width and set the height of the box.
580 width = width + 16;
581 height = (18 * #information) + 14;
582
583 -- The position of the information box.
584 local x = 8;
585 local y = ScrH() - height - 8;
586
587 -- Draw a rounded box to put the information text onto.
588 draw.RoundedBox( 2, x, y, width, height, Color(0, 0, 0, 200) );
589
590 -- Increase the x and y position by 8.
591 x = x + 8;
592 y = y + 8;
593
594 -- Draw the information on the box.
595 for k, v in pairs(information) do
596 if ( v[2] ) then
597 self:DrawInformation(v[1], "EvoFont", x + 24, y, Color(255, 255, 255, 255), 255, true);
598
599 -- Draw the icon that respresents the text.
600 surface.SetMaterial( Material( v[2] ) );
601 surface.SetDrawColor(255, 255, 255, 255);
602 surface.DrawTexturedRect(x, y - 1, 16, 16);
603 else
604 self:DrawInformation(v[1], "EvoFont", x, y, Color(255, 255, 255, 255), 255, true);
605 end;
606
607
608 -- Increase the y position.
609 y = y + 18;
610 end;
611
612 -- Return the width and height of the box.
613 return width, height;
614end;
615
616-- Draw the health bar.
617function GM:DrawHealthBar(bar)
618 local health = math.Clamp(LocalPlayer():Health(), 0, 100);
619
620 -- Draw the health and ammo bars.
621 self:DrawBar("Default", bar.x, bar.y, bar.width, bar.height, Color(255, 50, 50, 200), "Health: "..health, 100, health, bar);
622end;
623
624function GM:DrawAmmoBar(bar)
625 local weapon = LocalPlayer():GetActiveWeapon();
626
627 -- Check if the weapon is valid.
628 if not self.ammoCount then self.ammoCount = {} end
629 if ( IsValid(weapon) ) then
630 if ( !self.ammoCount[ weapon:GetClass() ] ) then
631 self.ammoCount[ weapon:GetClass() ] = weapon:Clip1();
632 end;
633
634 -- Check if the weapon's first clip is bigger than the amount we have stored for clip one.
635 if ( weapon:Clip1() > self.ammoCount[ weapon:GetClass() ] ) then
636 self.ammoCount[ weapon:GetClass() ] = weapon:Clip1();
637 end;
638
639 -- Get the amount of ammo the weapon has in it's first clip.
640 local clipOne = weapon:Clip1();
641 local clipMaximum = self.ammoCount[ weapon:GetClass() ];
642 local clipAmount = LocalPlayer():GetAmmoCount( weapon:GetPrimaryAmmoType() );
643
644 -- Check if the maximum clip if above 0.
645 if (clipMaximum > 0) then
646 self:DrawBar("Default", bar.x, bar.y, bar.width, bar.height, Color(100, 100, 255, 200), "Ammo: "..clipOne.." ["..clipAmount.."]", clipMaximum, clipOne, bar);
647 end;
648 end;
649end;
650
651-- Called when the bottom bars should be drawn.
652function GM:DrawBottomBars(bar) end;
653
654-- Called when the top text should be drawn.
655function GM:DrawTopText(text) end;
656
657-- Called every time the HUD should be painted.
658function GM:HUDPaint()
659 if not (self.playerInitialized) then return end
660 if ( !self:IsUsingCamera() ) then
661
662 --local x = "Location: ";
663 --if(LocalPlayer()._LastLocation) then x = x..LocalPlayer()._LastLocation end
664
665 --self:DrawInformation(x , "EvoFont", ScrW(), ScrH(), Color(255, 50, 25, 255), 255, true, function(x, y, width, height)
666 -- return x - width - 22, y - height - 22;
667 --end);
668
669 self:DrawInformation(evorp.configuration["Website URL"], "EvoFont", ScrW(), ScrH(), Color(255, 255, 255, 255), 255, true, function(x, y, width, height)
670 return x - width - 8, y - height - 8;
671 end);
672
673 -- Get the size of the information box.
674 local width, height = self:DrawPlayerInformation();
675
676 -- A table to store the bar and text information.
677 local bar = {x = width + 16, y = ScrH() - 24, width = 144, height = 16};
678 local text = {x = ScrW(), y = 8};
679
680 -- Draw the player's health and ammo bars.
681 self:DrawHealthBar(bar);
682 self:DrawAmmoBar(bar);
683
684 -- Call a hook to let plugins know that we're now drawing bars and text.
685 hook.Call("DrawBottomBars", GAMEMODE, bar);
686 hook.Call("DrawTopText", GAMEMODE, text);
687
688 if (LocalPlayer():InVehicle() and LocalPlayer():GetVehicle():GetClass() == "prop_vehicle_jeep") then
689 local fuel = LocalPlayer():GetVehicle():GetNetworkedInt("fuel");
690 self:DrawBar("Default", bar.x, bar.y, bar.width, bar.height, Color(109, 130, 247, 200), "Fuel: "..fuel, 100, fuel, bar);
691 end
692
693 -- Set the position of the chat box.
694 evorp.chatBox.position = {x = 8, y = ScrH() - (height + 40)};
695
696 -- Get the player's next spawn time.
697 local _NextSpawnTime = LocalPlayer()._NextSpawnTime or 0;
698
699 if (LocalPlayer():GetNetworkedBool("FakeDeathing"))then
700 local secondsleft = math.floor(LocalPlayer():GetNetworkedInt("FakeDeathTimer") - CurTime())
701 local sptime = evorp.configuration["Spawn Time"];
702 if (LocalPlayer():GetNetworkedBool("evorp_Donator")) then sptime = evorp.configuration["Spawn Time"] / 2; end
703 local sleft =math.floor((LocalPlayer():GetNetworkedInt("FakeDeathTimer") - 120 + sptime) - CurTime());
704 local text = "A paramedic can revive you in the next "..secondsleft.." seconds or you can wait "..sleft.." seconds and click to give up on life."
705 if (sleft < 1) then text = "A paramedic can revive you in the next "..secondsleft.." seconds or you can click to give up on life." end
706 self:DrawInformation(text, "EvoFont", ScrW() / 2, (ScrH() / 2) + 16, Color(255, 255, 255, 255), 255);
707 else
708
709 -- Check if the next spawn time is greater than the current time.
710 if ( !LocalPlayer():Alive() and _NextSpawnTime > CurTime()) then
711 local seconds = math.floor( _NextSpawnTime - CurTime() );
712
713 -- Check if the amount of seconds is greater than 0.
714 if (seconds > 0) then
715 self:DrawInformation("You must wait "..seconds.." second(s) to spawn.", "EvoFont", ScrW() / 2, (ScrH() / 2) + 16, Color(255, 255, 255, 255), 255);
716 end;
717 elseif ( LocalPlayer():GetNetworkedBool("evorp_KnockedOut") ) then
718 local _BecomeConsciousTime = LocalPlayer()._BecomeConsciousTime or 0;
719
720 -- Check if the unknock out time is greater than the current time.
721 if ( _BecomeConsciousTime > CurTime() ) then
722 local seconds = math.floor( _BecomeConsciousTime - CurTime() );
723
724 -- Check if the amount of seconds is greater than 0.
725 if (seconds > 0) then
726 self:DrawInformation("You will become conscious in "..seconds.." second(s).", "EvoFont", ScrW() / 2, (ScrH() / 2) + 16, Color(255, 255, 255, 255), 255);
727 end;
728 end;
729 end;
730 end
731 -- Get whether the player is stuck in the world.
732 local stuckInWorld = LocalPlayer()._StuckInWorld;
733
734 -- Check whether the player is stuck in the world.
735 if (stuckInWorld) then
736 draw.DrawText("You are stuck! Press 'Jump' to get unstuck.", "EvoFont", ScrW() / 2, (ScrH() / 2) - 16, Color(255, 50, 25, 255), 1, 1);
737 end;
738
739 -- Loop through every player.
740 for k, v in pairs( g_Player.GetAll() ) do hook.Call("PlayerHUDPaint", GAMEMODE, v); end;
741
742 -- Call the base class function.
743 self.BaseClass:HUDPaint();
744 end;
745end;
746
747-- Called to check if a player can use voice.
748function GM:PlayerCanVoice(player)
749 if ( player:Alive() and player:GetPos():Distance( LocalPlayer():GetPos() ) <= evorp.configuration["Talk Radius"]) then
750 return true;
751 else
752 return false;
753 end;
754end;
755
756-- Called every frame.
757function GM:Think()
758 if ( evorp.configuration["Local Voice"] ) then
759 for k, v in pairs( player.GetAll() ) do
760 if ( hook.Call("PlayerCanVoice", GAMEMODE, v) ) then
761 if ( v:IsMuted() ) then v:SetMuted(); end;
762 else
763 if ( !v:IsMuted() ) then v:SetMuted(); end;
764 end;
765 end;
766 end;
767 Control()
768 -- Call the base class function.
769 return self.BaseClass:Think();
770end;
771
772-- Called when a player begins typing.
773function GM:StartChat(team) return true; end;
774
775-- Called when a player says something or a message is received from the server.
776function GM:ChatText(index, name, text, filter)
777 if ( filter == "none" or filter == "joinleave" or (filter == "chat" and name == "Console") ) then
778 evorp.chatBox.chatText(index, name, text, filter);
779 end;
780
781 -- Return true because we handle this our own way.
782 return true;
783end;
784
785-- Hook into when the player has initialized.
786usermessage.Hook("evorp.player.initialized", function() GAMEMODE.playerInitialized = true; end);
787
788function DrawDeathMessage()
789 -- Frame
790 local LDFrame = vgui.Create( "DFrame" )
791 LDFrame:SetPos( ScrW() / 2 - 250,ScrH() / 2 )
792 LDFrame:SetSize( 518, 200 )
793 LDFrame:SetTitle( "New Life Rule - NLR" )
794 LDFrame:SetVisible( true )
795 LDFrame:SetDraggable( true )
796 LDFrame:ShowCloseButton( false )
797 LDFrame:SetBackgroundBlur( true )
798 LDFrame:MakePopup()
799
800 local PaintPanel = vgui.Create( "DPanel", LDFrame )
801
802 -- Black box
803 PaintPanel:SetPos( 5, 25 )
804 PaintPanel:SetSize( 508, 170 )
805 PaintPanel.Paint = function()
806 surface.SetDrawColor( 50, 50, 50, 255 )
807 surface.DrawRect( 0, 0, PaintPanel:GetWide(), PaintPanel:GetTall() )
808 end
809
810 -- Text
811 local Dlabel = vgui.Create("DLabel", PaintPanel);
812 Dlabel:SetText("Your old life ended. You now only remember your friends, job and home. You do not\nremember where you died or how you died...\n\nThese rules now apply:\n1. Do not return to the place you died for the next 5 minutes.\n2. Do not kill the player that killed you on the basis of revenge.\n");
813 Dlabel:SetSize(490, 120);
814 Dlabel:SetPos(10, 10);
815
816 -- Buttons
817 timer.Simple(5, function()
818 local OKButton = vgui.Create("DButton", PaintPanel);
819 OKButton:SetText("Agree");
820 OKButton:SetSize(100, 30);
821 OKButton:SetPos(10, 130);
822 OKButton.DoClick = function()
823 LDFrame:Close()
824 LocalPlayer()._TimeSinceDeath = 0;
825 LocalPlayer()._NLRTimer = true;
826 timer.Start("NLR");
827 end
828 local NOButton = vgui.Create("DButton", PaintPanel);
829 NOButton:SetText("Disagree");
830 NOButton:SetSize(100, 30);
831 NOButton:SetPos(140, 130);
832 NOButton.DoClick = function()
833 RunConsoleCommand("disconnect")
834 end
835 end)
836end
837
838concommand.Add("DrawDeathMsg", DrawDeathMessage)
839
840timer.Create( "NLR", 1, 0, function()
841 if not (LocalPlayer()._NLRTimer) then
842 timer.Stop("NLR");
843 else
844 LocalPlayer()._TimeSinceDeath = LocalPlayer()._TimeSinceDeath + 1;
845 if(LocalPlayer()._TimeSinceDeath > 299) then
846 LocalPlayer()._NLRTimer = false;
847 end
848 end
849end)
850
851function OnContextMenuOpen()
852 return true;
853end
854hook.Add( "ContextMenuOpen", "OnContextMenuOpen", OnContextMenuOpen )
855
856function Control()
857 if not (LocalPlayer()._NextControl) then LocalPlayer()._NextControl = 0; end
858 if not (LocalPlayer()._NextControl <= CurTime()) then return end
859 if (input.IsKeyDown(KEY_F4) and !evorp.chatBox.derma.panel:IsVisible()) then
860 LocalPlayer()._NextControl = CurTime() + .2;
861 RunConsoleCommand("ExQuickToggle");
862 end
863 if (input.IsKeyDown(KEY_LCONTROL)) and (input.IsKeyDown(KEY_TAB)) then
864
865 LocalPlayer()._NextControl = CurTime() + .2;
866 TP:RegQuickMenu();
867 --[[
868 if (ctp:IsEnabled()) then
869 ctp:Disable();
870 else
871 if (LocalPlayer():InVehicle()) then
872 ctp:LoadCVarPreset("Vehicle")
873 else
874 ctp:LoadCVarPreset("Third Person")
875 end
876
877 ctp:Enable();
878 end]]
879 end
880 if (LocalPlayer():InVehicle() and !evorp.chatBox.derma.panel:IsVisible()) then
881 if (input.IsKeyDown(KEY_C)) and (input.IsKeyDown(KEY_LCONTROL)) then
882 LocalPlayer()._NextControl = CurTime() + .2;
883 RunConsoleCommand("ToggleCruise")
884 elseif (input.IsKeyDown(KEY_H)) and (input.IsKeyDown(KEY_LCONTROL)) then
885 LocalPlayer()._NextControl = CurTime() + .2;
886 RunConsoleCommand("HonkSiren")
887 elseif (input.IsKeyDown(KEY_H)) then
888 LocalPlayer()._NextControl = CurTime() + .2;
889 RunConsoleCommand("HonkHorn")
890 elseif (input.IsKeyDown(KEY_LSHIFT)) then
891 LocalPlayer()._NextControl = CurTime() + .2;
892 RunConsoleCommand("hydr")
893 end
894 end
895end
896
897--[[
898timer.Create("LocationUpdater", 1, 0, function()
899 if not (IsValid(LocalPlayer())) then return end
900 if not (LocalPlayer()._LastLocation) then LocalPlayer()._LastLocation = "UNKNOWN" end
901 if string.lower(game.GetMap()) == "rp_evocity_v33x" then
902 if (LocalPlayer():GetPos():Distance(Vector( -7006, -8928, 72 )) < 128) then
903 LocalPlayer()._LastLocation = "Nexus";
904 elseif (LocalPlayer():GetPos():Distance(Vector( -7351, -9582, 460 )) < 128) then
905 LocalPlayer()._LastLocation = "Nexus First Floor";
906 elseif (LocalPlayer():GetPos():Distance(Vector( -7349, -9574, 1735 )) < 128) then
907 LocalPlayer()._LastLocation = "Nexus Second Floor";
908 elseif (LocalPlayer():GetPos():Distance(Vector( -7337, -9592, 3791 )) < 128) then
909 LocalPlayer()._LastLocation = "Nexus Third Floor";
910 elseif (LocalPlayer():GetPos():Distance(Vector( -7558, -6300, 72 )) < 128) then
911 LocalPlayer()._LastLocation = "AM/PM";
912 end
913 end
914end);
915]]
916
917ScoreBoard = nil
918
919timer.Simple( 1.5, function()
920
921 function GAMEMODE:CreateScoreboard()
922
923 if ( ScoreBoard ) then
924
925 ScoreBoard:Remove()
926 ScoreBoard = nil
927
928 end
929
930 ScoreBoard = vgui.Create( "ScoreBoard" )
931
932 return true
933
934 end
935
936 function GAMEMODE:ScoreboardShow()
937
938 if not ScoreBoard then
939 self:CreateScoreboard()
940 end
941
942 GAMEMODE.ShowScoreboard = true
943 gui.EnableScreenClicker( true )
944
945 ScoreBoard:SetVisible( true )
946 ScoreBoard:UpdateScoreboard( true )
947
948 return true
949
950 end
951
952 function GAMEMODE:ScoreboardHide()
953
954 GAMEMODE.ShowScoreboard = false
955 gui.EnableScreenClicker( false )
956
957 ScoreBoard:SetVisible( false )
958
959 return true
960
961 end
962
963end )
964
965local tblFonts = { }
966
967tblFonts["HUDNumber5"] = {
968 font = "Museo Sans 500",
969 size = 45,
970 weight = 900,
971}
972
973tblFonts["DefaultBold"] = {
974 font = "Tahoma",
975 size = 13,
976 weight = 1000,
977}
978
979
980for k,v in SortedPairs( tblFonts ) do
981 surface.CreateFont( k, tblFonts[k] );
982end
983
984TP = {}
985
986TP.config = TP.config or {}
987TP.config.distance = TP.config.distance or 0
988TP.config.sensitive = TP.config.sensitive or .025
989TP.config.changedir = TP.config.changedir or false
990TP.config.changedir = TP.config.classic or false
991TP.config.maxdistance = 100
992
993
994local mc = math.Clamp
995local playerMeta = FindMetaTable("Player")
996local GetVelocity = FindMetaTable("Entity").GetVelocity
997local Length2D = FindMetaTable("Vector").Length2D
998
999local function ffr()
1000 return mc(FrameTime(), 1/60,1)
1001end
1002
1003local nobob = {
1004 "weapon_physgun",
1005 "gmod_tool",
1006}
1007
1008function playerMeta:CanOverrideView()
1009 return (
1010 self:IsValid() && // If player is available.
1011 self:Alive() && // If player is alive.
1012 !self:GetNetworkedBool("evorp_KnockedOut") && // If player is not ragdolled/falloverd
1013 TP.config.distance > 0 // If player enabled the thirdperson.
1014 )
1015end
1016
1017function TP:DistPerc()
1018 return mc(self.config.distance / self.config.maxdistance, 0, 1)
1019end
1020
1021
1022function TP:RegQuickMenu()
1023 if (TP.config.distance != 100) then
1024 TP.config.distance = 100;
1025 else
1026 TP.config.distance = 0;
1027 end
1028 --[[
1029 local DPanel = vgui.Create( "DFrame" )
1030 DPanel:SetPos( 10, 30 ) -- Set the position of the panel
1031 DPanel:SetSize( 200, 200 ) -- Set the size of the panel
1032 DPanel:SetVisible( true )
1033 DPanel:SetDraggable( true )
1034 DPanel:ShowCloseButton( true )
1035 TP:CreateQuickMenu(DPanel)
1036 gui.EnableScreenClicker(true)
1037 ]]
1038end
1039
1040hook.Add("HUDShouldDraw", "HideOldChatBox", function( name )
1041 if name == "CHudChat" then return false end
1042end)
1043
1044
1045function GM:ShouldDrawLocalPlayer()
1046 if ( LocalPlayer():Alive()) then
1047 if ( LocalPlayer():GetNetworkedBool("evorp_KnockedOut") ) then
1048 return true
1049 end
1050
1051 if TP.config.distance > 0 then
1052 return true
1053 end
1054 end
1055 return false
1056end
1057
1058local class
1059local camang = Angle(0, 0, 0)
1060local addpos = Vector(0, 0, 0)
1061local finaladdpos = addpos
1062local finalang = camang
1063local camx, camy = 0, 0
1064
1065local lastaim = Angle(0, 0, 0)
1066if LocalPlayer() and LocalPlayer():IsValid() and LocalPlayer().character then
1067 lastaim = LocalPlayer():EyeAngles()
1068 camang = LocalPlayer():EyeAngles()
1069end
1070
1071local movetrig = false
1072
1073
1074function GM:CreateMove( cmd )
1075 local ply = LocalPlayer()
1076 local vel = math.floor( Length2D(GetVelocity(ply)) )
1077
1078 if ply:CanOverrideView() and !TP.config.classic then
1079 if (vel < 5) then
1080 cmd:SetViewAngles(lastaim)
1081 movetrig = true
1082 else
1083 if movetrig then
1084 cmd:SetViewAngles(camang)
1085 movetrig = false
1086 end
1087 lastaim = ply:EyeAngles()
1088 end
1089 end
1090end
1091
1092function GM:InputMouseApply( cmd, x, y, ang ) // :C
1093 local ply = LocalPlayer()
1094 local vel = math.floor(Length2D(GetVelocity(ply)))
1095
1096 camx = x * -TP.config.sensitive
1097 camy = y * TP.config.sensitive
1098
1099 if (vel < 5 and !TP.config.classic) then
1100 camang = camang + Angle(camy, camx, 0)
1101 camang.p = mc(camang.p, -90, 90)
1102 addpos = camang:Up()*math.abs(camang.p*.1)
1103 end
1104end
1105
1106local nodesync = false
1107function GM:CalcView( ply, pos, ang, fov )
1108 local rt = RealTime()
1109 local ft = FrameTime()
1110 local vel = math.floor( Length2D(GetVelocity(ply)) )
1111 local runspeed = ply:GetRunSpeed()
1112 local walkspeed = ply:GetWalkSpeed()
1113 local wep = ply:GetActiveWeapon()
1114 if wep and wep:IsValid() then
1115 class = ply:GetActiveWeapon():GetClass()
1116 else
1117 class = ""
1118 end
1119 local v = {}
1120 if
1121 ply:CanOverrideView()
1122 then
1123
1124 if !(vel < 5) or TP.config.classic then
1125 camang = ang
1126 addpos = ang:Up()*mc(TP:DistPerc()*TP.config.distance*.3, 10, TP.config.maxdistance)
1127 --[[
1128 if ply:WepRaised() then
1129 local difac = 1
1130 if TP.config.changedir then
1131 difac = -1
1132 end
1133
1134 addpos = addpos + difac * ang:Right()*mc(TP:DistPerc()*TP.config.distance*.8, 20, TP.config.maxdistance)
1135 end
1136 ]]
1137 end
1138
1139 local data = {}
1140 data.start = pos
1141 data.endpos = data.start - finalang:Forward() * TP.config.distance + finaladdpos
1142 data.filter = ply
1143 local trace = util.TraceLine(data)
1144
1145 // The reson of Clamping Frametime to 1/60(60 fps): Because Lerp getting slow as fuck when youre having too good fps.
1146 // Also Lerp gets freak out when player is getting really low fps.
1147 // Upgrade your fucking computer then.
1148 if FrameTime() < 1/10 then
1149 finalang = LerpAngle(ffr()*15, finalang, camang)
1150 finaladdpos = LerpVector(ffr()*15, finaladdpos, addpos)
1151 else
1152 finalang = camang
1153 finaladdpos = addpos
1154 end
1155
1156 v.angles = finalang
1157 v.angles.r = 0
1158 v.origin = trace.HitPos + trace.HitNormal * 10
1159 v.fov = fov
1160
1161 return self.BaseClass:CalcView(ply, v.origin, v.angles, v.fov)
1162
1163 end
1164
1165end