Jump to content

Flashlight bind


dewu

Recommended Posts

What are you talking about ReX?

Hes probably talking about bindKey.

@dewu: just use the functiom bindKey ,

example :

bindKey("b", "down", function) 

Just put this under your flashlight function and change "function" in the bindKey Event above to your functionname.

Sent from my phone.

Link to comment

Yes! It is that what i mean ;)

but, don't know why it's not working.

I've changed:

  
-- start or stop using flashlight 
function toggleFlashLight() 
if flashLiTable.flModel[getLocalPlayer()] then  
    outputChatBox('You have disabled the flashlight',0,255,0) 
    triggerServerEvent("onSwitchLight",getLocalPlayer(),false) 
    triggerServerEvent("onSwitchEffect",getLocalPlayer(),false) 
    isLightOn = false 
    unbindKey(switch_key,"down",toggleLight) 
else 
    outputChatBox('You have enabled the flashlight',0,255,0) 
    triggerServerEvent("onSwitchLight",getLocalPlayer(),false) 
    triggerServerEvent("onSwitchEffect",getLocalPlayer(),true) 
    bindKey(switch_key,"down",toggleLight) 
    end 
end 
  
--------------------------------------------------------------------------------------------------- 
         
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource()), function() 
    local ver = getVersion ().sortable 
    local build = string.sub( ver, 9, 13 ) 
    if build<"04938" or ver < "1.3.1" then  
        outputChatBox('The resource is not compatible with this client version!',255,0,0) 
        return 
    end 
    local isEffectValid 
    if (vCardPSVer()~="3") then  
        outputChatBox('Flashlight: Shader Model 3 not supported',255,0,0) 
        isFullShader = false 
        isEffectValid = createWorldLightShader(0) 
    else 
        isFullShader = true 
        isEffectValid = createWorldLightShader(2) 
    end 
    if not isEffectValid then  
        outputChatBox('Flashlight effect failed to start!',255,0,0)  
        return  
    else 
        outputChatBox('Shader flashlight test ver 1.06 has started.',255,255,0) 
    end 
    engineImportTXD( engineLoadTXD( "objects/flashlight.txd" ), objID )  
    engineReplaceModel ( engineLoadDFF( "objects/flashlight.dff", 0 ), objID,true) 
    triggerServerEvent("onPlayerStartRes",getLocalPlayer()) 
    if autoEnableFL then  
        toggleFlashLight()  
    else 
        outputChatBox('Type /flashlight to enable the flashlight ',255,255,0) 
    end 
    outputChatBox('Hit '..switch_key..' to turn on/off the flashlight',255,255,0) 
    addCommandHandler("flashlight",toggleFlashLight) 
end 
) 

to

  
-- start or stop using flashlight 
function toggleFlashLight() 
if flashLiTable.flModel[getLocalPlayer()] then  
    outputChatBox('You have disabled the flashlight',0,255,0) 
    triggerServerEvent("onSwitchLight",getLocalPlayer(),false) 
    triggerServerEvent("onSwitchEffect",getLocalPlayer(),false) 
    isLightOn = false 
    unbindKey("b","down",toggleLight) 
else 
    outputChatBox('You have enabled the flashlight',0,255,0) 
    triggerServerEvent("onSwitchLight",getLocalPlayer(),false) 
    triggerServerEvent("onSwitchEffect",getLocalPlayer(),true) 
    bindKey("b","down",toggleLight) 
    end 
end 
  
--------------------------------------------------------------------------------------------------- 
         
addEventHandler("onClientResourceStart", getResourceRootElement( getThisResource()), function() 
    local ver = getVersion ().sortable 
    local build = string.sub( ver, 9, 13 ) 
    if build<"04938" or ver < "1.3.1" then  
        outputChatBox('The resource is not compatible with this client version!',255,0,0) 
        return 
    end 
    local isEffectValid 
    if (vCardPSVer()~="3") then  
        outputChatBox('Flashlight: Shader Model 3 not supported',255,0,0) 
        isFullShader = false 
        isEffectValid = createWorldLightShader(0) 
    else 
        isFullShader = true 
        isEffectValid = createWorldLightShader(2) 
    end 
    if not isEffectValid then  
        outputChatBox('Flashlight effect failed to start!',255,0,0)  
        return  
    else 
        outputChatBox('Shader flashlight test ver 1.06 has started.',255,255,0) 
    end 
    engineImportTXD( engineLoadTXD( "objects/flashlight.txd" ), objID )  
    engineReplaceModel ( engineLoadDFF( "objects/flashlight.dff", 0 ), objID,true) 
    triggerServerEvent("onPlayerStartRes",getLocalPlayer()) 
    if autoEnableFL then  
        toggleFlashLight()  
    else 
        outputChatBox('Type /flashlight to enable the flashlight ',255,255,0) 
    end 
    outputChatBox('Hit '..switch_key..' to turn on/off the flashlight',255,255,0) 
end 
) 

Also I deleted line with addCommandHandler

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