Jump to content

Arrest Script


DakiLLa

Recommended Posts

Guys, need help. I want to make an arrest scene. There is some script but it's not work. Can you help ?

  
function Arrest ( attacker, weapon, bodypart ) 
    if isElement(attacker) and getElementType(attacker) == "player" then 
        if ( weapon == 3 and getPlayerSkin ( attacker ) >= 280 ) then 
            if ( getPlayerWantedLevel ( source ) > 0 ) then 
                setPlayerWantedLevel ( source, 0 ) 
                setElementPosition ( source, -1982.1209, 130.7857, 27.6875 ) 
                outputChatBox ( "You have been arrested.", source, 255, 0, 0 ) 
                toggleAllControls ( source, true ) 
            end 
        end 
    end 
    setTimer ( DisableControls, 30000, 1 ) 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), Arrest ) 
  
function DisableControls () 
    toggleAllControls ( source, false ) 
    outputChatBox ("You are free now. Please, dont become a criminal in next time.", source, 0, 255, 0 ) 
end 
  

Link to comment

Ehm... What exactly is wrong?

If you don't know, place outputChatBox("1"), "2", etc. in the if blocks. So for example:

function Arrest ( attacker, weapon, bodypart ) 
    if isElement(attacker) and getElementType(attacker) == "player" then 
        outputChatBox("1") 
        if ( weapon == 3 and getPlayerSkin ( attacker ) >= 280 ) then 
            outputChatBox("2") 
            if ( getPlayerWantedLevel ( source ) > 0 ) then 
                outputChatBox("3") 
                setPlayerWantedLevel ( source, 0 ) 
                setElementPosition ( source, -1982.1209, 130.7857, 27.6875 ) 
                outputChatBox ( "You have been arrested.", source, 255, 0, 0 ) 
                toggleAllControls ( source, true ) 
            end 
        end 
    end 
    setTimer ( DisableControls, 30000, 1 ) 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), Arrest ) 
  
function DisableControls () 
    outputChatBox("4") 
    toggleAllControls ( source, false ) 
    outputChatBox ("You are free now. Please, dont become a criminal in next time.", source, 0, 255, 0 ) 
end 

And if you see...

1

2

3

4 (this one after a while)

... then it should work, right?

Otherwise, tell us from where it's going wrong.

Link to comment

The variable source is not passed to DisableControls by default. You will have to pass it as an argument in your setTimer call.

  
setTimer ( DisableControls, 30000, 1, source ) 
  

  
function DisableControls (thePlayer) 
    toggleAllControls ( thePlayer, false ) 
    outputChatBox ("You are free now. Please, dont become a criminal in next time.", thePlayer, 0, 255, 0 ) 
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...