Jump to content

[HELP] Only admins can do this


AlvarO

Recommended Posts

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
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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...