[Release] ArrestAnims 1.0

str:Split does not exist anymore, you should use the proper Lua functions for this. For the commonly copy-pasted stringsplit function, this’d be:



function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

of course i am using fx server.

so your saying some of my scripts that this is poping up on is due to the author hasnt changed the stringsplit and i should use that section of code.

no he is saying if u used this code

AddEventHandler(“chatMessage”, function(source, name, message) cm = stringsplit(message, " ") if cm[1] == “/k” then CancelEvent() TriggerClientEvent(“KneelHU”, source) end end)

than it will give u a error i havnt tested this as my original script is to work with essenttial mode, the code above ^^ is to be used if u dont have essential mode but i havnt tested it

oh well i have essentialmode. what i did was download your script and copied the code over to the handsup script so its being used as one resource not two. yes i copied server to server and client to client.

Client

--[[Handsup & Cuff Script]]-- Author-xander1998

RegisterNetEvent("Handcuff")
AddEventHandler("Handcuff", function()
	local lPed = GetPlayerPed(-1)
	if DoesEntityExist(lPed) then
		Citizen.CreateThread(function()
			RequestAnimDict("mp_arresting")
			while not HasAnimDictLoaded("mp_arresting") do
				Citizen.Wait(100)
			end
			
			if IsEntityPlayingAnim(lPed, "mp_arresting", "idle", 3) then
				ClearPedSecondaryTask(lPed)
				SetEnableHandcuffs(lPed, false)
			else
				TaskPlayAnim(lPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
				SetEnableHandcuffs(lPed, true)
			end		
		end)
	end
end)

RegisterNetEvent("Handsup")
AddEventHandler("Handsup", function()
	local lPed = GetPlayerPed(-1)
	if DoesEntityExist(lPed) then
		Citizen.CreateThread(function()
			RequestAnimDict("random@mugging3")
			while not HasAnimDictLoaded("random@mugging3") do
				Citizen.Wait(100)
			end
			
			if IsEntityPlayingAnim(lPed, "random@mugging3", "handsup_standing_base", 3) then
				ClearPedSecondaryTask(lPed)
				SetEnableHandcuffs(lPed, false)
				TriggerEvent("chatMessage", "", {255, 0, 0}, "Your have put your hands down.")
			else
				TaskPlayAnim(lPed, "random@mugging3", "handsup_standing_base", 8.0, -8, -1, 49, 0, 0, 0, 0)
				SetEnableHandcuffs(lPed, true)
				TriggerEvent("chatMessage", "", {255, 0, 0}, "Your hands are up.")
			end		
		end)
	end
end)

--[[ DRAG SCRIPT ]]-- Author-Unknown

local drag = false

RegisterNetEvent("Drag")
AddEventHandler("Drag", function(oid)
	if drag == false then
		local otherPlayer = tonumber(oid)
		local oPed = GetPlayerPed(GetPlayerFromServerId(otherPlayer))
		local myPed = GetPlayerPed(PlayerId())
		AttachEntityToEntity(myPed, oPed, 11816, 0.54, 0.54, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
	elseif drag == true then
		DetachEntity(GetPlayerPed(PlayerId()), true, false)
	end
end)
--]]

--[[ Handsup Kneel Script]]-- Author-Coshark

function loadAnimDict( dict )
    while ( not HasAnimDictLoaded( dict ) ) do
        RequestAnimDict( dict )
        Citizen.Wait( 5 )
    end
end 

RegisterNetEvent( 'KneelHU' )
AddEventHandler( 'KneelHU', function()
    local player = GetPlayerPed( -1 )
	if ( DoesEntityExist( player ) and not IsEntityDead( player )) then 
        loadAnimDict( "random@arrests" )
		loadAnimDict( "random@arrests@busted" )
		if ( IsEntityPlayingAnim( player, "random@arrests@busted", "idle_a", 3 ) ) then 
			TaskPlayAnim( player, "random@arrests@busted", "exit", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
			Wait (3000)
            TaskPlayAnim( player, "random@arrests", "kneeling_arrest_get_up", 8.0, 1.0, -1, 128, 0, 0, 0, 0 )
        else
            TaskPlayAnim( player, "random@arrests", "idle_2_hands_up", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
			Wait (4000)
            TaskPlayAnim( player, "random@arrests", "kneeling_arrest_idle", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
			Wait (500)
			TaskPlayAnim( player, "random@arrests@busted", "enter", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
			Wait (1000)
			TaskPlayAnim( player, "random@arrests@busted", "idle_a", 8.0, 1.0, -1, 9, 0, 0, 0, 0 )
        end     
    end
end )

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsEntityPlayingAnim(GetPlayerPed(PlayerId()), "random@arrests@busted", "idle_a", 3) then
			DisableControlAction(1, 140, true)
			DisableControlAction(1, 141, true)
			DisableControlAction(1, 142, true)
			DisableControlAction(0,21,true)
		end
	end
end)

Server

--[[Handsup & Cuff Script]]-- Author-xander1998

AddEventHandler("chatMessage", function(source, name, message)
	cm = stringsplit(message, " ")

	if cm[1] == "/cuff" then
		CancelEvent()
		if tablelength(cm) > 1 then
			local tPID = tonumber(cm[2])
			TriggerClientEvent("Handcuff", tPID)
		end
	end

	if cm[1] == "/drag" then
		CancelEvent()
		if tablelength(cm) > 1 then
			local tPID = tonumber(cm[2])
			TriggerClientEvent("Drag", tPID, source)
		end
	end

	if cm[1] == "/hu" then
		CancelEvent()
		TriggerClientEvent("Handsup", source)
	end
end)

--[[ Handsup Kneel Script]]-- Author-Coshark

TriggerEvent('es:addCommand', 'huk', function(source, args, user)
	TriggerClientEvent('KneelHU', source, {})
end, {help = "Get down on your knees and put your hands on your head"})

--[[Stringsplit]]--

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

function tablelength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end
1 Like

did u try it with only mine??

also by doing that, i cant reallly help u modifications on your own risk, my side of the script is working its the commands thing isnt, essentialmode commands work good with no errors but since u put my script into another script that uses str splitting it gives u errors m8. i dont see the reason why u would wanna do that its only 1 extra script

i can try this today. i am trying to combine and reduce how many resources the server has to load. like my vehicles i had 15 folders reduced down to 2 now.

ye doing that with vehicles is perfect
butt with other resources its just useless imo and causes errors

see did not know that. this is a lesson learned i suppose.

update: this is still happening and ran as your resource only. not entirely sure why i am getting this.

Command 'k' entered..
Error running system event handling function for resource commands: citizen:/scripting/lua/scheduler.lua:39: Failed to execute thread: server.lua:34: attempt to call a nil value (method 'Split')
stack traceback:
	server.lua:34: in function 'stringsplit'
	server.lua:26: in upvalue 'handler'
	citizen:/scripting/lua/scheduler.lua:124: in function <citizen:/scripting/lua/scheduler.lua:123>
stack traceback:
	[C]: in function 'error'
	citizen:/scripting/lua/scheduler.lua:39: in field 'CreateThreadNow'
	citizen:/scripting/lua/scheduler.lua:123: in function <citizen:/scripting/lua/scheduler.lua:92>
Command 'k' entered..
Error running system event handling function for resource commands: citizen:/scripting/lua/scheduler.lua:39: Failed to execute thread: server.lua:34: attempt to call a nil value (method 'Split')
stack traceback:
	server.lua:34: in function 'stringsplit'
	server.lua:26: in upvalue 'handler'
	citizen:/scripting/lua/scheduler.lua:124: in function <citizen:/scripting/lua/scheduler.lua:123>
stack traceback:
	[C]: in function 'error'
	citizen:/scripting/lua/scheduler.lua:39: in field 'CreateThreadNow'
	citizen:/scripting/lua/scheduler.lua:123: in function <citizen:/scripting/lua/scheduler.lua:92>

This is another update. I found my culprit and fixed it. i was working on creating this and had the stringsplit at the end. i relized after looking at my loaded resources.

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/911" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "911 Hotline | " .. name, { 255, 0, 0 }, string.sub(msg,5))
	end
end)

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/911 tow" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "AAA Services | " .. name, { 255, 0, 0 }, string.sub(msg,5))
	end
end)

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/do" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "Action | " .. name, { 255, 0, 0 }, string.sub(msg,5))
	end
end)

AddEventHandler('chatMessage', function(source, name, msg)
	sm = stringsplit(msg, " ");
	if sm[1] == "/ooc" then
		CancelEvent()
		TriggerClientEvent('chatMessage', -1, "OOC | " .. name, { 255, 0, 0 }, string.sub(msg,5))
	end
end)
Error running system event handling function for resource commands:

like i said earlier my resource is fine “resource commands”

How would I change the keybind from enter.

? this is not key based?? its command based xD

So the only thing included in this script is the /k command? :dizzy_face: Okay then lol there is something else I need to look at. Cool script by the way.

ye only /k for now until i add more Anims ;D

This source code looks very similar to this: How do I smooth out this animation?, sorta like you copy and pasted it and slightly modified it.

If you didn’t use this than that is just a really weird coinicidence how similar they look.

mr turtle thatts cause i looked there and saw it like the code and wrote it adding my own stuff rewritting 80% of the code adding other stuff and my own anim flags, even if it is based of that code, whatt difference does it make?

and i dont know lua so you can say i copied it but i couldnt care less, i rewrote 80% of the code and spent quite a while testting it and finding anims, and in the end its to help the community get wut they need ;D

So 20% of the credit for this release should go the person who original wrote the code you pulled from. Its a courtesy thing.

The difference it makes is how it makes you look within the community. He posted it on a public form yes but all I’m saying is you should have at least credited him somewhat as a courtesy for his help. A simple -- Credits to @Wolfknight for example code above the functions would have been all you need. When I see people rip code that I or someone else wrote, modify it 80% and then upload it without credits it just makes me less likely to help people and release my scripts.

Reviewing your code:
0% Changes: http://puu.sh/xBQ50/bb91f29230.png
80% changes: http://puu.sh/xBQdB/67ce4d170c.png

Also, the fact that the spacing looks so bad makes me think you copy pasted his code and edited it. There is a difference between using someone codes as a base to work upon and using someones code as a reference to build your own.

like i said what does it matter? i can give 200% credits to him saying that he made it, its not about that its about helping out the community, i dont see ur problem ;D