Jump to content

Triggering events


myonlake

Recommended Posts

Hello,

It seems that this code gives me an error: "Client triggered serverside event onCommand, but event is not added serverside"

Client-side

function onTrigger(cmd) 
    triggerServerEvent("onCommand", getLocalPlayer()) 
end 
addCommandHandler("cmds", onTrigger) 
  
function onTrigger1() 
    guiSetVisible(window2, true) 
    showCursor(true) 
end 
addEvent("onTriggerCommand1", true) 
addEventHandler("onTriggerCommand1", getRootElement(), onTrigger1) 
  
function onTrigger2() 
    guiSetVisible(window, true) 
    showCursor(true) 
end 
addEvent("onTriggerCommand2", true) 
addEventHandler("onTriggerCommand2", getRootElement(), onTrigger2) 
 

Server-side

function commandHandler(player) 
    local account = getAccountName(getPlayerAccount(player)) 
     
    if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then 
        triggerClientEvent("onTriggerCommand1", player) 
    end 
     
    if isObjectInACLGroup("user." .. account, aclGetGroup("MemberExtra")) then 
        triggerClientEvent("onTriggerCommand2", player) 
    end 
end 
addEvent("onCommand", true) 
addEventHandler("onCommand", getRootElement(), commandHandler) 
 

I haven't put the GUI on the code because it's not necessarry.

Edited by myonlake
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...