How would I go around making F4 act as a chat command on my server?
5 replies, posted
Basically, I wan't it so that when people press F4 it would display the MOTD(Which is currently done by typing !motd) & another F key will let a user switch teams.
Currently, a user has to type !swap to switch to guards/prisoners.
I am not sure of the code that would work this.
So overall it would be something like
User presses F4
It acts as typing !motd in chat
MOTD appears
or
User presses F4
It acts as if user typed !swap
swap list appears
Use these functions.
[code]
GM:ShowHelp --F1
GM:ShowTeam --F2
GM:ShowSpare1 --F3
GM:ShowSpare2 --F4
[/code]
This will print the player who pressed F1 everytime they press it.
[code]
function GM:ShowHelp( ply )
print( ply.. "pressed F1" )
end
[/code]
You can also hook it like this:
[lua]hook.Add("ShowSpare2","OpenSwapMenu",function(ply)
ply:ConCommand("say !swap")
end)[/lua]
This will make the player say !swap when you press F4, if you wanted motd just replace the !swap with !motd.
[QUOTE=goosey;41230930]You can also hook it like this:
[lua]hook.Add("ShowSpare2","OpenSwapMenu",function(ply)
ply:ConCommand("say !swap")
end)[/lua]
This will make the player say !swap when you press F4, if you wanted motd just replace the !swap with !motd.[/QUOTE]
What there controls which F key makes it say !swap?
[QUOTE=Knill;41232064]What there controls which F key makes it say !swap?[/QUOTE]
[QUOTE=Jarva;41228841][code]
GM:ShowHelp --F1
GM:ShowTeam --F2
GM:ShowSpare1 --F3
GM:ShowSpare2 --F4
[/code][/QUOTE]
ShowSpare2 = F4 and the function that goosey wrote hooks into ShowSpare2. That means that it will check to see if the person is pressing F4 before it runs the function. You can use the chart that Jarva posted and change it to any of the other F buttons.
Thank you very much guys, I really appreciate your help.
Sorry, you need to Log In to post a reply to this thread.