Jump to content

[help]Need Help In Commands


Tarek632

Recommended Posts

No, You'll use theme o check the account of the player that is trying to execute the command .

use getPlayerAccount to get his account, And then use getAccountName to get the name of the player's account, After that use isObjectInACLGroup to check if that account is added to the Admin ( or any group you want ) group .

Link to comment

here is the script

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) 
  

--Can Someone make it for only admins for me?

Link to comment

function createSpeaker(thePlayer) 
    if not isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then 
    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 (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) 
  

Try it.

Link to comment
function createSpeaker(thePlayer) 
    if not isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( thePlayer ) ), aclGetGroup ( "Admin" ) ) then 
    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 (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) 
  

Try it.

Thanks Helped Alot.

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