Jump to content

Triggering events


myonlake

Recommended Posts

Posted (edited)

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
Posted

what is the purpose of this? what's wrong with addCommandHandler?

anyway, your problem is stated in that error message. it means that your server part either not running or stops somewhere before the event is added.

Posted

Cool, just found out my god damn XML file had wrong type on the server thing. It had client, no shit it didn't work - thanks anyways :)

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