Jump to content

Police /tie


Rotti

Recommended Posts

Hello,

I'm scripting my police fraction at the moment. I wanted to make a /tie command so that the police can shakle the player on the back seat, so that he can't get out of the car. I've tried it with this code:

function fesseln(player) 
    outputChatBox("Gefangener im Auto gefesselt",player, 255, 255, 0) 
    local playerTeam = getPlayerTeam ( player )  
    if (playerTeam == Polizei or playerTeam == FBI or PlayerTeam == Army) then 
        if isPedInVehicle(player) == true then 
            vehicle = getPedOccupiedVehicle(player) 
            if ( policeVehicles[getElementModel ( vehicle )] ) then 
                gefangener = getVehicleOccupant(vehicle, 2) 
                setElementFrozen(gefangener, true) 
            end 
        end 
    end 
end 
  
addCommandHandler("tie", fesseln) 

Thats where the police Vehicles are defined:

policeVehicles = { [598]=true, [596]=true, [597]=true, [599]=true } 

But the player can exit the car!

Can someone help me to fix it?

Link to comment
function fesseln ( player ) 
    outputChatBox ( "Gefangener im Auto gefesselt",player, 255, 255, 0 ) 
    local playerTeam = getPlayerTeam ( player ) 
    if ( playerTeam == Polizei or playerTeam == FBI or PlayerTeam == Army ) then 
        if isPedInVehicle ( player ) then 
            local vehicle = getPedOccupiedVehicle ( player ) 
            if ( policeVehicles [ getElementModel ( vehicle ) ] ) then 
                local gefangener = getVehicleOccupant ( vehicle, 2 ) 
                toggleControl ( gefangener, "enter_exit", false ) 
            end 
        end 
    end 
end 
addCommandHandler ( "tie", fesseln ) 

This will stop the player from leaving the vehicle.

P.S: You've got defined the team variables, right?

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