[Request] Need Basic Code

Hi,

I’m not good in lua, so i back to you :slight_smile:
I would like a simple code, when player tape command /cuff [Player ID]
If player have permission level 2 he can, but if he have 1 or 0 he can’t
and a send text

text_permission : You have handcuffed ‘player’
text_error : You don’t have permission, because you are not a cop

Can i have some help ?
Thanks :smiley:

Hello,
Do you have essential mode installed on your server? That is the only way I can

If player have permission level 2 he can, but if he have 1 or 0 he can’t and a send text

Once I know you have it I will begin working on it.
Thanks,
Zach

Yes, i have essential mode :slight_smile:

I assume you took this from the AdvancedRP server dump?

if so, there are arguments I believe to check for “JOB”. You will need to remove that as it appears you are only using the cuff portion if I assume correctly?

I don’t took this from the AdvancedRP ^^

sv_cuff

RegisterServerEvent("chatMessage")
AddEventHandler('chatMessage', function(source, n, 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
end)

function stringsplit(self, delimiter)
  local a = self:Split(delimiter)
  local t = {}

  for i = 0, #a - 1 do
     table.insert(t, a[i])
  end

  return t
end

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

cl_cuff

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)

I am not the best when it comes to LUA. You need to determine what line allows user permission level = granted / fail and trigger chat messages to output text under the appropriate fields.

You may want to look at the advancedRP dump, they have a pretty solid cuff script with permissions, though I personally would use groups under essentials.

Hello,

Do you have the code please :slight_smile: ?
Because i try myself but is very hard lol …

1 Like

To be very honest with you, I would not be able to code this. Work on combining both of them together or hell… even use AdvanceRP’s script and then ask for help but make sure you give credit to the poster.

You could either get into Lua or C# as a start. There are several usefull links scattered around on the forums

We have a Wiki you could take a look at also take a look at NativeDB for usefull natives.

Be sure to take a look at our Releases section on the forums aswell, since there are some great
examples on it.

If you have any more questions be sure to post back!

:snail:

I wait you,
Please can you help me :frowning: ?

Hi, maybe I hijack this post a little, but since it is a basic code request I will take my chance.
I see that in some mods, there are multiple Citizen.CreateThread(function() functions.
Does the number affect any performance ? Or is it always an extension of that function ?
I try to get as performant as possible. But some mods manage to pull 200 selects/h from the database… Why not using the classes like the EssentialMode does (in a small part) And just save the data when the player logs out ?
(Example is the save position into the database. Every second the script opens a connection to write the coordinates in the database… Damn)

Are there any guides to follow ? Because in my eyes, if you install 10 mods the amount of stuff that the server needs to do is huge. I hope you understand my question :smiley: