Last active
December 31, 2015 09:09
-
-
Save SDraw/7964730 to your computer and use it in GitHub Desktop.
[MTA] L\R level
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local handl = nil | |
local sx,_ = guiGetScreenSize() | |
local colors = { tocolor(255,0,0),tocolor(0,255,0) } | |
function clientRenderFunc() | |
if(handl) then | |
local ls,rs = getSoundLevelData(handl) | |
if(ls ~= false) then | |
dxDrawRectangle(sx/2-10,0,10,128*(ls/32768),colors[1]) | |
dxDrawRectangle(sx/2+10,0,10,128*(rs/32768),colors[2]) | |
end | |
end | |
end | |
function clientSoundStopFunc(_) | |
if(source == handl) then | |
removeEventHandler("onClientRender",root,clientRenderFunc) | |
removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) | |
handl = nil | |
end | |
end | |
function musicStartFunc() | |
if(not handl) then | |
handl = playSound('nya.mp3') | |
addEventHandler("onClientRender",root,clientRenderFunc) | |
addEventHandler("onClientSoundStopped",root,clientSoundStopFunc) | |
end | |
end | |
function musicStopFunc() | |
if(handl) then | |
stopSound(handl) | |
handl = nil | |
removeEventHandler("onClientRender",root,clientRenderFunc) | |
removeEventHandler("onClientSoundStopped",root,clientSoundStopFunc) | |
end | |
end | |
bindKey("9","down",musicStartFunc) | |
bindKey("0","down",musicStopFunc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment