How to Execute a chat command via GUI?

Hi , I try to execute the command /id by clicking on a GUI menu.

I have no idea which code should I use

Thx for your help !

Instead of execute a command, maybe try to trigger an event

So This my command creation , how can I trigger this command in a GUI ?

– ID
TriggerEvent(‘es:addCommand’, ‘id’, function(source, args, user)
TriggerEvent(‘es:getPlayerFromId’, source, function(user)
local pos = user.coords

	TriggerEvent('es:getPlayers', function(players)
	for id,_ in pairs(players) do
		if(GetPlayerName(id))then
			TriggerEvent('es:getPlayerFromId', id, function(target)
				local pPos = target.coords

				local range = get3DDistance(pos.x, pos.y, pos.z, pPos.x, pPos.y, pPos.z)

				local tag = ""
				for k,v in ipairs(tags)do
					if(user.permission_level >= v.rank)then
						tag = v.tag
					end
				end

				TriggerEvent("es_roleplay:getPlayerJob", user.identifier, function(job)
					local dJob = "None"
					if(job)then
						dJob = job.job .. " ^0^r(^2^*" .. job.id .. "^0^r)"
					end

					if(range < 10.0)then
						TriggerClientEvent('chatMessage', id, "", {0, 0, 200}, "^2^*" .. GetPlayerName(source) .. "'s ID")
						TriggerClientEvent('chatMessage', id, "", {0, 0, 200}, "Name: ^2^*" .. GetPlayerName(source) .. "")
						TriggerClientEvent('chatMessage', id, "", {0, 0, 200}, "Job: ^2^*" .. dJob)
					end

				end)
			end)
		end
	end
end)
end)

end)

I don’t know, I never use GUI on my scripts (for the moment), but try to see an example with vdk_inventory for example

Then other question, how to execute a chat command by any means from client side? Except typing manually in chat.

i really wish to know what he is saying… how we can do this ? anyone know this? help!

how to execute a chat command by any means from client side? Except typing manually in chat. Need to know this asap please :smiley:

Maybe try looking at resources that already do it?

Radial menu is a good example
this is what it does to trigger the command:

ExecuteCommand(commandhere)

heres a link to his script in case you need more

1 Like

Thanks , yeah i figure out it was using that ExecuteCommand() . its works thank you.

yeah literally use ExecuteCommand('id')

2 Likes