Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: add CA_Client_SendToClient #334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ new logType_s: ca_log_type,
new const LOG_FOLDER[] = "ChatAdditions"

new g_fwdClientSay,
g_fwdClientSendToClient,
g_fwdClientVoice,
g_fwdClientChangeName,
g_retVal
Expand Down Expand Up @@ -61,13 +62,16 @@ public plugin_init() {
register_clcmd("say", "ClCmd_Say", ADMIN_ALL)
register_clcmd("say_team", "ClCmd_Say", ADMIN_ALL)

register_message(get_user_msgid("SayText"), "UserMsg_SayText")

register_forward(FM_Voice_SetClientListening, "Voice_SetClientListening_Pre", ._post = false)
register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged_Pre", ._post = false)

register_clcmd("VModEnable", "ClCmd_VModEnable", ADMIN_ALL, .FlagManager = false)
register_clcmd("vban", "ClCmd_vban", ADMIN_ALL, .FlagManager = false)

g_fwdClientSay = CreateMultiForward("CA_Client_Say", ET_STOP, FP_CELL, FP_CELL, FP_STRING)
g_fwdClientSendToClient = CreateMultiForward("CA_Client_SendToClient", ET_STOP, FP_CELL, FP_CELL, FP_STRING)
g_fwdClientVoice = CreateMultiForward("CA_Client_Voice", ET_STOP, FP_CELL, FP_CELL)
g_fwdClientChangeName = CreateMultiForward("CA_Client_ChangeName", ET_STOP, FP_CELL, FP_STRING)

Expand All @@ -78,6 +82,7 @@ public plugin_init() {

public plugin_end() {
DestroyForward(g_fwdClientSay)
DestroyForward(g_fwdClientSendToClient)
DestroyForward(g_fwdClientVoice)
DestroyForward(g_fwdClientChangeName)
}
Expand Down Expand Up @@ -234,6 +239,21 @@ public ClCmd_Say(const id) {
return (g_retVal == CA_SUPERCEDE) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}

public UserMsg_SayText(msgid, dest, receiver) {
if (dest != MSG_ONE)
return PLUGIN_CONTINUE

new sender = get_msg_arg_int(1)

// TODO: check other args
static message[256]
get_msg_arg_string(3, message, charsmax(message))

ExecuteForward(g_fwdClientSendToClient, g_retVal, sender, receiver, message)

return (g_retVal == CA_SUPERCEDE) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
}

public Voice_SetClientListening_Pre(const receiver, const sender, bool: canListen) {
if (receiver == sender)
return FMRES_IGNORED
Expand Down
12 changes: 12 additions & 0 deletions cstrike/addons/amxmodx/scripting/include/ChatAdditions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ native bool: CA_PlayerHasBlockedPlayer(const receiver, const sender)
*/
forward CA_Client_Say(index, const bool: isTeamMessage, const message[])

/**
* Called when server send message from player to other players chat.
*
* @param index Client index.
* @param receiver Receiver index.
* @param message Client message.
*
* @return CA_CONTINUE to allow send message
* CA_SUPERCEDE or higher to prevent message
*/
forward CA_Client_SendToClient(const index, const receiver, const message[])


/**
* Called when player begins to speak.
Expand Down