How to bind commands on keys

I need a script that allows me to bind /me /do on keys on my keyboard…

like I have to press “K” to open my car and I wanna a text like that /me x-y opened his/her car. or something like that I think you know.
I need help with that script: I want to bind the commands on bind like: I don’t have to type /lock I just have to press “K” when I’m close to my car.

client.lua (6.4 KB)
__resource.lua (119 Bytes)
readme.txt (429 Bytes)
server.lua (1.6 KB)

1 Like

You want the command to be /me opens phone
will open their phone??

Citizen.CreateThread(function()
while true do
	Citizen.Wait(100)
	if IsControlJustPressed(1, 51) then -- If E is pressed. Can change to K I just don't know which one K is.
		-- do something
	end
end)

You’d have to factor in distance as well if you want that. Maybe it’s like up to 10-15 feet and then it loses signal. Idk.

2 Likes
Citizen.CreateThread(function()
while true do
	Citizen.Wait(100)
	if IsControlJustPressed(1, 51) and GetLastInputMethod(2) then -- If E is pressed. Can change to K I just don't know which one K is.
		-- do something
	end
end)

This will disable the controllers for issues that you may have with controller support if people are using controllers.

1 Like

Yes, like my phone opens when I press “Y”. I want to bind /me on that button. /me opens his phone

Where would I put this?