# i need help

**URL:** <https://forums.solar2d.com/t/i-need-help/356887>\
**Category:** Games\
**Created:** [October 14, 2024, 4:19pm UTC](https://forums.solar2d.com/t/i-need-help/356887 "2024-10-14T16:19:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robotraicay](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@robotraicay](https://forums.solar2d.com/u/robotraicay)\
**Post date:** [October 14, 2024, 4:19pm UTC](https://forums.solar2d.com/t/i-need-help/356887/1 "2024-10-14T16:19:21Z")

</div>

* * *

## ---------------- Basic Variable ----------------------------- ---------------- Do not edit ---------------------

## local current\_weapon = “none”

## ---------------- Basic Setting ------------------------------

---- key bind ----

local ump9\_key = nil  
local akm\_key = 4  
local m16a4\_key = nil  
local m416\_key = nil  
local scarl\_key = nil  
local qbz\_key = nil  
local uzi\_key = nil  
local set\_off\_key = 5

---- keyboard ---- Only Support logitech G Keyboard  
local fire\_key = “F8”

local ump9\_gkey = nil —1 is use F1.  
local akm\_gkey = nil  
local m16a4\_gkey = nil  
local m416\_gkey = nil  
local set\_off\_key = 5  
local scarl\_gkey = nil  
local uzi\_gkey = nil  
local set\_off\_gkey = nil

---- fire key ----  
local ump9\_key = 7

---- can use “lalt”, “ralt”, “alt” “lshift”, “rshift”, “shift” “lctrl”, “rctrl”, “ctrl”

local ignore\_key = “lalt” — ignore key  
local hold\_breath\_key = “lshift”

---- only can use “numlock”, “capslock”, “scrolllock”

local full\_mode\_key = “numlock” —numlock lamp on,recoil is full\_mode.  
local mode\_switch\_key = “capslock”  
local lighton\_key = “scrolllock” —start script,scrolllock lamp will be on.close script ,scrolllock lamp will be off.

— fastloot setting—  
— Press fast\_loot\_key and click Left mouse button —

local fastloot = false —if you don’t need it, you can close it by true to false.  
local fast\_loot\_key = “lctrl”  
local move = 40 ----1920\*1080

— Your Sensitivity in Game

local vertical\_sensitivity = 1.0 — default is 0.7  
local target\_sensitivity = 50 — default is 50.0  
local scope\_sensitivity = 50 — default is 50.0  
local scope4x\_sensitivity = 50 — default is 50.0

---- function ----  
– if auto\_mode = true ,the guns need to switch automatic shooting mode,except m16 single.

local auto\_mode = true

– you can close these by true to false

local hold\_breath\_mode = true  
local full\_mode = true

---- Obfs setting  
---- Two firing time intervals = weapon\_speed \* interval\_ratio \* ( 1 + random\_seed \* ( 0 ~ 1))  
local weapon\_speed\_mode = false  
– local obfs\_mode = false  
local obfs\_mode = false  
local interval\_ratio = 0.75  
local random\_seed = 1

* * *

## ---------------- Recoil Table ------------------------------ ---------------- You can fix the value here ------------------------------

— recoil times  
— if the Recoil compensation is Large or small，You can modify the value of all\_recoil\_Times or recoil\_table{times}  
local all\_recoil\_times = 1

local recoil\_table = {}

recoil\_table[“ump9”] = {  
basic={33.5,19.2,30.5,35.7,39.3, 39.0,38.7,40.2,41.8,44.0, 43.8,43.8,46.5,44.5,47.5},  
basictimes = 1.05,

```
full={33.5,19.2,30.5,35.7,39.3, 39.0,38.7,40.2,41.8,44.0, 43.8,43.8,46.5,44.5,47.5},
fulltimes = 0.75*0.9,

holdbreathtimes = 1.25,

quadruple={33.5,19.2,30.5,35.7,39.3, 39.0,38.7,40.2,41.8,44.0, 43.8,43.8,46.5,44.5,47.5},
quadrupletimes = 4*1*0.97,

fullof4x={33.5,19.2,30.5,35.7,39.3, 39.0,38.7,40.2,41.8,44.0, 43.8,43.8,46.5,44.5,47.5},
fullof4xtimes = 4*0.75,

speed = 90,

maxbullets = 40,

```

}

recoil\_table[“akm”] = {  
basic={60.5,40.5,47.5,51.0,55.5, 64.0,67.5,69.5,70.5,71.0, 72.5,75.6,76.3,77.0,78.9,  
80.6,70.5,},  
basictimes = 1.01,

```
full={60.5,40.5,47.5,51.0,54.5, 64.0,67.5,69.0,70.5,71.0, 71.5,75.6,76.3,77.0,78.9,
80.6,70.5,},

holdbreathtimes = 1.25,

quadruple={60.5,40.5,47.5,51.0,54.5, 64.0,67.5,69.0,70.5,71.0, 71.5,75.6,76.3,77.0,78.9,
80.6,70.5,},
quadrupletimes = 4*1.01,

fullof4x={60.5,40.5,47.5,51.0,54.5, 64.0,67.5,69.0,70.5,71.0, 71.5,75.6,76.3,77.0,78.9,
80.6,70.5,},
fullof4xtimes = 4*1*0.75,

speed = 100,

maxbullets = 40,

```

}

recoil\_table[“m16a4”] = {  
basic={41.9,36.5,37.1,50.5,55.9, 62.9,66.9,69.5,69.5,70.0, 71.2,},  
basictimes = 1.05,

```
full={41.9,36.5,37.1,50.5,55.9, 62.9,66.9,69.5,69.5,70.0, 71.2,},
fulltimes = 1*0.77,

holdbreathtimes = 1.25,

quadruple={41.9,36.5,37.1,50.5,55.9, 62.9,66.9,69.5,69.5,70.0, 71.2,},
quadrupletimes = 1*4,

fullof4x={41.9,36.5,37.1,50.5,55.9, 62.9,66.9,69.5,69.5,70.0, 71.2,},
fullof4xtimes = 4*1*0.75,

speed = 75,

maxbullets = 40,

```

}

recoil\_table[“m416”] = {  
basic={49.5,36.0,41.9,44.3,49.4, 51.1,53.4,53.9,54.1,55.6, 56.5,58.5,62.3,60.4,60.8,  
60.3,},   
basictimes = 1.08,

```
full={50.2,39.0,41.3,43.4,48.0, 50.0,52.2,52.5,53.5,50.5, 51.5,53.8,59.6,59.8,60.8,
60.3,},
fulltimes = 1.08*0.75,	

holdbreathtimes = 1.25,

quadruple={50.2,39.0,41.3,43.4,48.0, 50.0,52.2,52.5,53.5,50.5, 51.5,53.8,59.6,59.8,60.8,
60.3,},
quadrupletimes = 4*1*0.8,

fullof4x={50.2,39.0,41.3,43.4,48.0, 50.0,52.2,52.5,53.5,50.5, 51.5,53.8,59.6,59.8,60.8,
60.3,},
fullof4xtimes = 4*1.08*0.75,

speed = 90,

maxbullets = 40,

```

}

recoil\_table[“scarl”] = {  
basic={59.0,28.5,33.5,42.0,45.9, 47.9,50.0,54.2,56.8,57.4, 57.9,57.5,57.7,58.8,59.4},  
basictimes = 1,

```
full={59.0,28.5,33.5,42.0,45.9, 47.9,50.0,54.2,56.8,57.4, 57.9,57.5,57.7,58.8,59.4},
fulltimes = 1*0.75,

holdbreathtimes = 1.25,

quadruple={59.0,28.5,33.5,42.0,45.9, 47.9,50.0,54.2,56.8,57.4, 57.9,57.5,57.7,58.8,59.4},
quadrupletimes = 4*1,

fullof4x={59.0,28.5,33.5,42.0,45.9, 47.9,50.0,54.2,56.8,57.4, 57.9,57.5,57.7,58.8,59.4},
fullof4xtimes = 4*1*0.75,

speed = 100,

maxbullets = 40,

```

}

recoil\_table[“uzi”] = {  
basic={16.0,16.0,16.0,17.6,18.6, 20.4,22.4,22.9,25.8,27.6, 32.6,36.9,38.0,38.8,39.8,40.5},  
basictimes = 1.15,

```
full={16.0,16.0,16.0,17.6,18.6, 20.4,22.4,22.9,25.8,27.6, 32.6,36.9,38.0,38.8,39.8,40.5},
fulltimes = 1.15*0.75*0.75,

holdbreathtimes = 1.25,

quadruple={16.0,16.0,16.0,17.6,18.6, 20.4,22.4,22.9,25.8,27.6, 32.6,36.9,38.0,38.8,39.8,40.5},
quadrupletimes = 1.15,

fullof4x={16.0,16.0,16.0,17.6,18.6, 20.4,22.4,22.9,25.8,27.6, 32.6,36.9,38.0,38.8,39.8,40.5},
fullof4xtimes = 1.15*0.75*0.75,

speed = 48,

maxbullets = 35,

```

}

recoil\_table[“qbz”] = {  
basic={52.0,25.0,28.7,38.2,42.4, 44.0,46.0,46.0,45.6,45.1, 48.0,51.3,52.0,54.0,56.0, 59},  
basictimes = 1.06,

```
full={51.2,24.5,28.7,38.2,42.4, 43.3,45.2,45.2,45.6,45.1, 48.0,50.3,51.0,53.0,55.0},
fulltimes = 1.06*0.75,

holdbreathtimes = 1.25,

quadruple={51.2,24.5,28.7,38.2,42.4, 43.3,45.2,45.2,45.6,45.1, 48.0,50.3,51.0,53.0,55.0},
quadrupletimes = 4*1.06,

fullof4x={51.2,24.5,28.7,38.2,42.4, 43.3,45.2,45.2,45.6,45.1, 48.0,50.3,51.0,53.0,55.0},
fullof4xtimes = 4*1.06*0.75,

speed = 90,

maxbullets = 40,

```

}

* * *

## ---------------- Function ------------------------------

function convert\_sens(unconvertedSens)  
return 0.002 \* 10^unconvertedSens / 50)  
end

function calc\_sens\_scale(sensitivity)  
return convert\_sens(sensitivity)/convert\_sens(50)  
end

local target\_scale = calc\_sens\_scale(target\_sensitivity)  
local scope\_scale = calc\_sens\_scale(scope\_sensitivity)  
local scope4x\_scale = calc\_sens\_scale(scope4x\_sensitivity)

function recoil\_mode()  
if not IsKeyLockOn(mode\_switch\_key) then  
if IsKeyLockOn(full\_mode\_key) and full\_mode then  
return “full”;  
else  
return “basic”;  
end  
end

```
if IsKeyLockOn(mode_switch_key) then
    if IsKeyLockOn(full_mode_key) and full_mode then
	   return "fullof4x"
	   else
	   return "quadruple"
    end 
end		

```

end

function recoil\_value(\_weapon,\_duration)  
local \_mode = recoil\_mode()  
if weapon\_speed\_mode then  
weapon\_speed = recoil\_table[\_weapon][“speed”]  
end  
– OutputLogMessage(“weapon\_speed = %s\n”, weapon\_speed)

```
local weapon_basictimes = recoil_table[_weapon]["basictimes"]
local weapon_fulltimes = recoil_table[_weapon]["fulltimes"]
local weapon_quadrupletimes = recoil_table[_weapon]["quadrupletimes"]
local step = (math.floor(_duration/100)) + 1
if step > #recoil_table[_weapon][_mode] then
    step = #recoil_table[_weapon][_mode]
end

local weapon_recoil = recoil_table[_weapon][_mode][step]
-- OutputLogMessage("weapon_recoil = %s\n", weapon_recoil)

local weapon_speed = 30
local weapon_fullof4xtimes = recoil_table[_weapon]["fullof4xtimes"]
local weapon_holdbreathtimes = recoil_table[_weapon]["holdbreathtimes"]
local weapon_intervals = weapon_speed    

if obfs_mode then
    local coefficient = interval_ratio * ( 1 + random_seed * math.random())
    weapon_intervals = math.floor(coefficient * weapon_speed) 
end
-- OutputLogMessage("weapon_intervals = %s\n", weapon_intervals)

recoil_recovery = weapon_recoil * weapon_intervals / 100 
recoil_times = all_recoil_times * 0.7 / vertical_sensitivity 

if recoil_mode() == "basic" and not IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * recoil_times * weapon_basictimes
end
if recoil_mode() == "basic" and hold_breath_mode and IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * weapon_holdbreathtimes * recoil_times * weapon_basictimes
end

if recoil_mode() == "full" and not IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * recoil_times * weapon_fulltimes
end
if recoil_mode() == "full" and hold_breath_mode and IsModifierPressed(hold_breath_key) then
recoil_recovery = recoil_recovery * weapon_holdbreathtimes * recoil_times * weapon_fulltimes
end

if recoil_mode() == "quadruple" then
recoil_recovery = recoil_recovery * recoil_times * weapon_quadrupletimes
end

if recoil_mode() == "fullof4x" then
recoil_recovery = recoil_recovery * recoil_times * weapon_fullof4xtimes
end

-- issues/3
if IsMouseButtonPressed(2) then
    recoil_recovery = recoil_recovery / target_scale
elseif recoil_mode() == "basic" then
    recoil_recovery = recoil_recovery / scope_scale
elseif recoil_mode() == "full" then
    recoil_recovery = recoil_recovery / scope_scale
elseif recoil_mode() == "quadruple" then
    recoil_recovery = recoil_recovery / scope4x_scale
elseif recoil_mode() == "fullof4x" then
    recoil_recovery = recoil_recovery / scope4x_scale
end

return weapon_intervals,recoil_recovery

```

end

* * *

## ---------------- OnEvent ------------------------------

function OnEvent(event, arg)  
OutputLogMessage(“event = %s, arg = %d\n”, event, arg)  
if (event == “PROFILE\_ACTIVATED”) then  
EnablePrimaryMouseButtonEvents(true)  
elseif event == “PROFILE\_DEACTIVATED” then  
current\_weapon = “none”  
shoot\_duration = 0.0  
ReleaseKey(fire\_key)  
ReleaseMouseButton(1)  
end

```
if (event == "MOUSE_BUTTON_PRESSED" and arg == set_off_key) 
or (event == "G_PRESSED" and arg == set_off_gkey) then
    current_weapon = "none"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == akm_key)
or (event == "G_PRESSED" and arg == akm_gkey) then
    current_weapon = "akm"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == m16a4_key)
or (event == "G_PRESSED" and arg == m16a4_gkey) then
    current_weapon = "m16a4"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == m416_key)
or (event == "G_PRESSED" and arg == m416_gkey) then
    current_weapon = "m416"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == ump9_key)
or (event == "G_PRESSED" and arg == ump9_gkey) then
    current_weapon = "ump9"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == uzi_key)
or (event == "G_PRESSED" and arg == uzi_gkey) then
    current_weapon = "uzi"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == scarl_key)
or (event == "G_PRESSED" and arg == scarl_gkey) then
    current_weapon = "scarl"
elseif (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and not IsModifierPressed(fast_loot_key)) then
    -- button 1 : Shoot
    if ((current_weapon == "none") or IsModifierPressed(ignore_key)) then
        PressKey(fire_key)
        repeat
            Sleep(30)
        until not IsMouseButtonPressed(1)
        ReleaseKey(fire_key)
    elseif((current_weapon == "m16a4") and not IsModifierPressed(ignore_key)) then
        local shoot_duration = 0.0
        repeat
            local intervals,recovery = recoil_value(current_weapon,shoot_duration)
            PressAndReleaseKey(fire_key)
            MoveMouseRelative(0, recovery )
            Sleep(intervals)
            shoot_duration = shoot_duration + intervals
        until not IsMouseButtonPressed(1)
    else
        if auto_mode then
            PressKey(fire_key)
            local shoot_duration = 0.0
            repeat
            local intervals,recovery = recoil_value(current_weapon,shoot_duration)
            MoveMouseRelative(0, recovery )
            Sleep(intervals)
            shoot_duration = shoot_duration + intervals
            until not IsMouseButtonPressed(1)
        else
            local shoot_duration = 0.0
            repeat
            local intervals,recovery = recoil_value(current_weapon,shoot_duration)
            PressAndReleaseKey(fire_key)
            MoveMouseRelative(0, recovery )
            Sleep(intervals)
            shoot_duration = shoot_duration + intervals
            until not IsMouseButtonPressed(1)
        end
    end
elseif (event == "MOUSE_BUTTON_RELEASED" and arg == 1) then
    ReleaseKey(fire_key)
end
while (event == "MOUSE_BUTTON_PRESSED" and arg == 1 and IsModifierPressed(fast_loot_key) and fastloot) do
    ReleaseMouseButton(1)
    PressMouseButton(1)
    for i = 0, 14 do
    MoveMouseRelative(move, 0)
    Sleep(2)
    end
    ReleaseMouseButton(1)
    for i = 0, 14 do
    MoveMouseRelative(-move, 0)
    Sleep(2)
    end
    Sleep(10) 
end
if (current_weapon == "none") then
    if IsKeyLockOn(lighton_key) then
    PressAndReleaseKey(lighton_key)
    end 
else
    if not IsKeyLockOn(lighton_key) then
    PressAndReleaseKey(lighton_key)
    end
 end

```

end

---

<div class="post-metadata">

**Author:** ![bgmadclown](https://forums.solar2d.com/user_avatar/forums.solar2d.com/bgmadclown/32/490_2.png) [@bgmadclown](https://forums.solar2d.com/u/bgmadclown)\
**Post date:** [October 14, 2024, 10:54pm UTC](https://forums.solar2d.com/t/i-need-help/356887/2 "2024-10-14T22:54:25Z")

</div>

You need to clearly describe what’s the help you need and format your code better. After that, someone might be able to help you with your issue.

---

<div class="post-metadata">

**Author:** ![clang](https://forums.solar2d.com/user_avatar/forums.solar2d.com/clang/32/3368_2.png) [@clang](https://forums.solar2d.com/u/clang)\
**Post date:** [October 16, 2024, 1:56am UTC](https://forums.solar2d.com/t/i-need-help/356887/3 "2024-10-16T01:56:23Z")

</div>

+1  
See [https://xyproblem.info/](https://xyproblem.info/)

---

<div class="post-metadata">

**Author:** ![system](https://forums.solar2d.com/uploads/default/original/1X/1bf6a947166df24e92aaa3358558f4b82d7f3d5a.png) [@system](https://forums.solar2d.com/u/system)\
**Post date:** [April 14, 2025, 1:57am UTC](https://forums.solar2d.com/t/i-need-help/356887/4 "2025-04-14T01:57:11Z")

</div>

Closed on April 14, 2025, 1:57am UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
