AlvarO Posted October 18, 2015 Share Posted October 18, 2015 CLIENT sounds = { shutup = {"sound/ahahshutup.mp3", "Shut up!"}, airhorn = {"sound/airhorn.wav", "Air horn!"}, amazing = {"sound/AMAZING.WAV", "AMAZING!"}, andwheni = {"sound/andwheni.mp3", "And when I say jump, you say, how high?"}, apologize = {"sound/apologize.mp3", "Apologize!"}, blew = {"sound/blew.mp3", "Blew!"}, hello1 = {"sound/HELLO.WAV", "Hello!"}, hello2 = {"sound/HelloNoob.mp3", "Hello noob!"}, } local sonidos = {} for k,sound in ipairs(getElementsByType("sound")) do table.insert(sonidos,sound) end function playSounds( cmd, type, sound) if type then if getElementsByType("sound") then outputChatBox("A sound has been played by: "..getPlayerName(localPlayer).." #ffffff[#ad2525"..sounds[type][2].."#ffffff]", 255, 255, 255, true) sonido = playSound(sounds[type][1]) end end end addEvent("onStartSound", true) addEventHandler("onStartSound", root, playSounds) addEventHandler("onClientResourceStart", getRootElement(), playSounds) SERVER function funcionDeSaberSiEsAdmin(client) local pAccount = getPlayerAccount(client) local accName = getAccountName(pAccount) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then triggerClientEvent ( client, "onStartSound", client) else outputChatBox("You're not admin!", getRootElement(), 255, 0, 0) end end addCommandHandler("sound", funcionDeSaberSiEsAdmin) Nothing in debug, and sound is not reproduced, help? Link to comment
bebo1king Posted October 18, 2015 Share Posted October 18, 2015 sounds = { shutup = {"sound/ahahshutup.mp3", "Shut up!"}, airhorn = {"sound/airhorn.wav", "Air horn!"}, amazing = {"sound/AMAZING.WAV", "AMAZING!"}, andwheni = {"sound/andwheni.mp3", "And when I say jump, you say, how high?"}, apologize = {"sound/apologize.mp3", "Apologize!"}, blew = {"sound/blew.mp3", "Blew!"}, hello1 = {"sound/HELLO.WAV", "Hello!"}, hello2 = {"sound/HelloNoob.mp3", "Hello noob!"}, } local sonidos = {shutup,airhorn,amazing,andwheni,apologize,blew,hello1,hello2} for k,sound in ipairs(getElementsByType("sound")) do table.insert(sonidos,sound) end Link to comment
AlvarO Posted October 18, 2015 Author Share Posted October 18, 2015 Well, I think you didn't get the idea, I want that when a ADMIN player writes the command and the sound, the sound reproduces, and when the player is NOT admin, output the message. Link to comment
Fist Posted October 18, 2015 Share Posted October 18, 2015 Im not sure or this is what u want but basicly i made script that will play sound what admin is choosed to every player what is in server. CLIENT: sounds = { -- {"soundname.mp3",soundNumber} {"crafting.mp3",1}, {"fire.mp3",2}, } prefix = "[ADMIN SOUNDS]" function playAdminSound(source,sound) local player = getPlayerName(source) for _,value in ipairs(sounds) do if tonumber(sound) == value[2] then playSound("sounds/"..value[1],false) outputChatBox(prefix.." Sound was played by "..player.." and sound number is "..sound) end end end addEvent("playAdminSound",true) addEventHandler("playAdminSound",root,playAdminSound) SERVER: prefix = "[ADMIN SOUNDS]" function adminSoundCommand(source,cmd,sound) account = getAccountName(getPlayerAccount(source)) if isObjectInACLGroup("user."..account,aclGetGroup("Admin")) then if sound ~= nil then triggerClientEvent(root,"playAdminSound",root,source,sound) else outputChatBox(prefix.." Please type command correct! example: /asound (1-2)",source) end else outputChatBox(prefix.." You must have admin access to use this command!",source) end end addCommandHandler("asound",adminSoundCommand) 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