Jump to content

Event doesn't trigger


Recommended Posts

Hey there!

My problem now is that an event doesn't trigger when it should.

I used this for triggering:

triggerClientEvent("sendChatMessage", source, "Hello there.")

And I have added the event client-side:

function sendChatMessage(text)
local ptext = guiGetText(chatLabel)
guiSetText(chatLabel, "" .. ptext .. "\n" .. text .. "")
end
addEvent("sendChatMessage", true)
addEventHandler("sendChatMessage", getRootElement(), sendChatMessage)

Though, suprisingly, the same event DOES trigger when I call it from the same server-side script, this one:

triggerClientEvent("sendChatMessage", playerid, "You have been successfully registered and logged in.")

I am guessing it is the two different player variables. One of them is source and the other one is playerid. I forward playerid from getLocalPlayer in another client-side script.

What's wrong?

Link to comment
triggerClientEvent("sendChatMessage", source, "Hello there.")

So if that doesn't work, and yet the other version of it does, the only explination is that the theElement argument is not correct.

P.S: If there is no argument before the event name, the event will be triggered for all players.

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