1
0
Fork 0
forked from Simnation/Main
Main/resources/[standalone]/rpemotes-reborn/client/Walk.lua
2025-06-12 03:36:12 +02:00

124 lines
3.4 KiB
Lua

local canChange = true
local unable_message = "You are unable to change your walking style right now."
function WalkMenuStart(name, force)
if not canChange and not force then
EmoteChatMessage(unable_message)
return
end
if not name or name == "" then
ResetWalk()
return
end
if not RP[name] or type(RP[name]) ~= "table" or RP[name].category ~= "Walks" then
EmoteChatMessage("'" .. tostring(name) .. "' is not a valid walk")
return
end
local walk = RP[name][1]
RequestWalking(walk)
SetPedMovementClipset(PlayerPedId(), walk, 0.2)
RemoveAnimSet(walk)
if Config.PersistentWalk then SetResourceKvp("walkstyle", name) end
end
function ResetWalk()
if not canChange then
EmoteChatMessage(unable_message)
return
end
ResetPedMovementClipset(PlayerPedId(), 0.0)
end
function WalksOnCommand()
local WalksCommand = ""
for name, data in PairsByKeys(RP) do
if type(data) == "table" and data.category == "Walks" then
WalksCommand = WalksCommand .. string.lower(name) .. ", "
end
end
EmoteChatMessage(WalksCommand)
EmoteChatMessage("To reset do /walk reset")
end
function WalkCommandStart(name)
if not canChange then
EmoteChatMessage(unable_message)
return
end
name = FirstToUpper(string.lower(name))
if name == "Reset" then
ResetPedMovementClipset(PlayerPedId(), 0.0)
DeleteResourceKvp("walkstyle")
return
end
WalkMenuStart(name, true)
end
if Config.WalkingStylesEnabled and Config.PersistentWalk then
local function walkstyleExists(kvp)
while not CONVERTED do
Wait(0)
end
if not kvp or kvp == "" then
return false
end
local walkstyle = RP[kvp]
if walkstyle and type(walkstyle) == "table" and walkstyle.category == "Walks" then
return true
end
return false
end
local function handleWalkstyle()
local kvp = GetResourceKvpString("walkstyle")
if kvp then
if walkstyleExists(kvp) then
WalkMenuStart(kvp, true)
else
ResetPedMovementClipset(PlayerPedId(), 0.0)
DeleteResourceKvp("walkstyle")
end
end
end
AddEventHandler('playerSpawned', function()
Wait(3000)
handleWalkstyle()
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', handleWalkstyle)
RegisterNetEvent('esx:playerLoaded', handleWalkstyle)
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
handleWalkstyle()
end
end)
end
if Config.WalkingStylesEnabled then
RegisterCommand('walks', function() WalksOnCommand() end, false)
RegisterCommand('walk', function(_, args, _) WalkCommandStart(tostring(args[1])) end, false)
TriggerEvent('chat:addSuggestion', '/walk', 'Set your walkingstyle.', { { name = "style", help = "/walks for a list of valid styles" } })
TriggerEvent('chat:addSuggestion', '/walks', 'List available walking styles.')
end
CreateExport('toggleWalkstyle', function(bool, message)
canChange = bool
if message then
unable_message = message
end
end)
CreateExport('getWalkstyle', function()
return GetResourceKvpString("walkstyle")
end)
CreateExport('setWalkstyle', WalkMenuStart)