Hi all , i know this sound stupid but i can not get it right.
i have made a small script to make a sound when the F key are pressed for the flash light that part work
My problem is ... I only want the prompt part : Prompt (" Press F for flash light ") to only prompt if the flash light is off.
but it stays on .
please check my script and help me.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Enters Sound Zone
local flashlight_key = 33 -- f key
function flash_light_init(e)
once = 0
end
function flash_light_main(e)
if g_Scancode ~= flashlight_key then
fls_light = 0
torch_on = 0
end
---prompt for flash light ---
if fls_light == 0 and torch_on == 0 then
Prompt(" Press F for flash light ")
end
------------ torch on -------
if GetInKey() == "f" or GetInKey() == "F" and once == 0 and fls_light == 0 and torch_on == 0 then
if once == 0 then
PlaySound(e, 0)
torch_on = 1
once = 1
end
end
-----------torch 0ff -----
if GetInKey() == "f" or GetInKey() == "F" and once == 1 and fls_light == 0 and torch_on == 1 then
if once == 1 then
PlaySound(e, 0)
torch_on = 0
once = 0
end
end
end
Thanks for any help.
Pcs
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11
The author of this post has marked a post as an answer.
Go to answer