Skip to content

Commit 7bfcc51

Browse files
Core API enhance (#241)
* core: Extending the API forwards `CA_Client_Say` and `CA_Client_SayTeam` can now transmit the message string * core: fix const * core: include: update forwards decription
1 parent 1a00568 commit 7bfcc51

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

cstrike/addons/amxmodx/scripting/ChatAdditions_Core.sma

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public plugin_init() {
7070
register_clcmd("VModEnable", "ClCmd_VModEnable", ADMIN_ALL, .FlagManager = false)
7171
register_clcmd("vban", "ClCmd_vban", ADMIN_ALL, .FlagManager = false)
7272

73-
g_fwdClientSay = CreateMultiForward("CA_Client_Say", ET_STOP, FP_CELL)
74-
g_fwdClientSayTeam = CreateMultiForward("CA_Client_SayTeam", ET_STOP, FP_CELL)
73+
g_fwdClientSay = CreateMultiForward("CA_Client_Say", ET_STOP, FP_CELL, FP_STRING)
74+
g_fwdClientSayTeam = CreateMultiForward("CA_Client_SayTeam", ET_STOP, FP_CELL, FP_STRING)
7575
g_fwdClientVoice = CreateMultiForward("CA_Client_Voice", ET_STOP, FP_CELL, FP_CELL)
7676
g_fwdClientChangeName = CreateMultiForward("CA_Client_ChangeName", ET_STOP, FP_CELL, FP_STRING)
7777

@@ -135,13 +135,21 @@ public NativeFilter(const nativeName[], index, trap) {
135135
}
136136

137137
public ClCmd_Say(const id) {
138-
ExecuteForward(g_fwdClientSay, g_retVal, id)
138+
static message[CA_MAX_MESSAGE_SIZE]
139+
read_args(message, charsmax(message))
140+
remove_quotes(message)
141+
142+
ExecuteForward(g_fwdClientSay, g_retVal, id, message)
139143

140144
return (g_retVal == CA_SUPERCEDE) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
141145
}
142146

143147
public ClCmd_SayTeam(const id) {
144-
ExecuteForward(g_fwdClientSayTeam, g_retVal, id)
148+
static message[CA_MAX_MESSAGE_SIZE]
149+
read_args(message, charsmax(message))
150+
remove_quotes(message)
151+
152+
ExecuteForward(g_fwdClientSayTeam, g_retVal, id, message)
145153

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

cstrike/addons/amxmodx/scripting/include/ChatAdditions.inc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define CA_VERSION "%CA_VERSION%"
2020
#endif
2121

22+
const CA_MAX_MESSAGE_SIZE = 188
23+
2224
/**
2325
* Return types
2426
*/
@@ -236,22 +238,24 @@ native bool: CA_PlayerHasBlockedPlayer(const receiver, const sender);
236238
/**
237239
* Called when player say to chat.
238240
*
239-
* @param index Client index.
241+
* @param index Client index.
242+
* @param message Client message.
240243
*
241244
* @return CA_CONTINUE to allow send message
242245
* CA_SUPERCEDE or higher to prevent message
243246
*/
244-
forward CA_Client_Say(index);
247+
forward CA_Client_Say(index, const message[]);
245248

246249
/**
247250
* Called when player say to team chat.
248251
*
249-
* @param index Client index.
252+
* @param index Client index.
253+
* @param message Client message.
250254
*
251255
* @return CA_CONTINUE to allow send message
252256
* CA_SUPERCEDE or higher to prevent message
253257
*/
254-
forward CA_Client_SayTeam(index);
258+
forward CA_Client_SayTeam(index, const message[]);
255259

256260

257261
/**

0 commit comments

Comments
 (0)