Chat commands wont work.


ChatCommands = {}

GMRP.specialTalk = {}
GMRP.specialTalk["/y"] = { "(YELL)", 1000 }
GMRP.specialTalk["/w"] = { "(WHISPER)", 100 }


function GMRP.ChatCommand( name, cmd )
	
	ChatCommands[ "/"..name ] = cmd
	
end	


function GM:PlayerSay( p, text )
	
	local chat = string.Explode( " ", string.lower(text) )
	
	for k, v in pairs( ChatCommands ) do
	
		if ( chat[1] == k ) then
		
			if chat[2] != "" && chat[2] != nil then
		
				v( p, chat[2] )
				return ""
				
			else

				v( p )
				return ""
				
			end	
			
		end
		
	end	
	

	if ( string.sub( text, 1, 3 ) == "// " ) then
	
		return string.sub( text, 4 )
		
	end
	
	for k, v in pairs( GMRP.specialTalk ) do
	
		if ( string.sub( text, 1, string.len( k ) + 1 ) == k.." "  ) then
	
			p:RPTalk( GMRP.specialTalk[k][2], GMRP.specialTalk[k][1].." "..string.sub( text, string.len( k ) + 2 ) )	
			return ""
			
		end
		
	end	

	p:RPTalk( 300, text )	
	return ""	

end	


function DropMoneyChatCommand(ply, amount)

	if ( amount == nil ) then return end

	ply:ConCommand( "gm_rp_dropcash "..amount )
	
end

GMRP.ChatCommand( "drop", DropMoneyChatCommand )


function SleepChat( ply, a )

	ply:ConCommand( "gm_rp_sleep" )
	
end

GMRP.ChatCommand( "sleep", SleepChat )


function SitChat( ply, a )
	
	ply:ConCommand( "gm_rp_sit" )
	
end

GMRP.ChatCommand( "sit", SitChat )

None of those commands work I put all of them in chatcommands.lua and whenever I try to use them in game they will not work. Can anyone tell me why these are unable to execute in game? It works when I type gm_rp_dropcash in console but when I try to type drop in game it will not work.
I’ve tried drop, dropcash, dropmoney, /drop, /dropmoney, /dropcash and none work any suggestions? :bang: Also the yell and whisper wont work so thats another problem i need help fixing.

Anyone know?

That looks fine to me. Are you sure you’re not getting any sort of error running this?

Im not getting any errors at all. When I would type /drop or drop It wouldn’t drop the money so its really confusing me right now.

Try placing a few prints (different for each part of the code) to see what does and doesn’t get run.

edit : Also, where is that code? Are you sure it’s included in init.lua?

Its not in init.lua its in chatcommands.lua


include( 'chatcommands.lua' )

In init.lua.

Lol.

I found out it was assmod grammar that was messing it up.