bradio10 Posted April 12, 2014 Posted April 12, 2014 Hi, I am wanting to make a BPM counter with DX so that it will move up and down to the beat. I'm not sure if this would be the way to do it but I have tried this way and it spams in the debug saying a userdata value function test() sound = playSound("playerpics/song.mp3") counter = setTimer(function() getSoundBPM() end, 50, 0) addEventHandler("onClientRender", root, bpmCounterDX) end addCommandHandler("testbpm", test) function bpmCounterDX() dxDrawRectangle(1062, 484, 15, 112/1000*counter, tocolor(184, 1, 5, 255), true) dxDrawRectangle(1099, 484, 15, 112/1000*counter, tocolor(156, 20, 161, 255), true) dxDrawRectangle(1135, 484, 15, 112/1000*counter, tocolor(7, 161, 175, 255), true) dxDrawRectangle(1173, 484, 15, 112/1000*counter, tocolor(172, 178, 5, 255), true) dxDrawRectangle(1209, 484, 15, 112/1000*counter, tocolor(7, 182, 2, 255), true) end ERROR: musicplayer\client.lua:49: attempt to perform arithmetic on global 'counter' (a userdata value) What is wrong and what is a userdata? Thanks. Streamline Servers Vultr.com | Worldwide VPS's at an awesome price. Buy one here!
bradio10 Posted April 14, 2014 Author Posted April 14, 2014 bump Streamline Servers Vultr.com | Worldwide VPS's at an awesome price. Buy one here!
Woovie Posted April 14, 2014 Posted April 14, 2014 Userdata is an MTA element. If you bothered to read the wiki entry for setTimer, you would see it returns a timer element. Furthermore, you need to change line 3 to look like this. counter = setTimer(getSoundBPM, 50, 0) I don't understand at all what you're attempting to do with this, but you're doing it wrong. "The humble beet is the answer to all riddles." - Rolf
Moderators IIYAMA Posted April 14, 2014 Moderators Posted April 14, 2014 I think he means this. local counter = 1 function test() sound = playSound("playerpics/song.mp3") setTimer(function() counter = getSoundBPM() end, 50, 0) addEventHandler("onClientRender", root, bpmCounterDX) end addCommandHandler("testbpm", test) function bpmCounterDX() dxDrawRectangle(1062, 484, 15, 112/1000*counter, tocolor(184, 1, 5, 255), true) dxDrawRectangle(1099, 484, 15, 112/1000*counter, tocolor(156, 20, 161, 255), true) dxDrawRectangle(1135, 484, 15, 112/1000*counter, tocolor(7, 161, 175, 255), true) dxDrawRectangle(1173, 484, 15, 112/1000*counter, tocolor(172, 178, 5, 255), true) dxDrawRectangle(1209, 484, 15, 112/1000*counter, tocolor(7, 182, 2, 255), true) end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
bradio10 Posted April 15, 2014 Author Posted April 15, 2014 Ok, sorry, I misunderstood BPM and stuff. I thought I could get the BPM and make a visualizer with DX. If anybody has any ideas on how to do that, please comment. Streamline Servers Vultr.com | Worldwide VPS's at an awesome price. Buy one here!
.:HyPeX:. Posted April 15, 2014 Posted April 15, 2014 There's a resource called "visualizer" already, you should check it out, and read it. (It comes by default with mta) My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
bradio10 Posted April 15, 2014 Author Posted April 15, 2014 Oh, I never knew that, this is pretty cool. Thanks for that. Streamline Servers Vultr.com | Worldwide VPS's at an awesome price. Buy one here!
.:HyPeX:. Posted April 15, 2014 Posted April 15, 2014 You're Welcome My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
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