Difference between revisions of "SourceMod 1.5.0 API Changes"
(→SDKHooks) |
|||
Line 104: | Line 104: | ||
For those not already familiar with the api, see the [http://hg.alliedmods.net/releases/sourcemod-1.5/file/tip/plugins/include/sdkhooks.inc sdkhooks.inc] file. | For those not already familiar with the api, see the [http://hg.alliedmods.net/releases/sourcemod-1.5/file/tip/plugins/include/sdkhooks.inc sdkhooks.inc] file. | ||
+ | |||
+ | There is also a new ISDKHooks interface for extensions which allows them to add listeners for entity creation and deletion. | ||
==SDKTools== | ==SDKTools== |
Revision as of 08:45, 25 August 2013
This page is unfinished, still in progress
These are just the API changes from SourceMod 1.4.7 to SourceMod 1.5.0. Click here for the full SourceMod 1.5.0 Release Notes.
Contents
Additions
BaseComm
The BaseComm base plugin now has a new set of global forwards to notify other plugins of its actions.
/** * Called when a client is muted or unmuted * * @param client Client index * @param muteState True if client was muted, false otherwise */ forward BaseComm_OnClientMute(client, bool:muteState);
/** * Called when a client is gagged or ungagged * * @param client Client index * @param gagState True if client was gaged, false otherwise */ forward BaseComm_OnClientGag(client, bool:gagState);
Clients
GetClientAuthString by default now is only successful if the client has fully authenticated (if the new ValidateAuthentication feature is enabled in core.cfg).
There is a new bool param, validate, which can be sent as false to bypass this and get a potentially unvalidated auth string.
A new GetSteamAccountID native also has this param with the same purpose. A Steam account ID is the lower 32 bits of the full 64-bit Steam ID (referred to as community id by some) and is unique per account.
/** * Returns the client's Steam account ID. * * @param client Client Index. * @param validate Check backend validation status. * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, * You WILL KNOW if you need to use this, MOST WILL NOT. * @return Steam account ID or 0 if not available. * @error If the client is not connected or the index is invalid. */ native GetSteamAccountID(client, bool:validate=true);
You can also now return the maximum number of non-bots that a game will allow to join, which can be lower than MaxClients.
These limits can be put into place in games starting with Left 4 Dead. L4D 1 and 2 use it to limit connecting clients to 4 (coop) or 8 (versus) depending on game mode, and Counter-Strike: Global Offensive's new "gametypes" config system will set it based on the current mode's configured MaxPlayers amount.
/** * Returns the maximum number of human players allowed on the server. This is * a game-specific function used on newer games to limit the number of humans * that can join a game and can be lower than MaxClients. It is the number often * reflected in the server browser or when viewing the output of the status command. * On unsupported games or modes without overrides, it will return the same value * as MaxClients. * * You should not globally cache the value to GetMaxHumanPlayers() because it can change across * game modes. You may still cache it locally. * * @return Maximum number of humans allowed. */ native GetMaxHumanPlayers();
Console
New global forwards have been added to specifically catch player chat without having to manually add a command listener for each possible chat command in a given game.
OnClientSayCommand can be used to block chat from occurring, and OnClientSayCommand_Post will only be fired if the chat was allowed, not blocked in the first forward or due to flooding.
/** * Global listener for the chat commands. * * @param client Client index. * @param command Command name. * @param sArgs Chat argument string. * * @return An Action value. Returning Plugin_Handled bypasses the game function call. Returning Plugin_Stop bypasses the post hook as well as the game function. */ forward Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]);
/** * Global post listener for the chat commands. * * @param client Client index. * @param command Command name. * @param sArgs Chat argument string. * */ forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]);
Protobuf
Support and many new natives for protobuf usermessages has been added. These are used in newer games like Counter-Strike: Global Offensive and Dota 2 in place of bitbuf messages.
For more info, see the Protobuf article.
SDKHooks
With it already in use on numerous servers, the SDKHooks extension has been added as officially supported.
For those not already familiar with the api, see the sdkhooks.inc file.
There is also a new ISDKHooks interface for extensions which allows them to add listeners for entity creation and deletion.
SDKTools
GetPlayerResourceEntity has been added as a game-agnostic replacement for TF2_GetResourceEntity
The resource entity typically contains multiple player-indexed arrays to network shared player data from the server to the client. Its data is typically updated internally each frame, making it much easier to read than effectively write. It's commonly used for scoreboard data amount other things. You can find a list of all of the data on it in a game by generating a dump of the game's networked properties (see Entity_Properties#SourceMod_Commands).
/* * Returns the entity index of the player resource/manager entity. * * @return Index of resource entity or -1 if not found. */ native GetPlayerResourceEntity();
UserMessages
The GetUserMessageType native has been added to detect at runtime which usermessage system that the current game uses.
/** * UserMsg message serialization formats */ enum UserMessageType { UM_BitBuf = 0, UM_Protobuf, };
/** * Returns usermessage serialization type used for the current engine * * @return The supported usermessage type. */ native UserMessageType:GetUserMessageType();