· 6 years ago · Feb 27, 2020, 06:02 PM
1local font_main = draw.CreateFont ("Tahoma Bold", 20, 20)
2local font_main_small = draw.CreateFont ("Tahoma Bold", 13, 13)
3
4-- Skript --------
5local cur_scriptname = GetScriptName ()
6local cur_version = "1.3"
7local git_version = "https://raw.githubusercontent.com/itisluiz/aimware_quickpeek/master/version.txt"
8local git_repository = "https://raw.githubusercontent.com/itisluiz/aimware_quickpeek/master/quickpeek.lua"
9------------------ ------------------.
10
11- UI-Elemente -
12local ref_vis_msc_assistance = gui.Reference ("VISUALS", "MISC", "Assistance")
13
14gui.Combobox (ref_vis_msc_assistance, "msc_quickpeek_indicator", "Quick Peek Indication", "Off", "On World", "On HUD", "On Both")
15gui.Combobox (ref_vis_msc_assistance, "msc_quickpeek_indicatordetail", "Quick Peek Indication Style", "Fancy", "Simplified")
16
17local ref_rbot_weapon =
18{
19 ["shared"] = gui.Reference ("RAGE", "WEAPON", "SHARED", "Accuracy"),
20 ["Pistole"] = gui.Reference ("RAGE", "WEAPON", "PISTOL", "Accuracy"),
21 ["revolver"] = gui.Reference ("RAGE", "WEAPON", "REVOLVER", "Accuracy"),
22 ["smg"] = gui.Reference ("RAGE", "WEAPON", "SMG", "Accuracy"),
23 ["Gewehr"] = gui.Reference ("RAGE", "WAFFE", "GEWEHR", "Genauigkeit"),
24 ["Schrotflinte"] = gui.Reference ("RAGE", "WEAPON", "SHOTGUN", "Accuracy"),
25 ["Scout"] = gui.Reference ("RAGE", "WEAPON", "SCOUT", "Accuracy"),
26 ["autosniper"] = gui.Reference ("RAGE", "WEAPON", "A. SNIPER", "Accuracy"),
27 ["sniper"] = gui.Reference ("RAGE", "WEAPON", "SNIPER", "Accuracy"),
28 ["lmg"] = gui.Reference ("RAGE", "WEAPON", "LMG", "Accuracy");
29}}
30
31für Index Referenz in Paaren (ref_rbot_weapon) tun
32 gui.Keybox (Referenz, string.format ("rbot_% s_quickpeek_key", Index), "Quick Peek Key", 0)
33 gui.Slider (Referenz, string.format ("rbot_% s_quickpeek_returnaftershots", Index), "Return After X Shots", 1, 1, 15)
34 gui.Checkbox (Referenz, string.format ("rbot_% s_quickpeek_killreturn", Index), "Return on Kill", 1)
35 gui.Checkbox (Referenz, string.format ("rbot_% s_quickpeek_knife", Index), "Quick Peek Switch to Knife", 1)
36Ende
37------------------ ------------------.
38
39-- Auf Updates prüfen
40lokale Funktion git_update ()
41 wenn cur_version ~ = http.Get (git_version) dann
42 local this_script = file.Open (cur_scriptname, "w")
43 this_script: Write (http.Get (git_repository))
44 this_script: Close ()
45 print ("[Lua Scripting]" .. cur_scriptname .. "hat sich von Version" .. cur_version .. "auf" .. http.Get (git_version)) aktualisiert.)
46 print ("[Lua Scripting] Bitte neu laden" .. cur_scriptname)
47 sonst
48 print ("[Lua Scripting]" .. cur_scriptname .. "ist aktuell")
49 Ende
50Ende
51
52lokale Funktion drawCircle (Position, Radius) - Behält diese Funktion bei, da die Kreise der neuen API keine 3D-Kreise zeichnen können
53
54 für Grad = 1, 360, 1 tun
55 lokal thisPoint = nil;
56 lokaler lastPoint = nil;
57
58 wenn Position [3] == null dann
59 thisPoint = {Position [1] + math.sin (math.rad (Grad)) * Radius, Position [2] + math.cos (math.rad (Grad)) * Radius};
60 lastPoint = {Position [1] + math.sin (math.rad (Grad - 1)) * Radius, Position [2] + math.cos (math.rad (Grad - 1)) * Radius};
61 sonst
62 thisPoint = {client.WorldToScreen (Position [1] + math.sin (math.rad (Grad)) * Radius, Position [2] + math.cos (math.rad (Grad)) * Radius, Position [3]) };
63 lastPoint = {client.WorldToScreen (Position [1] + math.sin (math.rad (Grad - 1)) * Radius, Position [2] + math.cos (math.rad (Grad - 1)) * Radius, Position [3])};
64 Ende
65
66 wenn thisPoint [1] ~ = nil und thisPoint [2] ~ = nil und lastPoint [1] ~ = nil und lastPoint [2] ~ = nil dann
67 draw.Line (thisPoint [1], thisPoint [2], lastPoint [1], lastPoint [2]);
68 Ende
69
70 Ende
71
72Ende
73
74lokale Funktion ActiveWeaponInfo (Entität)
75
76 local ent_weapon = Entität: GetPropEntity ("m_hActiveWeapon")
77
78 wenn ent_weapon == nil dann
79 gib null zurück
80 Ende
81
82 local str_weapon = ent_weapon: GetName ()
83
84 wenn string.find (str_weapon, "revolver") dann
85 Rückgabe "Revolver", 2
86 Ende
87 wenn string.find (str_weapon, "ssg08") dann
88 return "scout", 1
89 Ende
90 wenn string.find (str_weapon, "awp") dann
91 Rückgabe "Scharfschütze", 1
92 Ende
93 wenn string.find (str_weapon, "scar20") oder string.find (str_weapon, "g3sg1") dann
94 Rückgabe "Autosniper", 1
95 Ende
96
97 local type_weapon = Entität: GetWeaponType ()
98
99 wenn type_weapon == 0 dann
100 gib null zurück
101 Ende
102
103 wenn type_weapon == 1 dann
104 "Pistole" zurückgeben, 2
105 Ende
106 wenn type_weapon == 2 dann
107 return "smg", 1
108 Ende
109 wenn type_weapon == 3 dann
110 Rückgabe "Gewehr", 1
111 Ende
112 wenn type_weapon == 4 dann
113 Rückgabe "Schrotflinte", 1
114 Ende
115 wenn type_weapon == 6 dann
116 return "lmg", 1
117 Ende
118
119 gib null zurück
120Ende
121
122-- Globale Variablen ---
123local msc_peekReturning = false
124local msc_quickPeeking = false
125local msc_peekCompleted = false
126
127local msc_shotsFired = 0
128local msc_hasKilled = false
129
130local pos_peekOrigin = {}
131local wpninfo_peek = nil
132local startwpn_peek = nil
133local curwpn_peek = nil
134
135local cacheArray =
136{
137 {"Autostop", 0},
138 {"autostop_key", 0}
139}}
140-----------------------
141
142lokale Funktion ResetPeek ()
143 wenn msc_quickPeeking oder msc_peekReturning oder msc_peekCompleted dann
144 msc_quickPeeking = false
145 msc_peekReturning = false
146 msc_peekCompleted = false
147 msc_shotsFired = 0
148 msc_hasKilled = false
149 msc_hasEmptied = false
150
151 für i = 1, #cacheArray do
152 gui.SetValue (string.format ("rbot_% s_% s", wpninfo_peek [1], cacheArray [i] [1]), cacheArray [i] [2])
153 Ende
154
155 wpninfo_peek = nil
156 startwpn_peek = nil
157 Ende
158Ende
159
160lokale Funktion onFrameMain ()
161
162 - Runde Schieberegler
163 für Index Referenz in Paaren (ref_rbot_weapon) tun
164 wenn gui.GetValue (string.format ("rbot_% s_quickpeek_returnaftershots", Index))% 1> 0 dann
165 gui.SetValue (string.format ("rbot_% s_quickpeek_returnaftershots", Index), math.floor (gui.GetValue (string.format ("rbot_% s_quickpeek_returnaftershots", Index)))
166 Ende
167 Ende
168
169 local LocalPlayer = entity.GetLocalPlayer ()
170
171 - Lokaler Spieler null und lebendig prüfen
172 wenn LocalPlayer == nil oder nicht LocalPlayer: IsAlive () dann
173 ResetPeek ()
174 Rückkehr
175 Ende
176
177 local pos_LocalPlayer = {LocalPlayer: GetAbsOrigin ()}
178
179 - Wenn die Waffe kein Messer ist
180 wenn LocalPlayer: GetWeaponType () ~ = 0 dann
181 wpninfo_peek = {ActiveWeaponInfo (LocalPlayer)}
182 curwpn_peek = LocalPlayer: GetWeaponID ()
183 Ende
184
185 - Überprüfen Sie, ob das Array null ist
186 wenn wpninfo_peek == nil dann
187 Rückkehr
188 Ende
189
190 - Überprüfen Sie, ob die Waffe null ist
191 wenn wpninfo_peek [1] == nil dann
192 Rückkehr
193 Ende
194
195 - Bei gemeinsamer Waffenkonfiguration
196 wenn gui.GetValue ("rbot_sharedweaponcfg") dann
197 wpninfo_peek [1] = "geteilt"
198 Ende
199
200 - Überprüfen Sie, ob der Schlüssel gesetzt ist
201 if gui.GetValue (string.format ("rbot_% s_quickpeek_key", wpninfo_peek [1])) == nil oder gui.GetValue (string.format ("rbot_% s_quickpeek_key", wpninfo_peek [1])) <= 0 dann
202 Rückkehr
203 Ende
204
205 if input.IsButtonDown (gui.GetValue (string.format ("rbot_% s_quickpeek_key", wpninfo_peek [1]))) und (startwpn_peek == curwpn_peek oder startwpn_peek == nil) dann
206
207 wenn nicht msc_quickPeeking und LocalPlayer: GetWeaponType () ~ = 0 dann
208 msc_quickPeeking = true
209 startwpn_peek = curwpn_peek
210 pos_peekOrigin = pos_LocalPlayer
211 msc_shotsFired = 0
212 msc_hasKilled = false
213 msc_hasEmptied = false
214
215 für i = 1, #cacheArray do
216 cacheArray [i] [2] = gui.GetValue (string.format ("rbot_% s_% s", wpninfo_peek [1], cacheArray [i] [1]))
217 Ende
218
219 gui.SetValue (string.format ("rbot_% s_% s", wpninfo_peek [1], cacheArray [1] [1]), 1)
220 gui.SetValue (string.format ("rbot_% s_% s", wpninfo_peek [1], cacheArray [2] [1]), 0)
221 elseif nicht msc_quickPeeking und LocalPlayer: GetWeaponType () == 0 dann
222 Rückkehr
223 Ende
224
225 wenn msc_peekCompleted dann
226 msc_peekCompleted = false
227 msc_shotsFired = 0
228 msc_hasKilled = false
229
230 if gui.GetValue (string.format ("rbot_% s_quickpeek_knife", wpninfo_peek [1])) dann
231 client.Command ("slot" .. wpninfo_peek [2], true)
232 Ende
233 Ende
234
235 if ((msc_shotsFired> = gui.GetValue (string.format ("rbot_% s_quickpeek_returnaftershots", wpninfo_peek [1]))) oder (msc_hasKilled und gui.GetValue (string.format ("rbot_% s_quickpeek_pret")) )) oder msc_hasEmptied)
236 und dann nicht msc_peekReturning
237 msc_peekReturning = true
238 wenn msc_hasEmptied dann
239 msc_hasEmptied = false
240 Ende
241
242 if gui.GetValue (string.format ("rbot_% s_quickpeek_knife", wpninfo_peek [1])) dann
243 client.Command ("slot3", true)
244 Ende
245 Ende
246
247 local world_forward = {vector.Subtract (pos_peekOrigin, pos_LocalPlayer)}
248 local world_angles = {vector.Angles (world_forward)}
249
250 local world_linestart = {pos_peekOrigin [1] - 9 * math.cos (math.rad (world_angles [2])), pos_peekOrigin [2] - 9 * math.sin (math.rad (world_angles [2])), pos_peekOrigin [ 3]}
251 local world_lineend = {pos_LocalPlayer [1] + 5 * math.cos (math.rad (world_angles [2])), pos_LocalPlayer [2] + 5 * math.sin (math.rad (world_angles [2])), pos_LocalPlayer [ 3]}
252
253 local wts_peekOrigin = {client.WorldToScreen (pos_peekOrigin [1], pos_peekOrigin [2], pos_peekOrigin [3])}
254 local wts_peekOriginText = {client.WorldToScreen (pos_peekOrigin [1], pos_peekOrigin [2], pos_peekOrigin [3] + 20)}
255 local wts_LocalPlayer = {client.WorldToScreen (pos_LocalPlayer [1], pos_LocalPlayer [2], pos_LocalPlayer [3])}
256
257 local peek_distance = math.floor (vector.Distance (pos_peekOrigin, pos_LocalPlayer) + 0.5)
258 local str_Indicator = "Quick Peeking:" .. peek_distance .. "Einheiten"
259
260 lokaler size_strIndicator
261
262 wenn msc_peekReturning dann
263 str_Indicator = "Schnellrückgabe:" .. peek_distance .. "Einheiten"
264 Ende
265
266 if (gui.GetValue ("msc_quickpeek_indicator") == 1 oder gui.GetValue ("msc_quickpeek_indicator") == 3) und (wts_peekOrigin [1] ~ = nil und wts_peekOriginText [1] ~ = nil und wts_Locall = 1 nil) dann
267 draw.SetFont (font_main_small)
268 size_strIndicator = {draw.GetTextSize (str_Indicator)}
269 draw.Color (gui.GetValue ("clr_gui_window_header_tab2"))
270 wenn gui.GetValue ("msc_quickpeek_indicatordetail") == 0 dann
271 drawCircle (pos_peekOrigin, 10)
272 drawCircle (pos_peekOrigin, 8)
273 drawCircle (pos_LocalPlayer, 6)
274 drawCircle (pos_LocalPlayer, 4)
275 draw.Color (255, 255, 255, 255)
276 drawCircle (pos_peekOrigin, 9)
277 drawCircle (pos_LocalPlayer, 5)
278 Ende
279 draw.Color (255, 255, 255, 255)
280 draw.TextShadow (wts_peekOriginText [1] - size_strIndicator [1] / 2, wts_peekOriginText [2], str_Indicator)
281
282 local wts_linestart = {client.WorldToScreen (world_linestart [1], world_linestart [2], world_linestart [3])}
283 local wts_lineend = {client.WorldToScreen (world_lineend [1], world_lineend [2], world_lineend [3])}
284
285 wenn msc_peekReturning dann
286 draw.Color (gui.GetValue ("clr_gui_window_header_tab2"))
287 sonst
288 draw.Color (255, 255, 255, 255)
289 Ende
290
291 wenn wts_linestart [1] ~ = nil und wts_lineend [1] ~ = nil und peek_distance> 15 dann
292 draw.Line (wts_linestart [1], wts_linestart [2], wts_lineend [1], wts_lineend [2])
293 Ende
294
295 Ende
296
297 wenn gui.GetValue ("msc_quickpeek_indicator")> = 2 dann
298 local width_screen, height_screen = draw.GetScreenSize ()
299 draw.SetFont (font_main)
300 size_strIndicator = {draw.GetTextSize (str_Indicator)}
301
302 wenn gui.GetValue ("msc_quickpeek_indicatordetail") == 0 dann
303 draw.Color (0, 0, 0, 125)
304 draw.FilledRect (width_screen / 2 - size_strIndicator [1] / 2, height_screen * 0,95 - size_strIndicator [2] / 2, width_screen / 2 + size_strIndicator [1] / 2, height_screen * 0,95 + size_strIndicator [2] / 2)
305 draw.Color (gui.GetValue ("clr_gui_window_header_tab2"))
306 draw.Line (width_screen / 2 - size_strIndicator [1] / 2, height_screen * 0,95 - size_strIndicator [2] / 2, width_screen / 2 + size_strIndicator [1] / 2, height_screen * 0,95 - size_strIndicator [2] / 2)
307 Ende
308
309 draw.Color (255, 255, 255, 255)
310 draw.Text (width_screen / 2 - size_strIndicator [1] / 2, height_screen * 0,95 - size_strIndicator [2] / 2, str_Indicator)
311 Ende
312
313 sonst
314 ResetPeek ()
315 Ende
316
317Ende
318callbacks.Register ("Draw", onFrameMain)
319
320lokale Funktion onEventMain (GameEvent)
321
322 local LocalPlayer = entity.GetLocalPlayer ()
323
324 - Lokaler Spieler null und lebendig prüfen
325 wenn LocalPlayer == nil oder nicht LocalPlayer: IsAlive () oder nicht msc_quickPeeking dann
326 Rückkehr
327 Ende
328
329 wenn GameEvent: GetName () == "Waffe_Feuer" dann
330
331 if entity.GetByUserID (GameEvent: GetInt ("userid")) == nil then
332 Rückkehr
333 Ende
334
335 if entity.GetByUserID (GameEvent: GetInt ("userid")): GetIndex () == LocalPlayer: GetIndex () then
336 if LocalPlayer: GetPropEntity ("m_hActiveWeapon"): GetPropInt ("m_iClip1") <= 1 dann
337 msc_hasEmptied = true
338 Ende
339 msc_shotsFired = msc_shotsFired + 1
340 Ende
341
342 elseif GameEvent: GetName () == "player_death" dann
343
344 if entity.GetByUserID (GameEvent: GetInt ("Angreifer")) == nil then
345 Rückkehr
346 Ende
347
348 if entity.GetByUserID (GameEvent: GetInt ("Angreifer")): GetIndex () == LocalPlayer: GetIndex () dann
349 wenn nicht msc_hasKilled dann
350 msc_hasKilled = true
351 Ende
352 Ende
353 Ende
354
355Ende
356callbacks.Register ("FireGameEvent", onEventMain)
357client.AllowListener ("Waffe_Feuer")
358client.AllowListener ("player_death")
359
360lokale Funktion onCreateMoveMain (UserCmd)
361
362 wenn msc_peekReturning dann
363 local LocalPlayer = entity.GetLocalPlayer ()
364
365 - Lokaler Spieler null und lebendig prüfen
366 wenn LocalPlayer == nil oder nicht LocalPlayer: IsAlive () dann
367 Rückkehr
368 Ende
369
370 local ang_LocalPlayer = {UserCmd: GetViewAngles ()}
371 local world_forward = {vector.Subtract (pos_peekOrigin, {LocalPlayer: GetAbsOrigin ()})}
372
373 UserCmd: SetForwardMove (((math.sin (math.rad (ang_LocalPlayer [2])) * world_forward [2]) + (math.cos (math.rad (ang_LocalPlayer [2])) * world_forward [1]) * 200)
374 UserCmd: SetSideMove (((math.cos (math.rad (ang_LocalPlayer [2])) * -world_forward [2]) + (math.sin (math.rad (ang_LocalPlayer [2])) * world_forward [1])) * 200)
375
376 wenn vector.Length (world_forward) <10 dann
377 msc_peekReturning = false
378 msc_peekCompleted = true
379 Ende
380 Ende
381
382Ende
383callbacks.Register ("CreateMove", onCreateMoveMain)