Chopper Posted June 18, 2013 Share Posted June 18, 2013 Hello everyone. Can anyone help me with this? I want to make the 2 functions to execute, only when the player who uses it is an admin in the acl. function duty() local name = getPlayerName(getLocalPlayer()) local sound = playSound ("files/sound.mp3") setSoundVolume (sound,0.5) panel = guiCreateStaticImage(432, 566, 447, 172, "files/bg.png", false) text = guiCreateLabel(443, 713, 426, 15, name.. " is now on adminduty!", false) guiSetFont(text, "default-bold-small") guiLabelSetColor(text, 252, 229, 230) guiLabelSetHorizontalAlign(text, "center", false) setTimer ( function() --Időzítőt beállítja// guiSetVisible (panel, false) --Panel láthatatlan// guiSetVisible (text, false) --text láthatatlan// end, 5000, 1 ) --5000=5 mp// end function offduty() local name = getPlayerName(getLocalPlayer()) local sound = playSound ("files/sound.mp3") setSoundVolume (sound,0.5) panel = guiCreateStaticImage(432, 566, 447, 172, "files/bg.png", false) text = guiCreateLabel(443, 713, 426, 15, name.. " is now off adminduty!", false) guiSetFont(text, "default-bold-small") guiLabelSetColor(text, 252, 229, 230) guiLabelSetHorizontalAlign(text, "center", false) setTimer ( function() guiSetVisible (panel, false) guiSetVisible (text, false) end, 5000, 1 ) end addCommandHandler ("aduty", duty) addCommandHandler ("offduty", offduty) Thanks if anyone can help me. Link to comment
Dealman Posted June 18, 2013 Share Posted June 18, 2013 When the commands are entered, use triggerServerEvent in which checks if the player is an Admin or not, with isObjectInACLGroup. If the Player's an Admin, then use triggerClientEvent to trigger the functions duty and offduty. Client-Side: -- Create a function which will trigger a server event to check the player's permissions. function adminDuty_Check_Permission() triggerServerEvent("checkIfAdmin", getLocalPlayer()) end addCommandHandler("aduty", adminDuty_Check_Permissions, false) -- Your function. function duty() local name = getPlayerName(getLocalPlayer()) local sound = playSound ("files/sound.mp3") setSoundVolume (sound,0.5) panel = guiCreateStaticImage(432, 566, 447, 172, "files/bg.png", false) text = guiCreateLabel(443, 713, 426, 15, name.. " is now on adminduty!", false) guiSetFont(text, "default-bold-small") guiLabelSetColor(text, 252, 229, 230) guiLabelSetHorizontalAlign(text, "center", false) setTimer ( function() --Időzítőt beállítja// guiSetVisible (panel, false) --Panel láthatatlan// guiSetVisible (text, false) --text láthatatlan// end, 5000, 1 ) --5000=5 mp// end addEvent("adminOnDuty", true) -- Create an Event for this function. addEventHandler("adminOnDuty", getRootElement(), duty) -- Use the new event to handle the function. Server-Side: -- Create a function which checks the permissions and if true, triggers the function "duty" for the player. Else outputs an error message. function checkIfAdmin_Handler(thePlayer) local accountName = getAccountName(getPlayerAccount(thePlayer)) if(isObjectInACLGroup("user."..accountName, aclGetGroup("admin")) then triggerClientEvent(thePlayer, "adminOnDuty". getRootElement()) else outputChatBox("[server]: You don't have permission to use that!", thePlayer, 255, 0, 0, true) end end addEvent("checkIfAdmin", true) addEventHandler("checkIfAdmin", getRootElement(), checkIfAdmin_Handler) Link to comment
Chopper Posted June 18, 2013 Author Share Posted June 18, 2013 There were several bugs i had to fix, but still not working. Link to comment
Dealman Posted June 18, 2013 Share Posted June 18, 2013 Yeah I wrote it out of memory so might have missed something, sorry about that Glad you got it sorted at least 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