Jump to content

Problem about toggleAllControls


jingzhi

Recommended Posts

Here is a part of arresting system scripts:

addEvent("onPlayerArrested",true) 
addEventHandler("onPlayerArrested",root, 
function(arrestercop) 
    arrester = arrestercop 
    toggleAllControls(false,true,false) 
    fadeCamera() 
    setCameraTarget(arrestercop) 
    addEventHandler("onClientRender",root,cuffed) 
end) 
  
function cuffed()   
    local copx, copy, copz = getElementPosition (arrester) 
    local x, y, z = getElementPosition (localPlayer) 
    local rx, ry, _ = getElementRotation (localPlayer) 
    local dist = getDistanceBetweenPoints2D (copx, copy, x, y) 
    local relx = copx - x 
    local rely = copy - y 
    if rely == 0 then 
        if relx < 0 then  
            copangle = 90  
        else 
            copangle = 270 
        end 
    else 
        if rely > 0 then 
            local copangle = 360 - math.deg(math.atan(relx / rely)) % 360 
        else 
            local copangle = 180 - math.deg(math.atan(relx / rely)) 
        end 
    end 
    setElementRotation(localPlayer,_,_, copangle) 
    if dist < 5 then 
        setControlState("forwards", false) 
        setControlState("sprint", false ) 
    else 
        setControlState("forwards", true) 
        setControlState("sprint", true ) 
        if dist > 50 then 
            setElementPosition(localPlayer,copx,copy,copz) 
        end 
    end 
end 

The arrested players can still change the direction when they move the mouse, any help?

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...