Skip to content

Instantly share code, notes, and snippets.

@EncodeTheCode
Last active May 6, 2023 21:46
Show Gist options
  • Save EncodeTheCode/9a57a85474491120190218d07cabcd18 to your computer and use it in GitHub Desktop.
Save EncodeTheCode/9a57a85474491120190218d07cabcd18 to your computer and use it in GitHub Desktop.
function c_msg(p,r,g,b,m,c)
r,g,b,c=r or '0',g or '0',b or '0',c or ''
local k = string.format("%s%s%s%s", string.char(169), r, g, b)
-- k=string.sub(k,1,-1)
-- k=string.gsub(k,"%s+","")
msg2(p, k .. m .. c);
end
function onPlayerKeyPress(id,key,state)
if(state==1)then
if(key=="W") then
-- msg("W is pressed!")
c_msg(id,102,255,102,'W is pressed!','@C')
elseif(key=="A") then
msg("A is pressed!")
c_msg(id,102,255,102,'A is pressed!','@C')
elseif(key=="S") then
msg("S is pressed!")
c_msg(id,102,255,102,'S is pressed!','@C')
elseif(key=="D") then
msg("D is pressed!")
c_msg(id,102,255,102,'D is pressed!','@C')
end
end
if(state==0)then
if(key=="W") then
msg("W has been pressed.")
c_msg(id,102,255,102,'W has been pressed!','@C')
elseif(key=="A") then
msg("A has been pressed!")
c_msg(id,102,255,102,'A has been pressed!','@C')
elseif(key=="S") then
msg("S has been pressed!")
c_msg(id,102,255,102,'S has been pressed!','@C')
elseif(key=="D") then
msg("D has been pressed!")
c_msg(id,102,255,102,'D has been pressed!','@C')
end
end
end
addhook("key", "onPlayerKeyPress")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment