Jump to content

Restrain ( Handscuff ) Script [HELP me]


Recommended Posts

Hello !

I'm search for how to put this, in a script with access acl admins , please help me.

-- ~ [CUFF, HANDCUFF, RESTRAIN] ~ -- 
addCommandHandler({"cuff", "handcuff", "restrain"}, 
    function(player, cmd, name) 
        for i,v in ipairs(getElementsByType("ped")) do 
            if tonumber(getElementData(player, "factions.player")) == tonumber(getElementData(v, "factions.id")) then 
                if exports.brpExports:getFactionType(v) == "law" then 
                    if name then 
                        local target = exports.brpExports:findPlayer(name, player) 
                        if target then 
                            if player ~= target then 
                                local x, y, z = getElementPosition(player) 
                                if exports.brpExports:isElementInRangeOfPoint(target, x, y, z, 5) then 
                                    if not getElementData(target, "police.cuffed") then 
                                        toggleControl(target, "fire", false) 
                                        toggleControl(target, "next_weapon", false) 
                                        toggleControl(target, "previous_weapon", false) 
                                        toggleControl(target, "sprint", false) 
                                        toggleControl(target, "aim_weapon", false) 
                                        toggleControl(target, "handbrake", false) 
                                        toggleControl(target, "vehicle_fire", false) 
                                        toggleControl(target, "vehicle_secondary_fire", false) 
                                        toggleControl(target, "vehicle_left", false) 
                                        toggleControl(target, "vehicle_right", false) 
                                        toggleControl(target, "steer_forward", false) 
                                        toggleControl(target, "steer_back", false) 
                                        setElementData(target, "police.cuffed", true) 
                                        outputChatBox("You are now restraining " .. getPlayerName(target) .. ".", player, 255, 255, 255, false) 
                                        outputChatBox("You are now restrained by " .. getPlayerName(target) .. ".", target, 255, 255, 255, false) 
                                        outputServerLog("[FACTIONS] [CMD/CUFF]: " .. getPlayerName(player) .. " is now restraining " .. getPlayerName(target) .. ".") 
                                    else 
                                        outputChatBox("That player is already handcuffed.", player, 255, 0, 0, false) 
                                    end 
                                else 
                                    outputChatBox("You are too far from the target.", player, 255, 0, 0, false) 
                                end 
                            else 
                                outputChatBox("You cannot cuff yourself.", player, 255, 0, 0, false) 
                            end 
                        else 
                            outputChatBox("Couldn't find such player.", player, 255, 0, 0, false) 
                        end 
                    else 
                        outputChatBox("Syntax: /" .. cmd .. " ", player, 220, 220, 0, false) 
                    end 
                end 
            end 
        end 
    end 
) 
  
-- ~ [uNCUFF, UNHANDCUFF, UNRESTRAIN] ~ -- 
addCommandHandler({"uncuff", "unhandcuff", "unrestrain"}, 
    function(player, cmd, name) 
        for i,v in ipairs(getElementsByType("ped")) do 
            if tonumber(getElementData(player, "factions.player")) == tonumber(getElementData(v, "factions.id")) then 
                if exports.brpExports:getFactionType(v) == "law" then 
                    if name then 
                        local target = exports.brpExports:findPlayer(name, player) 
                        if target then 
                            if player ~= target then 
                                local x, y, z = getElementPosition(player) 
                                if exports.brpExports:isElementInRangeOfPoint(target, x, y, z, 5) then 
                                    if getElementData(target, "police.cuffed") then 
                                        toggleControl(target, "fire", true) 
                                        toggleControl(target, "next_weapon", true) 
                                        toggleControl(target, "previous_weapon", true) 
                                        toggleControl(target, "sprint", true) 
                                        toggleControl(target, "aim_weapon", true) 
                                        toggleControl(target, "handbrake", true) 
                                        toggleControl(target, "vehicle_fire", true) 
                                        toggleControl(target, "vehicle_secondary_fire", true) 
                                        toggleControl(target, "vehicle_left", true) 
                                        toggleControl(target, "vehicle_right", true) 
                                        toggleControl(target, "steer_forward", true) 
                                        toggleControl(target, "steer_back", true) 
                                        removeElementData(target, "police.cuffed") 
                                        outputChatBox("You unrestrained " .. getPlayerName(target) .. ".", player, 255, 255, 255, false) 
                                        outputChatBox("You are unrestrained by " .. getPlayerName(target) .. ".", target, 255, 255, 255, false) 
                                        outputServerLog("[FACTIONS] [CMD/UNCUFF]: " .. getPlayerName(player) .. " now unrestrained " .. getPlayerName(target) .. ".") 
                                    else 
                                        outputChatBox("That player is not handcuffed.", player, 255, 0, 0, false) 
                                    end 
                                else 
                                    outputChatBox("You are too far from the target.", player, 255, 0, 0, false) 
                                end 
                            else 
                                outputChatBox("You cannot uncuff yourself.", player, 255, 0, 0, false) 
                            end 
                        else 
                            outputChatBox("Couldn't find such player.", player, 255, 0, 0, false) 
                        end 
                    else 
                        outputChatBox("Syntax: /" .. cmd .. " ", player, 220, 220, 0, false) 
                    end 
                end 
            end 
        end 
    end 
) 
  
-- ~ [AUNCUFF, AUNHANDCUFF, AUNRESTRAIN] ~ -- 
addCommandHandler({"auncuff", "aunhandcuff", "aunrestrain"}, 
    function(player, cmd, name) 
        if exports.brpExports:isPlayerAdmin(player) then 
            if name then 
                local target = exports.brpExports:findPlayer(name, player) 
                if target then 
                    if getElementData(target, "police.cuffed") then 
                        toggleControl(target, "fire", true) 
                        toggleControl(target, "next_weapon", true) 
                        toggleControl(target, "previous_weapon", true) 
                        toggleControl(target, "sprint", true) 
                        toggleControl(target, "aim_weapon", true) 
                        toggleControl(target, "handbrake", true) 
                        toggleControl(target, "vehicle_fire", true) 
                        toggleControl(target, "vehicle_secondary_fire", true) 
                        toggleControl(target, "vehicle_left", true) 
                        toggleControl(target, "vehicle_right", true) 
                        toggleControl(target, "steer_forward", true) 
                        toggleControl(target, "steer_back", true) 
                        removeElementData(target, "police.cuffed") 
                        outputChatBox("You unrestrained " .. getPlayerName(target) .. ".", player, 255, 255, 255, false) 
                        outputChatBox("You are unrestrained by " .. getPlayerName(target) .. ".", target, 255, 255, 255, false) 
                        outputServerLog("[FACTIONS] [CMD/UNCUFF]: " .. getPlayerName(player) .. " now unrestrained " .. getPlayerName(target) .. ".") 
                    else 
                        outputChatBox("That player is not handcuffed.", player, 255, 0, 0, false) 
                    end 
                else 
                    outputChatBox("Couldn't find such player.", player, 255, 0, 0, false) 
                end 
            else 
                outputChatBox("Syntax: /" .. cmd .. " ", player, 220, 220, 0, false) 
            end 
        end 
    end 
) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...