Difference between revisions of "SourceMod 1.4.0 API Changes"

From AlliedModders Wiki
Jump to: navigation, search
(Created page with '''This page is a work-in-progress as SourceMod 1.4.0 is not yet released.'' __FORCETOC__ =Sourcepawn API Changes= ==Additions== ===BaseComm=== The BaseComm base plugin now ha...')
(No difference)

Revision as of 12:21, 25 October 2011

This page is a work-in-progress as SourceMod 1.4.0 is not yet released.


Sourcepawn API Changes

Additions

BaseComm

The BaseComm base plugin now has a brand new API to fully interact with it, without conflict.

/**
 * Returns whether or not a client is gagged
 *
 * @param client		Client index.
 * @return			True if client is gagged, false otherwise.
 */
native bool:BaseComm_IsClientGagged(client);
 
/**
 * Returns whether or not a client is muted
 *
 * @param client		Client index.
 * @return			True if client is muted, false otherwise.
 */
native bool:BaseComm_IsClientMuted(client);
/**
 * Sets a client's gag state
 *
 * @param client		Client index.
 * @param gagState		True to gag client, false to ungag.
 * @return			True if this caused a change in gag state, false otherwise.
 */
native bool:BaseComm_SetClientGag(client, bool:gagState);
 
/**
 * Sets a client's mute state
 *
 * @param client		Client index.
 * @param muteState		True to mute client, false to unmute.
 * @return			True if this caused a change in mute state, false otherwise.
 */
native bool:BaseComm_SetClientMute(client, bool:muteState);


ClientPrefs

ClientPrefs now allows altering cookie values for clients that are not presently in-game.

/**
 * Sets the value of a Client preference cookie based on an authID string.
 *
 * @param authID		String Auth/STEAM ID of player to set.
 * @param cookie		Client preference cookie handle.
 * @param value			String value to set.
 * @noreturn
 * @error			Invalid cookie handle.
 */
native SetAuthIdCookie(const String:authID[], Handle:cookie, const String:value[]);


Core

Clients

Clients can now be easily identified as being the SourceTV or replay bot, regardless of when they are checked, what they were renamed to, or when they were enabled.

/**
 * Returns if a certain player is the SourceTV bot.
 *
 * @param client		Player index.
 * @return			True if player is the SourceTV bot, false otherwise.
 */
native bool:IsClientSourceTV(client);
 
/**
 * Returns if a certain player is the Replay bot.
 *
 * @param client		Player index.
 * @return			True if player is the Replay bot, false otherwise.
 */
native bool:IsClientReplay(client);

CommandFilters

Command filters are no longer limited to extensions. Multi-target filters can now be dynamically created, evaluated, and removed natively in Sourcepawn.

/**
 * Adds clients to a multi-target filter.
 *
 * @param pattern       Pattern name.
 * @param clients       Array to fill with unique, valid client indexes.
 * @return              True if pattern was recognized, false otherwise.
 */
functag public bool:MultiTargetFilter(const String:pattern[], Handle:clients);
 
/**
 * Adds a multi-target filter function for ProcessTargetString().
 *
 * @param pattern       Pattern to match (case sensitive).
 * @param filter        Filter function.
 * @param phrase        Descriptive phrase to display on successful match.
 * @param phraseIsML    True if phrase is multi-lingual, false otherwise.
 * @noreturn
 */
native AddMultiTargetFilter(const String:pattern[], MultiTargetFilter:filter,
                            const String:phrase[], bool:phraseIsML);
 
/**
 * Removes a multi-target filter function from ProcessTargetString().
 *
 * @param pattern       Pattern to match (case sensitive).
 * @param filter        Filter function.
 * @noreturn
 */
native RemoveMultiTargetFilter(const String:pattern[], MultiTargetFilter:filter);

See plugins/testsuite/ptstest.sp for example usage.

Console

ServerCommandEx has been added to allow saving the result text of the server command to a buffer. Note the warning as this command will immediately flush everything currently in the server's command buffer.

/**
 * Executes a server command as if it were on the server console (or RCON) 
 * and stores the printed text into buffer.
 *
 * Warning: This calls ServerExecute internally and may have issues if
 * certain commands are in the buffer, only use when you really need
 * the response.
 * Also, on L4D2 this will not print the command output to the server console.
 *
 * @param buffer		String to store command result into.
 * @param maxlen		Length of buffer.
 * @param format		Formatting rules.
 * @param ...			Variable number of format parameters.
 * @noreturn
 */
native ServerCommandEx(String:buffer[], maxlen, const String:format[], any:...);


Extension API Changes