Trigger client event

Hello, I have a k9 script that I want to be able to trigger from police F6 menu, but i can not get i to work, what I have done so far is, creating translation and gived it a place in F6.
esx_policejob/client/main
This is for when pressing the button in menu

elseif action == 'polishund' then

                        TriggerServerEvent('esx_policejob:openMenuX')

This is esx_policejob/server/main

RegisterNetEvent('esx_policejob:openMenuX')

AddEventHandler('esx_policejob:openMenuX', function()

    TriggerClientEvent('esx_policedog:openMenu', function()

end)

K9 scrit client

RegisterNetEvent('esx_policedog:openMenu')

AddEventHandler('esx_policedog:openMenu', function()

    mainMenu()

end)

How do i trigger the client function in k9 with button in police F6?

you need to change the function() to source)
like this TriggerClientEvent('esx_policedog:openMenu', source)

Im at work but when i come home i will try and replay how it went

Just tried it out and it does not work

Well depends on what do you have in mainMenu() function

Im not sure if it is ok for me to share this thou i am not the author but the first rows say

mainMenu = function()

    if PlayerData.job.name == Config.Job then

        ESX.UI.Menu.CloseAll()

        ESX.UI.Menu.Open(

                'default', GetCurrentResourceName(), 'buy_storage',

            {

I assume you want the K9 dog listed in the menu from the policejob right ?

should work, and btw why would you need to triggerserverevent? you can just directly TriggerEvent from here

elseif action == 'polishund' then

                        TriggerEvent('esx_policedog:openMenu')

Yes that is right!

because both functions are client sided, the police f6 menu and the k9 menu in the k9, im have recently began scriptning and I have been told that you can not trigger a client event from client side

lol of course you can trigger a client event from client side, who says you can’t

I did not know that, I will try that seems easier so

This is so wired, I tried the same function on another menu and it worked, but it does not work on the policejob

The code i used in the other script

elseif usage == 'test' then

            TriggerEvent('esx_policedog:openMenu')

FINALLY SOLVED!

For you who want to know how to add triggers in the F6 menu in the same coloum, you have to trigger it throu

if data.current.value == 'polishund' then

            TriggerEvent('esx_policedog:openMenu')

        end

It is below the labels and values… :slight_smile: