Why is it doing it?
this is what i get:
[CODE]error in string.lua
[ERROR] lua/includes/extensions/string.lua:91: bad argument #1 to 'string_gmatch' (string excepted, got userdata)
1. string_gmatch - [C]:-1
2. Explode - lua/includes/extensions/string.lua
3. fn - lua/cwarn.lua:35
4. unknown - addons/ulib/lua/ulib/shared/hook:179
line 35 of cwarn.lua:
if (text == "!admincommands") then[/CODE]
i am trying to create chat commands with PlayerSay hooks.
Full Code where error appears:
[CODE]function commands( text, ply )
if ( text == "!admincommands" ) then
PrintMessage(3, "!report name reason\n!warning name reason\n!rweapons name reason\n!giveweapon weapon_name player")
end
end[/CODE]
Post more code
I believe this is what your looking for. Well with string.lower
[CODE]hook.Add( "PlayerSay", "Killurself", function( ply, text, public )
text = string.lower( text ) -- Make the chat message entirely lowercase
if ( text == "!kill" ) then
ply:Kill()
return ""
end
end )
[/CODE]
Args are in the wrong order;
[B]replace with the following:[/B]
[CODE]function commands( ply, text, is_team_chat )
if ( text:lower() == "!admincommands" ) then -- lowercase the supplied text and check if it matches the expected chat command(s).
PrintMessage(3, "!report name reason\n!warning name reason\n!rweapons name reason\n!giveweapon weapon_name player")
-- return "" // removing the -- at the start of this line, will make it so that the supplied text(command) is not printed to chat, when sent the player executes the command.
end
end[/CODE]
[QUOTE=Faedro;48362439]Args are in the wrong order;
[B]replace with the following:[/B]
[CODE]function commands( ply, text, is_team_chat )
if ( text:lower() == "!admincommands" ) then -- lowercase the supplied text and check if it matches the expected chat command(s).
PrintMessage(3, "!report name reason\n!warning name reason\n!rweapons name reason\n!giveweapon weapon_name player")
-- return "" // removing the -- at the start of this line, will make it so that the supplied text(command) is not printed to chat, when sent the player executes the command.
end
end[/CODE][/QUOTE]
Thanks faedro, it works perfectly now.
Sorry, you need to Log In to post a reply to this thread.