Jump to content

speaker


Recommended Posts

Posted

I need help with this code how to add to only admin can place a speaker

function createSpeaker(thePlayer) 
        local x, y, z = getElementPosition(thePlayer) 
        speakerObject = createObject(2229, x, y, z-1) 
    outputChatBox("You have Succesfully created a speaker!", thePlayer, 0, 250, 0) 
        if (isPedInVehicle(thePlayer)) then 
                local vehicle = getPedOccupiedVehicle(thePlayer) 
                attachElements(speakerObject, vehicle) 
                triggerClientEvent(root, "playTheSound", root, x, y, z, vehicle) 
        else 
                triggerClientEvent(root, "playTheSound", root, x, y, z) 
        end 
end 
addCommandHandler("placespeaker", createSpeaker) 
  
function deleteSpeaker(thePlayer) 
        if (isElement(speakerObject)) then 
                destroyElement(speakerObject) 
                outputChatBox("You have Succesfully destroyed the Speaker!", thePlayer, 0, 0, 255) 
                triggerClientEvent("stopTheSound", root) 
        else 
                outputChatBox("Speaker is not created!", thePlayer, 250, 0, 0) 
        end 
end 
addCommandHandler("destroyspeaker", deleteSpeaker) 

Posted

if you have a player var use it or if you use Acl Admin group use this :

  
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 

Posted
if you have a player var use it or if you use Acl Admin group use this :
  
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 

where to put that

Posted
function createSpeaker(thePlayer) 
    if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then  
        outputChatBox("You're not admin",thePlayer,255,0,0)  
        return 
    end 
        local x, y, z = getElementPosition(thePlayer) 
        speakerObject = createObject(2229, x, y, z-1) 
    outputChatBox("You have Succesfully created a speaker!", thePlayer, 0, 250, 0) 
        if (isPedInVehicle(thePlayer)) then 
                local vehicle = getPedOccupiedVehicle(thePlayer) 
                attachElements(speakerObject, vehicle) 
                triggerClientEvent(root, "playTheSound", root, x, y, z, vehicle) 
        else 
                triggerClientEvent(root, "playTheSound", root, x, y, z) 
        end 
end 
addCommandHandler("placespeaker", createSpeaker) 
  
function deleteSpeaker(thePlayer) 
    if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then  
        outputChatBox("You're not admin",thePlayer,255,0,0)  
        return 
    end 
        if (isElement(speakerObject)) then 
                destroyElement(speakerObject) 
                outputChatBox("You have Succesfully destroyed the Speaker!", thePlayer, 0, 0, 255) 
                triggerClientEvent("stopTheSound", root) 
        else 
                outputChatBox("Speaker is not created!", thePlayer, 250, 0, 0) 
        end 
end 
addCommandHandler("destroyspeaker", deleteSpeaker) 

Posted

KariiM, you did the opposite. Lol, you did if the player is admin, then it wont work.

  
function createSpeaker(thePlayer) 
    if not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then 
        outputChatBox("You're not admin",thePlayer,255,0,0) 
        return 
    end 
        local x, y, z = getElementPosition(thePlayer) 
        speakerObject = createObject(2229, x, y, z-1) 
    outputChatBox("You have Succesfully created a speaker!", thePlayer, 0, 250, 0) 
        if (isPedInVehicle(thePlayer)) then 
                local vehicle = getPedOccupiedVehicle(thePlayer) 
                attachElements(speakerObject, vehicle) 
                triggerClientEvent(root, "playTheSound", root, x, y, z, vehicle) 
        else 
                triggerClientEvent(root, "playTheSound", root, x, y, z) 
        end 
end 
addCommandHandler("placespeaker", createSpeaker) 
  
function deleteSpeaker(thePlayer) 
    if isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then 
        outputChatBox("You're not admin",thePlayer,255,0,0) 
        return 
    end 
        if (isElement(speakerObject)) then 
                destroyElement(speakerObject) 
                outputChatBox("You have Succesfully destroyed the Speaker!", thePlayer, 0, 0, 255) 
                triggerClientEvent("stopTheSound", root) 
        else 
                outputChatBox("Speaker is not created!", thePlayer, 250, 0, 0) 
        end 
end 
addCommandHandler("destroyspeaker", deleteSpeaker) 
  

Posted

lol I tought I had added the 'not' before the function, thanks for your attention !

updated the deleteSpeaker function

function deleteSpeaker(thePlayer) 
    if not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin" ) ) then 
        outputChatBox("You're not admin",thePlayer,255,0,0) 
        return 
    end 
        if (isElement(speakerObject)) then 
                destroyElement(speakerObject) 
                outputChatBox("You have Succesfully destroyed the Speaker!", thePlayer, 0, 0, 255) 
                triggerClientEvent("stopTheSound", root) 
        else 
                outputChatBox("Speaker is not created!", thePlayer, 250, 0, 0) 
        end 
end 
addCommandHandler("destroyspeaker", deleteSpeaker) 

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