/** * Handle Chat Messages */ public handleSayText( id ) { new s_Message[192]
// get the message read_args( s_Message, charsmax(s_Message) )
// clean up remove_quotes( s_Message ) trim( s_Message )
// no message? we're done if ( !s_Message[0] ) return PLUGIN_HANDLED
// only process if we found a command if ( isCommand( s_Message, strlen( s_Message ) ) ) { // go through all registered chat commands for ( new i; i < sizeof g_ChatCommands; i++ ) { // check if it's a registered command of this plugin if ( equali( g_ChatCmd, g_ChatCommands[i] ) ) { // debug client_print( 0, print_chat, "Command: %s", g_ChatCmd ) client_print( 0, print_chat, "Argument: %s", g_ChatArg ) } }
new s_cmd[32] read_argv( 0, s_cmd, charsmax(s_cmd) )
new is_TeamMessage = s_cmd[3] == '_' ? true : false new is_UserAlive = is_user_alive( id ) new CsTeams:id_UserTeam = cs_get_user_team( id )
new i_Players[32], i_PlayersCount new c_MsgType = id ? MSG_ONE : MSG_ALL new ChatChannel = getChatChannel( id, id_UserTeam, is_TeamMessage )
get_players( i_Players, i_PlayersCount, "ch" )
for ( new i; i < i_PlayersCount; i++ ) { if ( is_UserAlive == is_user_alive( i_Players[i] ) ) { if ( !is_TeamMessage || ( is_TeamMessage && id_UserTeam == cs_get_user_team( i_Players[i] ) ) ) { // actually write the message now emessage_begin( c_MsgType, g_MsgSayText, _, i_Players[i] )
ewrite_byte( id ) // Channel, e.g. #Cstrike_Chat_All ewrite_string( g_ChatChannelTypes[ChatChannel] ) // Username ewrite_string( "^x04Username" ) // Message ewrite_string( s_Message )
emessage_end() } } }
return PLUGIN_HANDLED }
return PLUGIN_CONTINUE }
/** * Check if the message is actually a command, e.g. /rank */ bool:isCommand( const p_msg[], p_msg_len ) { // check if first character is a slash if ( !strfind( p_msg, "/", 0, 0 ) ) { // set g_ChatCmd to passed command strtok( p_msg, g_ChatArg, p_msg_len, g_ChatCmd, p_msg_len, '/', 1 )
// set g_ChatArg to passed argument strtok( p_msg, g_ChatCmd, p_msg_len, g_ChatArg, p_msg_len, ' ', 1 )
Everything is simple just read the documentation files to learn more
Hey,
I don't think the documentation covers everything, otherwise I wouldn't have to guess how to use emessage_* properly. It surely does describe the arguments and what the function does (sometimes not even that, "no description available"), but not when and how to use some stuff. Also it seems to be incomplete for me here and there, e.g. the client_print_color function mentions:
Quote:
Alternatively, a specific team color can be enforced using the print_team_* constants in amxconst.inc
But there are no print_team_* constants.
Correct me if I'm wrong, please, but I'm kinda lost.
//e:
I bet the HL SDK would help me a lot to understand what's going on under the hood, but I don't know how to "use" it to answer the questions I have while coding.