dewu Posted January 9, 2014 Share Posted January 9, 2014 Hi guys, i got the question: How to set bind to turn on/off the flashlight, without use /flashlight command? https://community.multitheftauto.com/ind ... ls&id=6858 can be another script, but with bind function and without command runs. Link to comment
Lloyd Logan Posted January 9, 2014 Share Posted January 9, 2014 Hi guys, i got the question: How to set bind to turn on/off the flashlight, without use /flashlight command?https://community.multitheftauto.com/ind ... ls&id=6858 can be another script, but with bind function and without command runs. Do you mean; INGAME /bind flashlight Is that what you mean? Link to comment
dewu Posted January 9, 2014 Author Share Posted January 9, 2014 (edited) I don't mean command. I mean when i click ex. "B" button on the keyboard, flashlight will be turn on/off. In this res first i must type /flashlight command to enable. Edited January 9, 2014 by Guest Link to comment
Gallagher Posted January 9, 2014 Share Posted January 9, 2014 Hi guys, i got the question: How to set bind to turn on/off the flashlight, without use /flashlight command?https://community.multitheftauto.com/ind ... ls&id=6858 can be another script, but with bind function and without command runs. you want to turn on the flashlight? Link to comment
Lloyd Logan Posted January 9, 2014 Share Posted January 9, 2014 I don't mean command.I mean when i click ex. "B" button on the keyboard, flashlight will be turn on/off. In this script first i must type /flashlight command to enable. You type in the chat box /bind b flashlight After this, when you click "b" the flashlight will turn on and off Link to comment
dewu Posted January 9, 2014 Author Share Posted January 9, 2014 I create MTA: DayZ Server. I don't want to use it in single, but on my server where players to turn on/off light just must use a key without earlier binding. Link to comment
Gallagher Posted January 9, 2014 Share Posted January 9, 2014 I create MTA: DayZ Server.I don't want to use it in single, but on my server where players to turn on/off light just must use a key without earlier binding. I do not know if you know, but this feature causes lag Link to comment
dewu Posted January 9, 2014 Author Share Posted January 9, 2014 Hmm.. so maybe is way to auto-exucute command when log-in? Link to comment
Karuzo Posted January 9, 2014 Share Posted January 9, 2014 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
dewu Posted January 9, 2014 Author Share Posted January 9, 2014 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
Karuzo Posted January 9, 2014 Share Posted January 9, 2014 try this : bindKey("b","down", toggLight) i dont know if toggleLight is used to switch it off also , but if it is youll need an if i think . Ex : if switched == on then --- if switched == off then -- Greets, Sent from my Phone. Link to comment
WASSIm. Posted January 10, 2014 Share Posted January 10, 2014 1) change line 18 to "false" to "true" 2) change line 27 'r' ti key you want Link to comment
dewu Posted January 11, 2014 Author Share Posted January 11, 2014 Ok, works, thanks. Is this way to control the light ingame? I want to steer flashlight shader. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now