Jump to content

remotly triggerable...


WASSIm.

Recommended Posts

hi guys i get problem i don't know it... please help

ERROR: Client (WASSIm.) triggered serverside event onPlayerChat, but event is not marked as remotly triggerable

function commandChats(cmd, ...) 
    local msg = table.concat({...}, " ") 
    triggerServerEvent("onPlayerChat", localPlayer, msg, cmd, true)  
end 

Link to comment
You forgot the 'addEvent( ..., true )'?

That's not needed for a default event.

Try doing something like this:

function commandChats(cmd, ...) 
    local msg = table.concat({...}, " ") 
    triggerServerEvent("onPlayerChat", localPlayer, msg, 0, cmd, true) 
end 

Link to comment
  • Moderators

You are totally wrong guys ...

Built-in events can not be triggered at all from scripts. Only the "system" is allowed to trigger built-in events.

But there is a workaround. Basically, you can create your own event (which can be triggered) with a different but similar name.

Then listen for the built-in event to trigger your new event with the same datas.

Then you can use your event everywhere (in the resource) and it will be triggered when the built-in one is triggered by the system and also if you trigger it yourself:

addEventHandler("onCPlayerChat", true) 
  
addEventHandler("onPlayerChat", root, 
function (message, messageType) 
    cancelEvent() 
    triggerEvent("onCPlayerChat", source, message, messageType) 
end) 
  
function myOnPlayerChatHandler(message, messageType) 
    if messageType == 0 then -- global chat 
  
        -- do something 
  
    elseif messageType == 1 then -- /me actions 
  
        -- do something 
  
    elseif messageType == 2 then -- team chat 
  
        -- do something 
  
    end 
end 
addEventHandler("onCPlayerChat", root, myOnPlayerChatHandler) 

You have to code the chat again to make it work again like the original one (using outputChatBox, outputServerLog etc).

Once done, you can trigger onCPlayerChat instead of onPlayerChat.

Link to comment
You are totally wrong guys ...

Built-in events can not be triggered at all from scripts. Only the "system" is allowed to trigger built-in events.

Are you sure? I remember that i was able to trigger onPlayerWasted. But that wasn't using triggerServerEvent but just triggerEvent and the handler was in another resource.

Link to comment
  • Moderators
You are totally wrong guys ...

Built-in events can not be triggered at all from scripts. Only the "system" is allowed to trigger built-in events.

Are you sure? I remember that i was able to trigger onPlayerWasted. But that wasn't using triggerServerEvent but just triggerEvent and the handler was in another resource.

You are totally right, I just tried and it does work with triggerEvent but not with triggerClientEvent and triggerServerEvent.

From server to client event:

ERROR: Server triggered clientside event onClientPlayerWasted, but event is not marked as remotly triggerable

From client to server event:

ERROR: Client (Citizen) triggered serverside event onPlayerWasted, but event is not marked as remotly triggerable

Even if I tried to override the remote triggerable info to true by doing an addEvent with true as 2nd argument.

So yeah we can trigger built in events but not remotly because they have been created as non remote triggerable.

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