• Problem with simple code.
    8 replies, posted
I don't know to much about LUA but this script I played with is not working. The code should make you wave when you say these words "hi", "hey", "yo", "hello" it is lua\autorun\server\sv_anim.lua There are no errors, but it does nothing. [CODE] function AnimChat(ply, text) local prefixs = {"hi", "hey", "yo", "hello"} local command = string.Explode(" ", text)[1] for _, v in pairs(prefixs) do if string.lower(command) == v then ply:ConCommand("act wave") end end end hook.Add("PlayerSay", "AnimChat", AnimChat) [/CODE]
IIRC, the 'act' command is blocked.
Instead of using that console command you should take a look at [URL="http://glua.me/bin/?path=/gamemodes/terrortown/gamemode/player_ext_shd.lua&plaintext=1"]how TTT did it[/URL].
ply:ConCommand("act", "wave") The arguments must be separated by a comma. The function cuts out the middleman of the console itself, so it's not like you're saying "'act', 'wave'" in the console, it's actually sending strings directly to the server. Pretty much, just do it like that. You can change "wave" with "bow" and stuff.
[QUOTE=bobbleheadbob;35705833]ply:ConCommand("act", "wave") The arguments must be separated by a comma.[/QUOTE] Im 90% sure thats not how ConCommand works. RunConsoleCommand works like that, but not ConCommand.
[QUOTE=ArmageddonScr;35706931]Im 90% sure thats not how ConCommand works. RunConsoleCommand works like that, but not ConCommand.[/QUOTE] Not sure if that was directed towards me but I have no idea what im doing, thats why I posted this thread :v:
Here you go I figured this out pretty fast with the wiki's help :P [lua] hook.Add("OnPlayerChat", "AnimatePlayer", function( ply, text, bTeamOnly, bPlayerIsDead ) local act = {"wave", "bow"} local prefixs = {"hi", "hey"} local explode = string.Explode(" ", text) for k,v in pairs(prefixs) do if explode[1] == v then ply:ConCommand("act wave") end end end) [/lua] I tested in game and it works so just edit it to your liking! enjoy :) The chat hook is clientside by the way you had it serverside.
[QUOTE=brandonj4;35711306]Here you go I figured this out pretty fast with the wiki's help :P [lua] hook.Add("OnPlayerChat", "AnimatePlayer", function( ply, text, bTeamOnly, bPlayerIsDead ) local act = {"wave", "bow"} local prefixs = {"hi", "hey"} local explode = string.Explode(" ", text) for k,v in pairs(prefixs) do if explode[1] == v then ply:ConCommand("act wave") end end end) [/lua] I tested in game and it works so just edit it to your liking! enjoy :) The chat hook is clientside by the way you had it serverside.[/QUOTE] Thank you so much :)
No problem!
Sorry, you need to Log In to post a reply to this thread.