Tarek632 Posted April 28, 2013 Share Posted April 28, 2013 Need A command in a resource to work only for admins and mods Link to comment
iPrestege Posted April 28, 2013 Share Posted April 28, 2013 addCommandHandler isObjectInACLGroup getAccountName Use these . Link to comment
Sasu Posted April 28, 2013 Share Posted April 28, 2013 addCommandHandler isObjectInACLGroup getAccountName Use these . Also, getPlayerAccount Link to comment
Tarek632 Posted April 29, 2013 Author Share Posted April 29, 2013 I just place Them at the beginning of the script? Link to comment
PaiN^ Posted April 29, 2013 Share Posted April 29, 2013 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
Tarek632 Posted April 29, 2013 Author Share Posted April 29, 2013 so after isObjectInACLGroup in do isObjectInACLGroup(admin) Link to comment
iPrestege Posted April 29, 2013 Share Posted April 29, 2013 No you have to learn somethings about lua . Link to comment
Tarek632 Posted April 29, 2013 Author Share Posted April 29, 2013 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
Tarek632 Posted April 29, 2013 Author Share Posted April 29, 2013 No you have to learn somethings about lua . I know LUA but not for MTA, I wrote the script above can someone make it only for admin??? Link to comment
iPrestege Posted April 29, 2013 Share Posted April 29, 2013 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
Tarek632 Posted April 29, 2013 Author Share Posted April 29, 2013 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
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