local ev = require 'lib.samp.events'
local anims = {"KD_left","KD_right","KO_shot_face","KO_shot_stom","KO_skid_front","KO_spin_L","KO_spin_R"}
local pID;
local state = false
local thread1
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
while true do
wait(0)
end
end
function ev.onPlayerDeath(playerId)
isSpawned = sampIsLocalPlayerSpawned()
if isSpawned then
inStream, ped = sampGetCharHandleBySampPlayerId(playerId)
if inStream then
pID = playerId;
state = true
thread1 = lua_thread.create_suspended(playanim)
thread1:run()
end
end
end
function playanim()
while(state) do
wait(100)
inStream, ped = sampGetCharHandleBySampPlayerId(pID)
if inStream then
local rand = math.random(1,7)
clearCharTasksImmediately(ped)
setCharAnimSpeed(ped, anims[rand], 0.8)
taskPlayAnim(ped, anims[rand], "PED", 3.0, false, false, false, false, -1)
state = false
end
end
end