[DMC] Posted July 4, 2010 Share Posted July 4, 2010 i tried making a admin only command for client and server side if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then could anyone post an example of how to make something admin only? Link to comment
dzek (varez) Posted July 4, 2010 Share Posted July 4, 2010 (edited) addCommandHandler("killAll", function(thePlayer) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))) then local players=getElementsByType("player") for key,val in ipairs(players) do killPed(val) end outputChatBox("* "..getPlayerName(thePlayer).." killed all players *", getRootElement(), 255, 0, 0) else outputChatBox("* You need to be admin to kill all players *", thePlayer, 255, 0, 0) end end) and for client-side, you have to check it like that (but i dont see a point in client-side admin thing) --[[ ***************** client-side part ***************** ]] addCommandHandler("pushMyCarClientSide", function() triggerServerEvent("checkAdmin", getLocalPlayer(), "pushMyCarClientSideEvent") -- 3rd argument is the event we want to trigger after check end) addEvent("pushMyCarClientSideEvent", true) addEventHandler("pushMyCarClientSideEvent", getRootElement(), function() local veh = getPedOccupiedVehicle(getLocalPlayer()) if (veh) then local xx,yy,zz = getElementVelocity(veh) setElementVelocity(veh, xx,yy,zz+4) else outputChatBox("* You need to be in car *", 255, 0, 0) end end) --[[ ***************** server-side part ***************** ]] addEvent("adminCheck", true) addEventHandler("adminCheck", getRootElement(), function(eventToFire) if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))) then triggerClientEvent(source, eventToFire, source) else outputChatBox("* You need to be an admin *", source, 255, 0, 0) end ) Edited July 4, 2010 by Guest Link to comment
[DMC] Posted July 4, 2010 Author Share Posted July 4, 2010 this doesnt work function PlayMusic() if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))) then triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) end addCommandHandler("mario", PlayMusic) Link to comment
dzek (varez) Posted July 4, 2010 Share Posted July 4, 2010 (edited) DEBUG FFS! function PlayMusic(thePlayer) -- edited if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin"))) then triggerClientEvent(getRootElement(), "playMyMusic", getRootElement()) end end addCommandHandler("mario", PlayMusic) Edited July 4, 2010 by Guest Link to comment
dzek (varez) Posted July 4, 2010 Share Posted July 4, 2010 and wtf is "thePlayer".. you asked for example, i gave you one, but you have to have the slightest idea about WHAT YOU ARE ACTUALLY DOING Link to comment
Lordy Posted July 4, 2010 Share Posted July 4, 2010 @[DMC] It's not like you write something and if it doesn't work out from the box, you just dump it here. Please read the wiki article on debugging. If you had any idea what you were doing, you would have seen that at first the script wouldn't have loaded because syntax errors. Then you could have fixed the missing 'end'. Then it would have told you that there is something wrong on line two. You should have seen that you have no thePlayer variable declared anywhere. Could have fixed that yourself and saved a lot of time. Yours aswell as ours. The debugscript and error messages aren't just some random "it throws an eror! attmept to balha blah help me". All the error messages are very descriptive and helpful for debugging. 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