Jump to content

setControlState problem


Tete omar

Recommended Posts

  
ctrlNames = { "forwards","backwards","left","right","jump","sprint","walk","crouch","enter_exit" } 
  
local function followHim(player) 
    for _, ctrl in ipairs(ctrlNames) do 
        setControlState(player,(ctrl),true) 
    end 
end 
setTimer(followHim, 10*500/100*10*5-2450, 0, player) -- the result : 50 
  
addEventHandler("onPlayerDamage", root, 
function( attacker, attackerweapon, bodypart, loss ) 
    for _,player in ipairs(getElementsByType("player")) do 
        local policeTeam = getPlayerTeam( attacker ) 
            if ( policeTeam == Police ) and ( attacker == Police ) then 
                if ( wantedLevel > 0 ) then -- wantedLevel is predefined .. 
                    if ( attackerweapon == 3 ) and ( loss > 2 ) then 
                        followHim(player) 
                        showCursor( true ) 
                    end 
                end 
            end 
    end 
end) 

Errors: bad argument @ 'setControlState'

Link to comment

Maybe?

ctrlNames = { "forwards","backwards","left","right","jump","sprint","walk","crouch","enter_exit" } 
  
local function followHim(player) 
    for _, ctrl in ipairs(ctrlNames) do 
        setControlState(player,(ctrl),true) 
    end 
end 
  
addEventHandler("onPlayerDamage", root, 
function( attacker, attackerweapon, bodypart, loss ) 
    for _,player in ipairs(getElementsByType("player")) do 
        local policeTeam = getPlayerTeam( attacker ) 
            if ( policeTeam == Police ) and ( attacker == Police ) then 
                if ( wantedLevel > 0 ) then -- wantedLevel is predefined .. 
                    if ( attackerweapon == 3 ) and ( loss > 2 ) then 
                        setTimer(followHim, 10*500/100*10*5-2450, 0, player) -- the result : 50 
                        showCursor( true ) 
                    end 
                end 
            end 
    end 
end) 

Link to comment
Maybe?
ctrlNames = { "forwards","backwards","left","right","jump","sprint","walk","crouch","enter_exit" } 
  
local function followHim(player) 
    for _, ctrl in ipairs(ctrlNames) do 
        setControlState(player,(ctrl),true) 
    end 
end 
  
addEventHandler("onPlayerDamage", root, 
function( attacker, attackerweapon, bodypart, loss ) 
    for _,player in ipairs(getElementsByType("player")) do 
        local policeTeam = getPlayerTeam( attacker ) 
            if ( policeTeam == Police ) and ( attacker == Police ) then 
                if ( wantedLevel > 0 ) then -- wantedLevel is predefined .. 
                    if ( attackerweapon == 3 ) and ( loss > 2 ) then 
                        setTimer(followHim, 10*500/100*10*5-2450, 0, player) -- the result : 50 
                        showCursor( true ) 
                    end 
                end 
            end 
    end 
end) 

No errors but i think it doesn't make sense.

Link to comment
ctrlNames = { "forwards","backwards","left","right","jump","sprint","walk","crouch","enter_exit" } 
  
local function followHim ( player ) 
    for _, ctrl in ipairs ( ctrlNames ) do 
        setControlState ( player, ( ctrl ), true ) 
    end 
end 
setTimer ( followHim, 10*500/100*10*5-2450, 0, player ) -- the result : 50 
  
addEventHandler ( "onPlayerDamage", root, 
    function ( attacker, attackerweapon, bodypart, loss ) 
        if ( attacker ) then 
            local policeTeam = getPlayerTeam ( attacker ) 
            if ( policeTeam == Police ) and ( wantedLevel > 0 ) then 
                if ( attackerweapon == 3 ) and ( loss > 2 ) then 
                    followHim ( source ) 
                    showCursor ( source, true ) 
                end 
            end 
        end 
    end 
) 

That's what you mean? because your script would make every player with these controls, mine will make only the player that got hit.

Link to comment

I just discovered that i just wasting my time with 'setControlState'

so i made a temporary test , and here you are

addEventHandler("onPlayerDamage", root, 
function( attacker, attackerweapon, bodypart, loss ) 
    local policeTeam = getPlayerTeam( attacker ) 
        if ( isElement( policeTeam ) and policeTeam == Police ) then 
        if ( ( wantedLevel or 0 ) >= 1 ) then 
        if ( attackerweapon == 3 ) and ( loss > 2 ) then 
            outputChatBox( getPlayerName( source ) .. " was Jailed by " .. getPlayerName( attacker ) ) 
        end 
        end 
        end 
end) 

if i damaged a person with 1 or more stars , the message won't be appear why ?.

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