thought id ask - is there anyone on here who could help me with a LUA script im stuck with?
im converting one ive found on 5mods but have run into a few problems i need help understanding
thought id ask - is there anyone on here who could help me with a LUA script im stuck with?
im converting one ive found on 5mods but have run into a few problems i need help understanding
What mod on gtav-mods.com?
Could you link it?
of course
this is the orignal
and here is my attempt its loads but the commented code is errors i dont understand how to correct
`
local ForceMod = {}
local ForceKey = 79 – O
local ForceKeyPad = 76 --RB
local Force = 0.5
local KeyPressed = false
local KeyTimer = 0
local KeyDelay = 15
local ForceEnabled = false
local P_Notif = {}
local P_Notif_i = 1
local StartedAnimWait = false
local StartPush = false
local PushDelay = 0
local RagCount = 0
local ForceAnimCore = “amb@world_human_aa_coffee@base”
local ForceAnim = “base”
–local ForceAnimCore = “anim@am_hold_up@male”
–local ForceAnim = “shoplift_high”
local PushAnimCore = “anim@mp_player_intcelebrationmale@thumbs_up”
local PushAnim = “thumbs_up”
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if (KeyPressed) then
KeyTimer = KeyTimer + 1
if(KeyTimer >= KeyDelay) then
KeyTimer = 0
KeyPressed = false
end
end
if IsControlPressed(1, forcekey) or IsControlPressed(1, ForceKeyPad)and not KeyPressed and not ForceEnabled then
KeyPressed = true
ForceEnabled = true
if (ForceEnabled) then
Ragdolled = false
PlaySoundFrontend(-1, "FocusOut", "HintCamSounds", true)
--ForceMod.DrawText("ON")
ForceMod.Walkable_Animation(ForceAnimCore, ForceAnim)
else
Ragdolled = false
local pid = PlayerPedId()
ClearPedTasks(pid)
--ForceMod.DrawText("OFF")
end
end
if (StartedAnimWait) then
SetPadShake(2, 1000, PushDelay*2)
PushDelay = PushDelay + 1
if (PushDelay >= 60) then
PushDelay = 0
StartedAnimWait = false
StartPush = true
ForceEnabled = false
end
end
if (StartPush) then
StartPush = false
local pid = PlayerPedId
StartScreenEffect("FocusIn", 0, false)
PlaySoundFrontend(-1, "FocusOut", "HintCamSounds", true)
SetTimeScale(0.2)
wait(1000)
StopScreenEffect("FocusIn")
--GRAPHICS._START_SCREEN_EFFECT("MinigameTransitionOut", 0, false)
SetTimeScale(1)
ClearPedTasks(pid)
PlaySoundFrontend(-1, "FocusOut", "HintCamSounds", true)
local vec = GetEntityForwardVector(pid)
local loc = GetEntityCoords(pid, nil)
local CamRot = GetGameplayCamRot(2)
local force = 5
local Fx = -( math.sin(math.rad(CamRot.z)) * force*10 )
local Fy = ( math.cos(math.rad(CamRot.z)) * force*10 )
local Fz = force * (CamRot.x*0.2)
--local Fx = vec.x * force*10
--local Fy = vec.y * force*10
local PlayerVeh = GetVehiclePedIsIn(pid, false)
local PedList,CountPed = GetPedNearbyPeds(pid, 1, -1)
local VehList,CountVeh = GetPedNearbyVehicles(pid, 1)
for k in ipairs(VehList) do
SetEntityInvincible(VehList[k], false)
if (IsEntityOnScreen(VehList[k])) then
if(VehList[k] ~= PlayerVeh) then
ApplyForceToEntity(VehList[k], 1, Fx, Fy,Fz, 0,0,0, true, false, true, true, true, true)
end
end
end
for k in ipairs(PedList) do
if (IsEntityOnScreen(PedList[k])) then
ApplyForceToEntity(PedList[k], 1, Fx, Fy,Fz, 0,0,0, true, false, true, true, true, true)
end
end
end
if IsControlPressed(1, forcekey) or IsControlPressed(1, ForceKeyPad) and not KeyPressed and ForceEnabled then
KeyPressed = true
StartedAnimWait = true
local pid = PlayerPedId
local PlayerVeh = GetVehiclePedIsIn(pid, false)
if(PlayerVeh == 0) then
local CamRot = GetGameplayCamRot(2)
SetEntityHeading(pid,CamRot.z)
ClearPedTasks(pid)
ForceMod.Fix_Animation(PushAnimCore, PushAnim)
end
end
if (ForceEnabled) then
if not StartedAnimWait then
SetPadShake(0, 10, 10)
end
local pid = PlayerPedId()
local vec = GetEntityForwardVector(pid)
local loc = GetEntityCoords(pid, nil)
local CamRot = GetGameplayCamRot(2)
local PlayerVeh = GetVehiclePedIsIn(pid, false)
--CamRot.x = (CamRot.x + 90) * 0.08 - 2
--CamRot.x = CamRot.x * CamRot.x
local Markerloc = loc
local High = (CamRot.x-20)*0.1
if (High < -0.5) then High = -0.5 end
-- Markerloc.x = loc.x - ( math.sin(math.rad(CamRot.z)) * 20 )
-- Markerloc.y = loc.y + ( math.cos(math.rad(CamRot.z)) * 20 )
-- Markerloc.z = loc.z
local PedList,CountPed = GetPedNearbyPeds(pid, 1, -1)
local VehList,CountVeh = GetPedNearbyVehicles(pid, 1)
-- for k in ipairs(VehList) do
-- SetEntityInvincible(VehList[k], true)
-- if(VehList[k] ~= PlayerVeh) then
-- if (IsEntityOnScreen(VehList[k])) then
--local Vehloc = GetEntityCoords(VehList[k], nil)
local Vehloc = GetEntityCoords(VehList, nil)
local distance = GetDistanceBetweenCoords(Markerloc.x, Markerloc.y, Markerloc.z, Vehloc.x, Vehloc.y, Vehloc.z, true)
local distX = Markerloc.x - Vehloc.x
local distY = Markerloc.y - Vehloc.y
local distZ = Markerloc.z - Vehloc.z
-- local Velocity = GetEntityVelocity(VehList[k])
local Velocity = GetEntityVelocity(VehList)
local Pspeed = GetEntitySpeed(pid)
local ForceX = -Velocity.x*0.01 + distX/(distance*5)*((0.1*Pspeed)+1)
local ForceY = -Velocity.y*0.01 + distY/(distance*5)*((0.1*Pspeed)+1)
local ForceZ = High + Force - Velocity.z + distZ/(distance*5)*((0.1*Pspeed)+1)
ApplyForceToEntity(VehList, 1, ForceX, ForceY, ForceZ, 0,0,0, true, false, true, true, true, true)
-- end
-- end
-- end
-- for k in ipairs(PedList) do
-- if (IsEntityOnScreen(PedList[k])) then
-- if (IsPedRagdoll(PedList[k])) then
-- local Pedloc = GetEntityCoords(PedList[k], nil)
local Pedloc = GetEntityCoords(PedList, nil)
local distance = GetDistanceBetweenCoords(Markerloc.x, Markerloc.y, Markerloc.z, Pedloc.x, Pedloc.y, Pedloc.z, true)
local distX = Markerloc.x - Pedloc.x
local distY = Markerloc.y - Pedloc.y
local distZ = Markerloc.z - Pedloc.z
-- local Velocity = GetEntityVelocity(PedList)
local Velocity = GetEntityVelocity(PedList[k])
local Pspeed = GetEntitySpeed(pid)
local ForceX = -Velocity.x*0.01 + distX/(distance*5)
local ForceY = -Velocity.y*0.01 + distY/(distance*5)
local ForceZ = High + Force - Velocity.z + distZ/(distance*5)*((0.1*Pspeed)+1)
ApplyForceToEntity(PedList[k], 1, ForceX, ForceY, ForceZ, 0,0,0, true, false, true, true, true, true)
--ApplyForceToEntity(PedList[k], 1, ForceX, ForceY, ForceZ, 0,0,0, true, false, true, true, true, true)end
--end
-- end
if (not Ragdolled) then
for k in ipairs(PedList) do
SetPedToRagdoll(PedList[k], 4000, 5000, 1, true, true, true)
end
Ragdolled = true
end
RagCount = RagCount + 1
if (RagCount > 200) then
RagCount = 0
Ragdolled = false
end
end
end
end)
function ForceMod.Walkable_Animation(Wanted_CoreAnim, Wanted_anim)
local pid = PlayerPedId
RequestAnimDict(Wanted_CoreAnim)
while (not HasAnimDictLoaded(Wanted_CoreAnim)) do Citizen.Wait(50) end
--TaskPlayAnim(pid,Wanted_CoreAnim, Wanted_anim, 2.0, -2.0, -1, 49, 0, true, true, false)
end
function ForceMod.Fix_Animation(Wanted_CoreAnim, Wanted_anim)
local pid = PlayerPedId
RequestAnimDict(Wanted_CoreAnim)
while (not HasAnimDictLoaded(Wanted_CoreAnim)) do Citizen.Wait(50) end
--TaskPlayAnimM(pid, Wanted_CoreAnim, Wanted_anim, 10.0, -2.0, -1, 52, 0, true, true, false)
end
function ForceMod.DrawText(Text)
for k in pairs(P_Notif) do
RemoveNotification(P_Notif[k])
end
SetNotificationTextEntry("STRING")
SetNotificationTextEntry(Text)
P_Notif[P_Notif_i] = DrawNotification(false, true)
P_Notif_i = P_Notif_i + 1
end
`
anyone want to help?