bradio10 Posted April 12, 2014 Share 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. Link to comment
Woovie Posted April 14, 2014 Share 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. Link to comment
Moderators IIYAMA Posted April 14, 2014 Moderators Share 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 Link to comment
bradio10 Posted April 15, 2014 Author Share 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. Link to comment
.:HyPeX:. Posted April 15, 2014 Share 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) Link to comment
bradio10 Posted April 15, 2014 Author Share Posted April 15, 2014 Oh, I never knew that, this is pretty cool. Thanks for that. 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