-.Paradox.- Posted November 4, 2013 Share Posted November 4, 2013 So i made this music player but i want to reduce it into a table, & play every sound with command /music test1 /music test2 etc thanks for helping Client ------americano function music10( name ) local sound = playSound("music/amricano.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "amricano", true ) addEventHandler( "amricano", getRootElement(), music10 ) ------joker function music9( name ) local sound = playSound("music/joker.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "joker", true ) addEventHandler( "joker", getRootElement(), music9 ) ------badboy function music8( name ) local sound = playSound("music/badboys.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "badboys", true ) addEventHandler( "badboys", getRootElement(), music8 ) --------- boys ... ---------- function music7( name ) local sound = playSound("music/boysboysboys.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "boysboysboys", true ) addEventHandler( "boysboysboys", getRootElement(), music7 ) Server ----americano function music(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "vip" ) ) then outputChatBox ( "" .. name .. ": #2600FF We No Speak Americano.", getRootElement(), r, g, b, true ) triggerClientEvent ("amricano", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end addCommandHandler("amricano", music) ----joker function music(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "vip" ) ) then outputChatBox ( "" .. name .. ": #2600FF Giggle bitch.", getRootElement(), r, g, b, true ) triggerClientEvent ("joker", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end addCommandHandler("joker", music) ----badboys function music(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "vip" ) ) then outputChatBox ( "" .. name .. ": #2600FF is a good boy.", getRootElement(), r, g, b, true ) triggerClientEvent ("badboys", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end addCommandHandler("isagoodboy", music) -----boysboysboys-------- addCommandHandler("music.boysboysboys", function (player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "vip" ) ) then outputChatBox ( "" .. name .. ": #2600FF boys boys boys.", getRootElement(), r, g, b, true ) triggerClientEvent ("boysboysboys", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end ) I want it like that /music joker it play joker sound /music badboys it plays bad boys sound etc Link to comment
xXMADEXx Posted November 4, 2013 Share Posted November 4, 2013 You need to make another argument for the "music" function. Link to comment
-.Paradox.- Posted November 4, 2013 Author Share Posted November 4, 2013 It's working good, but i want to reduce it into table and add a command /music [musicname] to get the music from table ['joker'] = ['music/joker.mp3'] or something like that Link to comment
Dealman Posted November 4, 2013 Share Posted November 4, 2013 You could easily google to find out how to work with tables in LUA. There are multiple ways of achieving what you want. It's just a matter of what you prefer and what you find the most efficient. Alternatively you could take a look at the Radio I made, since that uses a table for streaming internet radios. You'll need to modify it a bit, of course. But should point you in the right direction. Link to comment
-.Paradox.- Posted November 4, 2013 Author Share Posted November 4, 2013 Can somebody help me with a code, because idk how to get the command from table and location too. Link to comment
-.Paradox.- Posted November 5, 2013 Author Share Posted November 5, 2013 Just a code, i want in it a table of music locations and command for it Link to comment
pa3ck Posted November 5, 2013 Share Posted November 5, 2013 Like: music = { {"mymusic.mp3"}, {"mymusic2.mp3"}, } addCommandHandler('music', function(cmd, song) if song == '1' then playSound(music[1]) elseif song == '2' then playSound(music[2]) end end) Is that what you need? This might be easier: music = { {"mymusic.mp3"}, {"mymusic2.mp3"}, } addCommandHandler('music', function(cmd, song) local num = tonumber(song) if num and num > 0 and num < 3 then playSound(music[num]) else outputChatBox('Invalid song number', 255, 0, 0) end end) 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