Jump to content

admin only


[DMC]

Recommended Posts

i tried making a admin only command for client and server side :cry:

if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then

could anyone post an example of how to make something admin only? :wink:

Link to comment
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 by Guest
Link to comment

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

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 by Guest
Link to comment

@[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

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