2 Things I need help with.

Hi. I’m making a game mode and I don’t know how to do a few things in LUA.

  1. I want to make a chat command such as !class_menu to execute a custom console command, which I already have made.

  2. How Do I make it so maps starting with a certain name (such as “arena_map name”) automatically start my gamemode, which is an arena-type gamemode.


No one?

For the first question, Use **[Gamemode.PlayerSay


hook.Add( “PlayerSay”, “Execute Command”, function( ply, text, team, death )
if ply:IsPlayer() then
if string.lower(text) == “!class_menu” then
ply:ConCommand(“class_menu”) – Replace “class_menu” with your command.
And for the second question, I cant help you.

Thank you. Helps soo much

  1. Game.GetMap gets the current map name. Check it for whatever word you’re looking for and use the changegamemode console command if it’s not the right gamemode. Or something like that. You get the idea.

I believe you can use * as a wildcard eg. arena_*.bsp

Or you can use string.find().

You should be able to do that, yes.

for k, v in pairs (ents.FindByClass("npc_*")) do

You can set it more easily in the info.txt of the gamemode.

Example from the GMod wiki…