chatcommand with networking

I’ve been sitting on this mess for up to 2 hours, I cant find a solution for this:
the addon should send a net whenever a certain command was written but I can type either of which (2 commands) and it opens the same one:
sv_:


local ChatCString = function(len, ply)
	local strText = net.ReadString()

    	if ( strText == "/logout" or "!logout"  ) then 
    		 net.Start("jpg_PopupLogin")
             net.Send( ply )
	      	return true 
	    end
	    if ( strText == "!resetpass" or "/resetpass") then
	    	net.Start("jpg_PopupMenuOnClient")
            net.Send( ply )
            return true
	    end 
end
net.Receive("jpg_StringChat", ChatCString)

cl_:


hook.Add( "OnPlayerChat", "jpg_GetStringCommandLogin", function( ply, strText )
    if ply == LocalPlayer() then
	  strText = string.lower( strText ) 
    
    	if ( strText == "/logout" or "!logout" ) then 
    		net.Start("jpg_StringChat")
    		net.WriteString(strText)
    		net.SendToServer()
	      	return true 
	    end
	    if ( strText == "/resetpass" or "!resetpass" ) then 
    		net.Start("jpg_StringChat")
    		net.WriteString(strText)
    		net.SendToServer()
	      	return true 
	    end
    end
    end  )


I am at loss, please tell me what I am doing wrong

Why not just use a

GM:PlayerSay hook?

it made the same bug when I tried using playersay though

EDIT: Using Playersay now cuz it requires less networking, but I am facing the exact same issue

Just looked at your code and it’s because the first if statement will always pass. You could say anything in chat and it would trigger. You can’t just do “if string == otherstring or otherotherstring then” because you’re basically telling it to pass if otherotherstring isn’t nil which it never will be.

I tried this, just as the wiki suggests, but whenever I type something, be it “hello” or just a letter it opens only the menu connected to jpg_Popuplogin


hook.Add( "PlayerSay", "jpg_GetStringCommandLogin", function( ply, strText )
    
	  strText = string.lower( strText ) 
    
    	if (  string.sub( strText, 1, 7 ) == "/logout" or "!logout" ) then 
    		net.Start("jpg_PopupLogin")
             net.Send( ply )
	      	return true 
	    end
	    if (  string.sub( strText, 1, 10 ) == "/resetpass" or "!resetpass" ) then 
    		net.Start("jpg_PopupMenuOnClient")
            net.Send( ply )
	      	return true 
	    end
    
    end  )


“if ( string.sub( strText, 1, 7 ) == “/logout” or “!logout” ) then” is the same as “if condition or true then”. You need to use string.sub twice in each if statement.


hook.Add("PlayerSay", "command", function(ply, txt)
	if (txt:sub(1, 1) == "!" or txt:sub(1, 1) == "/") then
		if (txt:sub(2) == "logout") then
			net.Start("jpg_PopupLogin")
			net.Send(ply)
		elseif (txt:sub(2) == "resetpass") then
			net.Start("jpg_PopupMenuOnClient")
			net.Send(ply)
		end
		
		return ""
	end
end)


thx it works now, I think I understood where I made the mistake now

What you’re doing in both of your if statements is basically “if condition or string isn’t nil then” which will always pass. You need to do “if condition or othercondition then”.