Jump to content

setControlState problem


Tete omar

Recommended Posts

Posted
  
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'

F4MZM4.gif

Posted

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) 

CiTLh.png
Posted
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.

F4MZM4.gif

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

F4MZM4.gif

Posted

"Police" variable is defined, right?

Also, are you sure the health lost is higher than 2?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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