Help fixing a MilitaryRP War Scrript

I am making a MilitaryRP War Script, and I have most of it done. All I need help with is replacing some text with a simple chat command. (!war, !peace)
Thank you for helping!


--War, never changes


--This starts the base of the War and Peace Marker
function HUD()

	local client = LocalPlayer()

	if !client:Alive() then --Creates hud, if alive. If dead hides hud
		return
	end
	
	 draw.RoundedBox(4, 610,50 ,125, 50, Color(60,60,60,240))
	 	

		hook.Add( "PlayerSay", "war", function( ply, text, public )
	text = string.lower( text ) -- Make the chat message entirely lowercase
	if ( text == "!war" ) then
		draw.SimpleText("War", "DermaLarge", 648,58, Color(255,20,0,255), 0, 0) 
		draw.RoundedBox(4, 610,50 ,125, 50, Color(60,60,60,240))
	end
end )
			
hook.Add( "PlayerSay", "peace", function( ply, text, public )
	text = string.lower( text ) -- Make the chat message entirely lowercase
	if ( text == "!peace" ) then
		draw.SimpleText("Peace", "DermaLarge", 640,58, Color(0,255,0,255), 0, 0)
		draw.RoundedBox(4, 610,50 ,125, 50, Color(60,60,60,240))
	end
end )



end
	hook.Add("HUDPaint", "WarPeace", HUD)

P.S I know it isn’t perfect. I am not the best coder. This is as much as I know the best in glua.

Seperate your hooks, dont have them inside your hudpaint, hudpaint is a expensive function as its called every frame.

If you want a command like this to work, first you`ll want to seperate client and server code, this will help you in the future.

After you properly seperated your hooks, to tell if the hook is clientside or serverside you can refer to the wiki.garrysmod.com there is some amazing documentation there with guides that can help you do this.

Now on serverside we need to find out when someone calls this command, we should check if they are legally able to call the war and peace command.

After we check that, we can either sendlua or use net messages, I recommend the ladder for this though. We can send a net message to the clients that we when they receive the message the clients can start drawing your indicatior.

Extra: Now, lets say you want new players to receive the message after you send to all online players, you need to save the state of the message and send them to players on playerinitialspawn(untested[should work]).

Thats all you should need to know to create this feature.
Sorry for any typos, on my phone :wink:

Thank you

If you have any more questions, feel free to add me or post here, there are plenty of helpful people here willing to help you