Quote:
Originally Posted by Antithasys
Further suggestions. I always wonder why people hook the say command when all they want is the chat trigger. Sourcemod does all this for you. Creating your own console command is the way to go.
Replace:
PHP Code:
RegConsoleCmd("say", Command_SayChat); public Action:Command_SayChat(client, args) { decl String:text[192]; if (!GetConVarBool(cvPluginEnabled) || IsChatTrigger() || GetCmdArgString(text, sizeof(text)) < 1) return Plugin_Continue; ReplaceString(text, sizeof(text), "\"", ""); ReplaceString(text, sizeof(text), " ", ""); if (StrEqual(text, "!achievements")) { DisplayAchievements(client); return Plugin_Handled; } return Plugin_Continue; }
With:
PHP Code:
RegConsoleCmd("sm_achievements", Command_DisplayAchievements, "Display Achievements"); public Action:Command_DisplayAchievements(client, args) { if (GetConVarBool(cvPluginEnabled)) DisplayAchievements(client); return Plugin_Handled; }
|
As elegant as this is the only problem I can forsee is that it requires users to have access to the console. Some players don't even know what the console is, much less how to enable it and which key brings it down. Telling those people just to type a command in say is a lot easier than trying to teach them to bring up the console and type a command.
Code wise though the console command method is a lot more elegant.