Hello everyone, I get the feeling I've done something stupid, I just started with LUA so please dont flame me.
[CODE]hook.Add('PlayerSay', 'dhpointschatcommand'), function ( ply, text )
text = string.lower( text )
if ( string.sub( text 1, 5 ) == '!test' ) then
Player:PrintMessage( HUD_PRINTTALK, "DH points is a work in progress!" )
end
end[/CODE]
I would appreciate it if someone could tell me what i done wrong rather than fix it for me.
Thanks in advance
[code]
function chatCommand( ply, text, public )
text = string.lower(text )
if ( string.sub( text, 1, 5 ) == "!test" ) then
ply:PrintMessage( HUD_PRINTTALK, "DH points is a work in progress!" )
end
end
hook.Add( 'PlayerSay', 'chatCommand', chatCommand);
[/code]
Here you go
[LUA]
//You need a comma ;)
string.sub( text, 1, 5 )
--not
string.sub( text 1, 5 )
hook.Add("PlayerSay", "dhpointschatcommand", function ( ply, text )
text = string.lower( text )
if ( string.sub( text, 1, 5 ) == '!test' ) then
ply:PrintMessage( HUD_PRINTTALK, "DH points is a work in progress!" )
end
end )
[/LUA]
I do this: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/chat_commands/chat_commands.lua.html[/url]
I redirect ! and / commands to console commands. Just concommand.Add and add any commands like motd, or whatever else. Works perfectly.
Sorry, you need to Log In to post a reply to this thread.