[request] TriggerClientEvent

Hello , it’s possible to add TriggerClientEvent in c# lib ?

1 Like

Yes but TriggerClientEvent is needed to send message in chat.

1 Like

TriggerClientEvent is not on the CitizenFX

you are a smart one, TriggerClientEvent is what? it’s triggering the event, you cannot use c# in scripting a server side part, but you can do it with TriggerEvent from the client side, and triggerclientevent from the server side.

For example i need with TriggerClient with player click on button in chat is say " Hello " in c# it’s not possible because the TriggerClientEvent is not here.

yeah , in c# you can script only the client side, so if you want to trigger a client event you just use TriggerEvent, doesn’t matter if it’s LUA or C#, you use TriggerClientEvent only from the server.

Do you have idea to send message in chat with TriggerEvent ?

TriggerEvent(“chatMessage”, “[System]”, { 255,0,0}, “Message.”)
This is a red coulour [System] and regular colour (white ) message ) , this is how you do it in LUA, don’t know in c# but i think it’s something similar.

It’s not working but for c# you need the TriggerClientEvent to send message in chat

For example
menuJ.AddItem(new UIMenuItem(“Discord”, “???”));

with this if player click on the Discord how to send message in chat for the player with the command “/discord”

No you don’t?

TriggerEvent("chatMessage", "", new []{ 0, 0, 0 }, "Yes this is a chat message.");

Ok so where can i put the command in your code

I want to show the discord with the command /discord on your code how to add a command /discord ?

and why do you need c# for that?

Client.lua

RegisterNetEvent("discordmsg")
AddEventHandler('discordmsg', function()
	local ped = GetPlayerPed(-1)
	if DoesEntityExist(ped) then
		TriggerEvent("chatMessage", "SYSTEM", { 255,0,0}, " Our discrod adress is : Your Discord")
	end
end)

server.lua

AddEventHandler('chatMessage', function(source, n, message)
    cm = stringsplit(message, " ")

    if(cm[1] == "/discord") then
		CancelEvent()
		TriggerClientEvent("discordmsg", source)

function stringsplit(self, delimiter)
  local a = self:Split(delimiter)
  local t = {}

  for i = 0, #a - 1 do
     table.insert(t, a[i])
  end

  return t
end

this took like 3 minutes in lua, don’t know why go with C# for this.