Jump to content

'toggleControl' (Bad argument)


FSXTim

Recommended Posts

Hello,

I get errors at all 'toggleControl'-lines (Bad argument).

function playerListKeyPressed ( key, state ) 
    if state == "down" then 
        radioUpState = isControlEnabled ( "radio_next" ) 
        radioDownState = isControlEnabled ( "radio_previous" ) 
        weaponUpState = isControlEnabled ( "next_weapon" ) 
        weaponDownState = isControlEnabled ( "previous_weapon" ) 
         
        toggleControl ( source, "radio_next", false ) 
        toggleControl ( source, "radio_previous", false ) 
        toggleControl ( source, "next_weapon", false ) 
        toggleControl ( source, "previous_weapon", false ) 
         
        if isTimer ( playerListUpdateTimer ) then 
            killTimer ( playerListUpdateTimer ) 
        end 
        scollBarAdjustTimer = setTimer ( reAdjustPlayerListScollBar, 50, -1 ) 
        bindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        bindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        showPlayerList () 
    else 
        toggleControl ( "radio_next", radioUpState ) 
        toggleControl ( "radio_previous", radioDownState ) 
        toggleControl ( "next_weapon", weaponUpState ) 
        toggleControl ( "previous_weapon", weaponDownState ) 
         
        killTimer ( scollBarAdjustTimer ) 
        unbindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        unbindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        guiSetVisible ( gImage["playerList"], false ) 
    end 
end 
bindKey ( "tab", "both", playerListKeyPressed ) 

Greets

Link to comment

I can still toggle the radio.

function playerListKeyPressed (button, state) 
    if state == "down" then  
        toggleControl ( "radio_next", false ) 
        toggleControl ( "radio_previous", false ) 
        toggleControl ( "next_weapon", false ) 
        toggleControl ( "previous_weapon", false ) 
         
        if isTimer ( playerListUpdateTimer ) then 
            killTimer ( playerListUpdateTimer ) 
        end 
        scollBarAdjustTimer = setTimer ( reAdjustPlayerListScollBar, 50, -1 ) 
        bindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        bindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        showPlayerList () 
  
        addEventHandler("onClientPlayerRadioSwitch", getLocalPlayer(),       
            function () 
                setRadioChannel(0)   
            end 
        )    
    else     
         
        toggleControl ( "radio_next", true ) 
        toggleControl ( "radio_previous", true ) 
        toggleControl ( "next_weapon", true ) 
        toggleControl ( "previous_weapon", true ) 
         
        killTimer ( scollBarAdjustTimer ) 
        unbindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        unbindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        guiSetVisible ( gImage["playerList"], false ) 
    end 
end 
bindKey("tab", "both", playerListKeyPressed)  

Greets

Link to comment

Try

function playerListKeyPressed (button, state) 
    if state == "down" then  
        toggleControl ( "next_weapon", false ) 
        toggleControl ( "previous_weapon", false ) 
        addEventHandler("onClientPlayerRadioSwitch", localPlayer, Radio) 
        if isTimer ( playerListUpdateTimer ) then 
            killTimer ( playerListUpdateTimer ) 
        end 
        scollBarAdjustTimer = setTimer ( reAdjustPlayerListScollBar, 50, 1) 
        bindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        bindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        showPlayerList () 
    else 
        removeEventHandler("onClientPlayerRadioSwitch", localPlayer, Radio) 
        toggleControl ( "next_weapon", true ) 
        toggleControl ( "previous_weapon", true ) 
        if isTimer(scollBarAdjustTimer) then killTimer(scollBarAdjustTimer) end 
        unbindKey ( "mouse_wheel_up", "down", playerListScrollUp ) 
        unbindKey ( "mouse_wheel_down", "down", playerListScrollDown ) 
        guiSetVisible ( gImage["playerList"], false ) 
    end 
end 
bindKey("tab", "both", playerListKeyPressed) 
  
function Radio() 
     cancelEvent() 
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...