This commit is contained in:
xen
2020-03-25 20:09:12 +02:00
committed by xen
commit 527e7ec05e
420 changed files with 68682 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#if defined _AdvancedTargeting_Included
#endinput
#endif
#define _AdvancedTargeting_Included
native int IsClientFriend(int client, int friend);
native int ReadClientFriends(int client);
public SharedPlugin __pl_AdvancedTargeting =
{
name = "AdvancedTargeting",
file = "AdvancedTargeting.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_AdvancedTargeting_SetNTVOptional()
{
MarkNativeAsOptional("IsClientFriend");
MarkNativeAsOptional("ReadClientFriends");
}
#endif
+121
View File
@@ -0,0 +1,121 @@
/**
* =============================================================================
* Dynamic for SourceMod (C)2016 Matthew J Dunn. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if defined _dynamic_basic_included
#endinput
#endif
#define _dynamic_basic_included
/*
This methodmap is based on the Dynamic methodmap while using a StringMap methodmap
for implementation. This methodmap doesn't implement the full features of the Dynamic
methodmap (type conversion, object naming, plugin sharing, ect). This methodmap can
be used for basic storage using the standard Dynamic methodmap Methods.
Please see '\scripting\dynamic\examples\basic\' for an example usage of this methodmap
*/
methodmap Basic < StringMap
{
public Basic()
{
return view_as<Basic>(new StringMap());
}
public void Dispose(bool disposemembers=true)
{
delete this;
}
public int GetInt(const char[] membername, int defaultvalue=-1)
{
int value;
if (this.GetValue(membername, value))
return value;
return defaultvalue;
}
public void SetInt(const char[] membername, int value)
{
this.SetValue(membername, value);
}
public bool GetBool(const char[] membername, bool defaultvalue=false)
{
bool value;
if (this.GetValue(membername, value))
return value;
return defaultvalue;
}
public void SetBool(const char[] membername, bool value)
{
this.SetValue(membername, value);
}
public float GetFloat(const char[] membername, float defaultvalue=-1.0)
{
float value;
if (this.GetValue(membername, value))
return value;
return defaultvalue;
}
public void SetFloat(const char[] membername, float value)
{
this.SetValue(membername, value);
}
public bool GetString(const char[] membername, char[] buffer, int length)
{
return this.GetString(membername, buffer, length);
}
public void SetString(const char[] membername, const char[] value)
{
this.SetString(membername, value);
}
public Handle GetHandle(const char[] membername)
{
Handle value;
if (this.GetValue(membername, value))
return value;
return null;
}
public void SetHandle(const char[] membername, Handle value)
{
this.SetValue(membername, value);
}
public bool GetVector(const char[] membername, float[3] vector)
{
return this.GetArray(membername, vector, sizeof(vector));
}
public void SetVector(const char[] membername, const float[3] value)
{
this.SetArray(membername, value, sizeof(value));
}
}
+299
View File
@@ -0,0 +1,299 @@
#if defined _class_cambient_
#endinput
#endif
#define _class_cambient_
#include "Basic"
methodmap CSound < Basic
{
public CSound()
{
Basic myclass = new Basic();
myclass.SetInt("iEntity", INVALID_ENT_REFERENCE);
myclass.SetInt("iPassClient", 0);
myclass.SetInt("iPassTickCount", 0);
myclass.SetFloat("fLength", 0.0);
myclass.SetFloat("fEndTime", 0.0);
myclass.SetBool("bIsMusic", false);
myclass.SetInt("iOriginX", 0);
myclass.SetInt("iOriginY", 0);
myclass.SetInt("iOriginZ", 0);
myclass.SetInt("iVolume", 0);
myclass.SetFloat("fDelay", 0.0);
myclass.SetInt("iSeq", 0);
myclass.SetInt("iChannel", 0);
myclass.SetInt("iPitch", 0);
myclass.SetInt("iFlags", 0);
myclass.SetInt("iSoundnum", 0);
myclass.SetInt("iSoundnumHandle", 0);
myclass.SetInt("iSpeakerEntity", INVALID_ENT_REFERENCE);
myclass.SetInt("iSoundLevel", 0);
myclass.SetBool("bIsSentence", false);
myclass.SetBool("bIsAmbient", false);
return view_as<CSound>(myclass);
}
property int iEntity
{
public get()
{
return this.GetInt("iEntity");
}
public set(int value)
{
this.SetInt("iEntity", value);
}
}
property int iPassClient
{
public get()
{
return this.GetInt("iPassClient");
}
public set(int value)
{
this.SetInt("iPassClient", value);
}
}
property int iPassTickCount
{
public get()
{
return this.GetInt("iPassTickCount");
}
public set(int value)
{
this.SetInt("iPassTickCount", value);
}
}
property float fLength
{
public get()
{
return this.GetFloat("fLength");
}
public set(float value)
{
this.SetFloat("fLength", value);
}
}
property float fEndTime
{
public get()
{
return this.GetFloat("fEndTime");
}
public set(float value)
{
this.SetFloat("fEndTime", value);
}
}
property bool bIsMusic
{
public get()
{
return this.GetBool("bIsMusic");
}
public set(bool value)
{
this.SetBool("bIsMusic", value);
}
}
property int iOriginX
{
public get()
{
return this.GetInt("iOriginX");
}
public set(int value)
{
this.SetInt("iOriginX", value);
}
}
property int iOriginY
{
public get()
{
return this.GetInt("iOriginY");
}
public set(int value)
{
this.SetInt("iOriginY", value);
}
}
property int iOriginZ
{
public get()
{
return this.GetInt("iOriginZ");
}
public set(int value)
{
this.SetInt("iOriginZ", value);
}
}
property int iVolume
{
public get()
{
return this.GetInt("iVolume");
}
public set(int value)
{
this.SetInt("iVolume", value);
}
}
property float fDelay
{
public get()
{
return this.GetFloat("fDelay");
}
public set(float value)
{
this.SetFloat("fDelay", value);
}
}
property int iSeq
{
public get()
{
return this.GetInt("iSeq");
}
public set(int value)
{
this.SetInt("iSeq", value);
}
}
property int iChannel
{
public get()
{
return this.GetInt("iChannel");
}
public set(int value)
{
this.SetInt("iChannel", value);
}
}
property int iPitch
{
public get()
{
return this.GetInt("iPitch");
}
public set(int value)
{
this.SetInt("iPitch", value);
}
}
property int iFlags
{
public get()
{
return this.GetInt("iFlags");
}
public set(int value)
{
this.SetInt("iFlags", value);
}
}
property int iSoundnum
{
public get()
{
return this.GetInt("iSoundnum");
}
public set(int value)
{
this.SetInt("iSoundnum", value);
}
}
property int iSoundnumHandle
{
public get()
{
return this.GetInt("iSoundnumHandle");
}
public set(int value)
{
this.SetInt("iSoundnumHandle", value);
}
}
property int iSpeakerEntity
{
public get()
{
return this.GetInt("iSpeakerEntity");
}
public set(int value)
{
this.SetInt("iSpeakerEntity", value);
}
}
property int iSoundLevel
{
public get()
{
return this.GetInt("iSoundLevel");
}
public set(int value)
{
this.SetInt("iSoundLevel", value);
}
}
property bool bIsSentence
{
public get()
{
return this.GetBool("bIsSentence");
}
public set(bool value)
{
this.SetBool("bIsSentence", value);
}
}
property bool bIsAmbient
{
public get()
{
return this.GetBool("bIsAmbient");
}
public set(bool value)
{
this.SetBool("bIsAmbient", value);
}
}
public void Dispose()
{
delete this;
}
}
+33
View File
@@ -0,0 +1,33 @@
#if defined _HappyHour_included
#endinput
#endif
#define _HappyHour_included
/**
* Check if it is Happy Hour or not
*
*
* @return True if yes, false if no.
*/
native bool HH_IsItHappyHour();
public SharedPlugin __pl_HappyHour =
{
name = "HappyHour",
file = "HappyHour.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_HappyHour_SetNTVOptional()
{
MarkNativeAsOptional("HH_IsItHappyHour");
}
#endif
+47
View File
@@ -0,0 +1,47 @@
#if defined _physhooks_included
#endinput
#endif
#define _physhooks_included
forward void OnRunThinkFunctions(bool simulating);
forward void OnPrePlayerThinkFunctions();
forward void OnPostPlayerThinkFunctions();
forward void OnRunThinkFunctionsPost(bool simulating);
// Block TriggerMoved from being called at all for an entity by setting the bit to 1.
native void BlockTriggerMoved(int map[2048 / 32], bool set);
// Block triggers TriggerMoved from touching any client by setting the bit to 1 for the entity index.
native void BlockTriggerTouchPlayers(int map[2048 / 32], bool set);
// Block SolidMoved from being called at all for an entity by setting the bit to 1.
native void BlockSolidMoved(int map[2048 / 32], bool set);
// Block solids SolidMoved from touching any client by setting the bit to 1 for the entity index.
native void BlockSolidTouchPlayers(int map[2048 / 32], bool set);
// Block clients SolidMoved from touching an entity by setting the bit to 1 in the clients map.
native void FilterClientSolidTouch(int map[((MAXPLAYERS + 1) * 2048) / 32], bool set);
public Extension __ext_PhysHooks =
{
name = "PhysHooks",
file = "PhysHooks.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_PhysHooks_SetNTVOptional()
{
}
#endif
+26
View File
@@ -0,0 +1,26 @@
#if defined _SelectiveBhop_Included
#endinput
#endif
#define _SelectiveBhop_Included
native int LimitBhop(int client, bool bLimited);
native int IsBhopLimited(int client);
public SharedPlugin __pl_SelectiveBhop =
{
name = "SelectiveBhop",
file = "SelectiveBhop.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_SelectiveBhop_SetNTVOptional()
{
MarkNativeAsOptional("LimitBhop");
MarkNativeAsOptional("IsBhopLimited");
}
#endif
+413
View File
@@ -0,0 +1,413 @@
#if defined _SteamWorks_Included
#endinput
#endif
#define _SteamWorks_Included
/* results from UserHasLicenseForApp */
enum EUserHasLicenseForAppResult
{
k_EUserHasLicenseResultHasLicense = 0, // User has a license for specified app
k_EUserHasLicenseResultDoesNotHaveLicense = 1, // User does not have a license for the specified app
k_EUserHasLicenseResultNoAuth = 2, // User has not been authenticated
};
/* General result codes */
enum EResult
{
k_EResultOK = 1, // success
k_EResultFail = 2, // generic failure
k_EResultNoConnection = 3, // no/failed network connection
// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
k_EResultInvalidPassword = 5, // password/ticket is invalid
k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
k_EResultInvalidParam = 8, // a parameter is incorrect
k_EResultFileNotFound = 9, // file was not found
k_EResultBusy = 10, // called method busy - action not taken
k_EResultInvalidState = 11, // called object was in an invalid state
k_EResultInvalidName = 12, // name is invalid
k_EResultInvalidEmail = 13, // email is invalid
k_EResultDuplicateName = 14, // name is not unique
k_EResultAccessDenied = 15, // access is denied
k_EResultTimeout = 16, // operation timed out
k_EResultBanned = 17, // VAC2 banned
k_EResultAccountNotFound = 18, // account not found
k_EResultInvalidSteamID = 19, // steamID is invalid
k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
k_EResultNotLoggedOn = 21, // The user is not logged on
k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
k_EResultInsufficientPrivilege = 24, // Insufficient privilege
k_EResultLimitExceeded = 25, // Too much of a good thing
k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
k_EResultIPNotFound = 31, // IP address not found
k_EResultPersistFailed = 32, // failed to write change to the data store
k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
k_EResultLogonSessionReplaced = 34,
k_EResultConnectFailed = 35,
k_EResultHandshakeFailed = 36,
k_EResultIOFailure = 37,
k_EResultRemoteDisconnect = 38,
k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
k_EResultBlocked = 40, // a user didn't allow it
k_EResultIgnored = 41, // target is ignoring sender
k_EResultNoMatch = 42, // nothing matching the request found
k_EResultAccountDisabled = 43,
k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
k_EResultIllegalPassword = 61, // The requested new password is not legal
k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
k_EResultHardwareNotCapableOfIPT = 67, //
k_EResultIPTInitError = 68, //
k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
k_EResultFacebookQueryError = 70, // Facebook query returned an error
k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
k_EResultIPLoginRestrictionFailed = 72,
k_EResultAccountLockedDown = 73,
k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
k_EResultNoMatchingURL = 75,
k_EResultBadResponse = 76, // parse failure, missing field, etc.
k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password
k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range
k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen
k_EResultDisabled = 80, // The requested service has been configured to be unavailable
k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login
k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted
k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker
k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match
k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners
k_EResultNotModified = 91, // data not modified
k_EResultNoMobileDevice = 92, // the account does not have a mobile device associated with it
k_EResultTimeNotSynced = 93, // the time presented is out of range or tolerance
k_EResultSmsCodeFailed = 94, // SMS code failure (no match, none pending, etc.)
k_EResultAccountLimitExceeded = 95, // Too many accounts access this resource
k_EResultAccountActivityLimitExceeded = 96, // Too many changes to this account
k_EResultPhoneActivityLimitExceeded = 97, // Too many changes to this phone
k_EResultRefundToWallet = 98, // Cannot refund to payment method, must use wallet
k_EResultEmailSendFailure = 99, // Cannot send an email
k_EResultNotSettled = 100, // Can't perform operation till payment has settled
k_EResultNeedCaptcha = 101, // Needs to provide a valid captcha
k_EResultGSLTDenied = 102, // a game server login token owned by this token's owner has been banned
k_EResultGSOwnerDenied = 103, // game server owner is denied for other reason (account lock, community ban, vac ban, missing phone)
k_EResultInvalidItemType = 104 // the type of thing we were requested to act on is invalid
};
/* This enum is used in client API methods, do not re-number existing values. */
enum EHTTPMethod
{
k_EHTTPMethodInvalid = 0,
k_EHTTPMethodGET,
k_EHTTPMethodHEAD,
k_EHTTPMethodPOST,
k_EHTTPMethodPUT,
k_EHTTPMethodDELETE,
k_EHTTPMethodOPTIONS,
k_EHTTPMethodPATCH,
// The remaining HTTP methods are not yet supported, per rfc2616 section 5.1.1 only GET and HEAD are required for
// a compliant general purpose server. We'll likely add more as we find uses for them.
// k_EHTTPMethodTRACE,
// k_EHTTPMethodCONNECT
};
/* HTTP Status codes that the server can send in response to a request, see rfc2616 section 10.3 for descriptions
of each of these. */
enum EHTTPStatusCode
{
// Invalid status code (this isn't defined in HTTP, used to indicate unset in our code)
k_EHTTPStatusCodeInvalid = 0,
// Informational codes
k_EHTTPStatusCode100Continue = 100,
k_EHTTPStatusCode101SwitchingProtocols = 101,
// Success codes
k_EHTTPStatusCode200OK = 200,
k_EHTTPStatusCode201Created = 201,
k_EHTTPStatusCode202Accepted = 202,
k_EHTTPStatusCode203NonAuthoritative = 203,
k_EHTTPStatusCode204NoContent = 204,
k_EHTTPStatusCode205ResetContent = 205,
k_EHTTPStatusCode206PartialContent = 206,
// Redirection codes
k_EHTTPStatusCode300MultipleChoices = 300,
k_EHTTPStatusCode301MovedPermanently = 301,
k_EHTTPStatusCode302Found = 302,
k_EHTTPStatusCode303SeeOther = 303,
k_EHTTPStatusCode304NotModified = 304,
k_EHTTPStatusCode305UseProxy = 305,
//k_EHTTPStatusCode306Unused = 306, (used in old HTTP spec, now unused in 1.1)
k_EHTTPStatusCode307TemporaryRedirect = 307,
// Error codes
k_EHTTPStatusCode400BadRequest = 400,
k_EHTTPStatusCode401Unauthorized = 401, // You probably want 403 or something else. 401 implies you're sending a WWW-Authenticate header and the client can sent an Authorization header in response.
k_EHTTPStatusCode402PaymentRequired = 402, // This is reserved for future HTTP specs, not really supported by clients
k_EHTTPStatusCode403Forbidden = 403,
k_EHTTPStatusCode404NotFound = 404,
k_EHTTPStatusCode405MethodNotAllowed = 405,
k_EHTTPStatusCode406NotAcceptable = 406,
k_EHTTPStatusCode407ProxyAuthRequired = 407,
k_EHTTPStatusCode408RequestTimeout = 408,
k_EHTTPStatusCode409Conflict = 409,
k_EHTTPStatusCode410Gone = 410,
k_EHTTPStatusCode411LengthRequired = 411,
k_EHTTPStatusCode412PreconditionFailed = 412,
k_EHTTPStatusCode413RequestEntityTooLarge = 413,
k_EHTTPStatusCode414RequestURITooLong = 414,
k_EHTTPStatusCode415UnsupportedMediaType = 415,
k_EHTTPStatusCode416RequestedRangeNotSatisfiable = 416,
k_EHTTPStatusCode417ExpectationFailed = 417,
k_EHTTPStatusCode4xxUnknown = 418, // 418 is reserved, so we'll use it to mean unknown
k_EHTTPStatusCode429TooManyRequests = 429,
// Server error codes
k_EHTTPStatusCode500InternalServerError = 500,
k_EHTTPStatusCode501NotImplemented = 501,
k_EHTTPStatusCode502BadGateway = 502,
k_EHTTPStatusCode503ServiceUnavailable = 503,
k_EHTTPStatusCode504GatewayTimeout = 504,
k_EHTTPStatusCode505HTTPVersionNotSupported = 505,
k_EHTTPStatusCode5xxUnknown = 599,
};
/* list of possible return values from the ISteamGameCoordinator API */
enum EGCResults
{
k_EGCResultOK = 0,
k_EGCResultNoMessage = 1, // There is no message in the queue
k_EGCResultBufferTooSmall = 2, // The buffer is too small for the requested message
k_EGCResultNotLoggedOn = 3, // The client is not logged onto Steam
k_EGCResultInvalidMessage = 4, // Something was wrong with the message being sent with SendMessage
};
native bool:SteamWorks_IsVACEnabled();
native bool:SteamWorks_GetPublicIP(ipaddr[4]);
native SteamWorks_GetPublicIPCell();
native bool:SteamWorks_IsLoaded();
native bool:SteamWorks_SetGameData(const String:sData[]);
native bool:SteamWorks_SetGameDescription(const String:sDesc[]);
native bool:SteamWorks_SetMapName(const String:sMapName[]);
native bool:SteamWorks_IsConnected();
native bool:SteamWorks_SetRule(const String:sKey[], const String:sValue[]);
native bool:SteamWorks_ClearRules();
native bool:SteamWorks_ForceHeartbeat();
native bool:SteamWorks_GetUserGroupStatus(client, groupid);
native bool:SteamWorks_GetUserGroupStatusAuthID(authid, groupid);
native EUserHasLicenseForAppResult:SteamWorks_HasLicenseForApp(client, app);
native EUserHasLicenseForAppResult:SteamWorks_HasLicenseForAppId(authid, app);
native SteamWorks_GetClientSteamID(client, String:sSteamID[], length);
native bool:SteamWorks_RequestStatsAuthID(authid, appid);
native bool:SteamWorks_RequestStats(client, appid);
native bool:SteamWorks_GetStatCell(client, const String:sKey[], &value);
native bool:SteamWorks_GetStatAuthIDCell(authid, const String:sKey[], &value);
native bool:SteamWorks_GetStatFloat(client, const String:sKey[], &Float:value);
native bool:SteamWorks_GetStatAuthIDFloat(authid, const String:sKey[], &Float:value);
native Handle:SteamWorks_CreateHTTPRequest(EHTTPMethod:method, const String:sURL[]);
native bool:SteamWorks_SetHTTPRequestContextValue(Handle:hHandle, any:data1, any:data2=0);
native bool:SteamWorks_SetHTTPRequestNetworkActivityTimeout(Handle:hHandle, timeout);
native bool:SteamWorks_SetHTTPRequestHeaderValue(Handle:hHandle, const String:sName[], const String:sValue[]);
native bool:SteamWorks_SetHTTPRequestGetOrPostParameter(Handle:hHandle, const String:sName[], const String:sValue[]);
native bool:SteamWorks_SetHTTPRequestUserAgentInfo(Handle:hHandle, const String:sUserAgentInfo[]);
native bool:SteamWorks_SetHTTPRequestRequiresVerifiedCertificate(Handle:hHandle, bool:bRequireVerifiedCertificate);
native bool:SteamWorks_SetHTTPRequestAbsoluteTimeoutMS(Handle:hHandle, unMilliseconds);
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 9
typeset SteamWorksHTTPRequestCompleted
{
function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode);
function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1);
function void (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, any data1, any data2);
};
typeset SteamWorksHTTPHeadersReceived
{
function void (Handle hRequest, bool bFailure);
function void (Handle hRequest, bool bFailure, any data1);
function void (Handle hRequest, bool bFailure, any data1, any data2);
};
typeset SteamWorksHTTPDataReceived
{
function void (Handle hRequest, bool bFailure, int offset, int bytesreceived);
function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1);
function void (Handle hRequest, bool bFailure, int offset, int bytesreceived, any data1, any data2);
};
typeset SteamWorksHTTPBodyCallback
{
function void (const char sData[]);
function void (const char sData[], any value);
function void (const int data[], any value, int datalen);
};
#else
funcenum SteamWorksHTTPRequestCompleted
{
public(Handle:hRequest, bool:bFailure, bool:bRequestSuccessful, EHTTPStatusCode:eStatusCode),
public(Handle:hRequest, bool:bFailure, bool:bRequestSuccessful, EHTTPStatusCode:eStatusCode, any:data1),
public(Handle:hRequest, bool:bFailure, bool:bRequestSuccessful, EHTTPStatusCode:eStatusCode, any:data1, any:data2)
};
funcenum SteamWorksHTTPHeadersReceived
{
public(Handle:hRequest, bool:bFailure),
public(Handle:hRequest, bool:bFailure, any:data1),
public(Handle:hRequest, bool:bFailure, any:data1, any:data2)
};
funcenum SteamWorksHTTPDataReceived
{
public(Handle:hRequest, bool:bFailure, offset, bytesreceived),
public(Handle:hRequest, bool:bFailure, offset, bytesreceived, any:data1),
public(Handle:hRequest, bool:bFailure, offset, bytesreceived, any:data1, any:data2)
};
funcenum SteamWorksHTTPBodyCallback
{
public(const String:sData[]),
public(const String:sData[], any:value),
public(const data[], any:value, datalen)
};
#endif
native bool:SteamWorks_SetHTTPCallbacks(Handle:hHandle, SteamWorksHTTPRequestCompleted:fCompleted = INVALID_FUNCTION, SteamWorksHTTPHeadersReceived:fHeaders = INVALID_FUNCTION, SteamWorksHTTPDataReceived:fData = INVALID_FUNCTION, Handle:hCalling = INVALID_HANDLE);
native bool:SteamWorks_SendHTTPRequest(Handle:hRequest);
native bool:SteamWorks_SendHTTPRequestAndStreamResponse(Handle:hRequest);
native bool:SteamWorks_DeferHTTPRequest(Handle:hRequest);
native bool:SteamWorks_PrioritizeHTTPRequest(Handle:hRequest);
native bool:SteamWorks_GetHTTPResponseHeaderSize(Handle:hRequest, const String:sHeader[], &size);
native bool:SteamWorks_GetHTTPResponseHeaderValue(Handle:hRequest, const String:sHeader[], String:sValue[], size);
native bool:SteamWorks_GetHTTPResponseBodySize(Handle:hRequest, &size);
native bool:SteamWorks_GetHTTPResponseBodyData(Handle:hRequest, String:sBody[], length);
native bool:SteamWorks_GetHTTPStreamingResponseBodyData(Handle:hRequest, cOffset, String:sBody[], length);
native bool:SteamWorks_GetHTTPDownloadProgressPct(Handle:hRequest, &Float:percent);
native bool:SteamWorks_GetHTTPRequestWasTimedOut(Handle:hRequest, &bool:bWasTimedOut);
native bool:SteamWorks_SetHTTPRequestRawPostBody(Handle:hRequest, const String:sContentType[], const String:sBody[], bodylen);
native bool:SteamWorks_SetHTTPRequestRawPostBodyFromFile(Handle:hRequest, const String:sContentType[], const String:sFileName[]);
native bool:SteamWorks_GetHTTPResponseBodyCallback(Handle:hRequest, SteamWorksHTTPBodyCallback:fCallback, any:data = 0, Handle:hPlugin = INVALID_HANDLE); /* Look up, moved definition for 1.7+ compat. */
native bool:SteamWorks_WriteHTTPResponseBodyToFile(Handle:hRequest, const String:sFileName[]);
forward SW_OnValidateClient(ownerauthid, authid);
forward SteamWorks_OnValidateClient(ownerauthid, authid);
forward SteamWorks_SteamServersConnected();
forward SteamWorks_SteamServersConnectFailure(EResult:result);
forward SteamWorks_SteamServersDisconnected(EResult:result);
forward Action:SteamWorks_RestartRequested();
forward SteamWorks_TokenRequested(String:sToken[], maxlen);
forward SteamWorks_OnClientGroupStatus(authid, groupid, bool:isMember, bool:isOfficer);
forward EGCResults:SteamWorks_GCSendMessage(unMsgType, const String:pubData[], cubData);
forward SteamWorks_GCMsgAvailable(cubData);
forward EGCResults:SteamWorks_GCRetrieveMessage(punMsgType, const String:pubDest[], cubDest, pcubMsgSize);
native EGCResults:SteamWorks_SendMessageToGC(unMsgType, const String:pubData[], cubData);
public Extension:__ext_SteamWorks =
{
name = "SteamWorks",
file = "SteamWorks.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_SteamWorks_SetNTVOptional()
{
MarkNativeAsOptional("SteamWorks_IsVACEnabled");
MarkNativeAsOptional("SteamWorks_GetPublicIP");
MarkNativeAsOptional("SteamWorks_GetPublicIPCell");
MarkNativeAsOptional("SteamWorks_IsLoaded");
MarkNativeAsOptional("SteamWorks_SetGameData");
MarkNativeAsOptional("SteamWorks_SetGameDescription");
MarkNativeAsOptional("SteamWorks_IsConnected");
MarkNativeAsOptional("SteamWorks_SetRule");
MarkNativeAsOptional("SteamWorks_ClearRules");
MarkNativeAsOptional("SteamWorks_ForceHeartbeat");
MarkNativeAsOptional("SteamWorks_GetUserGroupStatus");
MarkNativeAsOptional("SteamWorks_GetUserGroupStatusAuthID");
MarkNativeAsOptional("SteamWorks_HasLicenseForApp");
MarkNativeAsOptional("SteamWorks_HasLicenseForAppId");
MarkNativeAsOptional("SteamWorks_GetClientSteamID");
MarkNativeAsOptional("SteamWorks_RequestStatsAuthID");
MarkNativeAsOptional("SteamWorks_RequestStats");
MarkNativeAsOptional("SteamWorks_GetStatCell");
MarkNativeAsOptional("SteamWorks_GetStatAuthIDCell");
MarkNativeAsOptional("SteamWorks_GetStatFloat");
MarkNativeAsOptional("SteamWorks_GetStatAuthIDFloat");
MarkNativeAsOptional("SteamWorks_SendMessageToGC");
MarkNativeAsOptional("SteamWorks_CreateHTTPRequest");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestContextValue");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestNetworkActivityTimeout");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestHeaderValue");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestGetOrPostParameter");
MarkNativeAsOptional("SteamWorks_SetHTTPCallbacks");
MarkNativeAsOptional("SteamWorks_SendHTTPRequest");
MarkNativeAsOptional("SteamWorks_SendHTTPRequestAndStreamResponse");
MarkNativeAsOptional("SteamWorks_DeferHTTPRequest");
MarkNativeAsOptional("SteamWorks_PrioritizeHTTPRequest");
MarkNativeAsOptional("SteamWorks_GetHTTPResponseHeaderSize");
MarkNativeAsOptional("SteamWorks_GetHTTPResponseHeaderValue");
MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodySize");
MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodyData");
MarkNativeAsOptional("SteamWorks_GetHTTPStreamingResponseBodyData");
MarkNativeAsOptional("SteamWorks_GetHTTPDownloadProgressPct");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBody");
MarkNativeAsOptional("SteamWorks_SetHTTPRequestRawPostBodyFromFile");
MarkNativeAsOptional("SteamWorks_GetHTTPResponseBodyCallback");
MarkNativeAsOptional("SteamWorks_WriteHTTPResponseBodyToFile");
}
#endif
+765
View File
@@ -0,0 +1,765 @@
/**
* AutoExecConfig
*
* Copyright (C) 2013-2019 Impact
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#if defined _autoexecconfig_included
#endinput
#endif
#define _autoexecconfig_included
#include <sourcemod>
#define AUTOEXECCONFIG_VERSION "0.1.5"
#define AUTOEXECCONFIG_URL "https://forums.alliedmods.net/showthread.php?t=204254"
// Append
#define AUTOEXEC_APPEND_BAD_FILENAME 0
#define AUTOEXEC_APPEND_FILE_NOT_FOUND 1
#define AUTOEXEC_APPEND_BAD_HANDLE 2
#define AUTOEXEC_APPEND_SUCCESS 3
// Find
#define AUTOEXEC_FIND_BAD_FILENAME 10
#define AUTOEXEC_FIND_FILE_NOT_FOUND 11
#define AUTOEXEC_FIND_BAD_HANDLE 12
#define AUTOEXEC_FIND_NOT_FOUND 13
#define AUTOEXEC_FIND_SUCCESS 14
// Clean
#define AUTOEXEC_CLEAN_FILE_NOT_FOUND 20
#define AUTOEXEC_CLEAN_BAD_HANDLE 21
#define AUTOEXEC_CLEAN_SUCCESS 22
// General
#define AUTOEXEC_NO_CONFIG 30
// Formatter
#define AUTOEXEC_FORMAT_BAD_FILENAME 40
#define AUTOEXEC_FORMAT_SUCCESS 41
// Global variables
static char g_sConfigFile[PLATFORM_MAX_PATH];
static char g_sRawFileName[PLATFORM_MAX_PATH];
static char g_sFolderPath[PLATFORM_MAX_PATH];
static bool g_bCreateFile = false;
static Handle g_hPluginHandle = null;
static bool g_bCreateDirectory = false;
static int g_bCreateDirectoryMode = FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC|FPERM_G_READ|FPERM_G_EXEC|FPERM_O_READ|FPERM_O_EXEC;
// Workaround for now
static int g_iLastFindResult;
static int g_iLastAppendResult;
/**
* Returns the last result from the parser.
*
* @return Returns one of the AUTOEXEC_FIND values or -1 if not set.
*/
stock int AutoExecConfig_GetFindResult()
{
return g_iLastFindResult;
}
/**
* Returns the last result from the appender.
*
* @return Returns one of the AUTOEXEC_APPEND values or -1 if not set.
*/
stock int AutoExecConfig_GetAppendResult()
{
return g_iLastAppendResult;
}
/**
* Set if the config file should be created by the autoexecconfig include itself if it doesn't exist.
*
* @param create True if config file should be created, false otherwise.
* @noreturn
*/
stock void AutoExecConfig_SetCreateFile(bool create)
{
g_bCreateFile = create;
}
/**
* Set if the config file's folder should be created by the autoexecconfig include itself if it doesn't exist.
* Note: Must be used before AutoExecConfig_SetFile as the potential creation of it happens there
*
* @param create True if config file should be created, false otherwise.
* @param mode Folder permission mode, default is u=rwx,g=rx,o=rx.
* @noreturn
*/
stock void AutoExecConfig_SetCreateDirectory(bool create, int mode=FPERM_U_READ|FPERM_U_WRITE|FPERM_U_EXEC|FPERM_G_READ|FPERM_G_EXEC|FPERM_O_READ|FPERM_O_EXEC)
{
g_bCreateDirectory = create;
g_bCreateDirectoryMode = mode;
}
/**
* Returns if the config file should be created if it doesn't exist.
*
* @return Returns true, if the config file should be created or false if it should not.
*/
stock bool AutoExecConfig_GetCreateFile()
{
return g_bCreateFile;
}
/**
* Set the plugin for which the config file should be created.
* Set to null to use the calling plugin.
* Used to print the correct filename in the top comment when creating the file.
*
* @param plugin The plugin to create convars for or null to use the calling plugin.
* @noreturn
*/
stock void AutoExecConfig_SetPlugin(Handle plugin)
{
g_hPluginHandle = plugin;
}
/**
* Returns the plugin's handle for which the config file is created.
*
* @return The plugin handle
*/
stock Handle AutoExecConfig_GetPlugin()
{
return g_hPluginHandle;
}
/**
* Set the global autoconfigfile used by functions of this file.
* Note: does not support subfolders like folder1/folder2
*
* @param file Name of the config file, path and .cfg extension is being added if not given.
* @param folder Folder under cfg/ to use. By default this is "sourcemod."
* @return True if formatter returned success, false otherwise.
*/
stock bool AutoExecConfig_SetFile(char[] file, char[] folder="sourcemod")
{
Format(g_sConfigFile, sizeof(g_sConfigFile), "%s", file);
// Global buffers for cfg execution
strcopy(g_sRawFileName, sizeof(g_sRawFileName), file);
strcopy(g_sFolderPath, sizeof(g_sFolderPath), folder);
// Format the filename
return AutoExecConfig_FormatFileName(g_sConfigFile, sizeof(g_sConfigFile), folder) == AUTOEXEC_FORMAT_SUCCESS;
}
/**
* Get the formatted autoconfigfile used by functions of this file.
*
* @param buffer String to format.
* @param size Maximum size of buffer
* @return True if filename was set, false otherwise.
*/
stock bool AutoExecConfig_GetFile(char[] buffer,int size)
{
if (strlen(g_sConfigFile) > 0)
{
strcopy(buffer, size, g_sConfigFile);
return true;
}
// Security for decl users
buffer[0] = '\0';
return false;
}
/**
* Creates a convar and appends it to the autoconfigfile if not found.
* FCVAR_DONTRECORD will be skipped.
*
* @param name Name of new convar.
* @param defaultValue String containing the default value of new convar.
* @param description Optional description of the convar.
* @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
* @param hasMin Optional boolean that determines if the convar has a minimum value.
* @param min Minimum floating point value that the convar can have if hasMin is true.
* @param hasMax Optional boolean that determines if the convar has a maximum value.
* @param max Maximum floating point value that the convar can have if hasMax is true.
* @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
* @error Convar name is blank or is the same as an existing console command.
*/
stock ConVar AutoExecConfig_CreateConVar(const char[] name, const char[] defaultValue, const char[] description="", int flags=0, bool hasMin=false, float min=0.0, bool hasMax=false, float max=0.0)
{
// If configfile was set and convar has no dontrecord flag
if (!(flags & FCVAR_DONTRECORD) && strlen(g_sConfigFile) > 0)
{
// Reset the results
g_iLastFindResult = -1;
g_iLastAppendResult = -1;
// Add it if not found
char buffer[64];
g_iLastFindResult = AutoExecConfig_FindValue(name, buffer, sizeof(buffer), true);
// We only add this convar if it doesn't exist, or the file doesn't exist and it should be auto-generated
if (g_iLastFindResult == AUTOEXEC_FIND_NOT_FOUND || (g_iLastFindResult == AUTOEXEC_FIND_FILE_NOT_FOUND && g_bCreateFile))
{
g_iLastAppendResult = AutoExecConfig_AppendValue(name, defaultValue, description, flags, hasMin, min, hasMax, max);
}
}
// Create the convar
return CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
}
/**
* Executes the autoconfigfile and adds it to the OnConfigsExecuted forward.
* If we didn't create it ourselves we let SourceMod create it.
*
* @noreturn
*/
stock void AutoExecConfig_ExecuteFile()
{
// Only let sourcemod create the file, if we didn't do that already.
AutoExecConfig(!g_bCreateFile, g_sRawFileName, g_sFolderPath);
}
/**
* Formats a autoconfigfile, prefixes path and adds .cfg extension if missing.
*
* @param buffer String to format.
* @param size Maximum size of buffer.
* @return Returns one of the AUTOEXEC_FORMAT values..
*/
stock static int AutoExecConfig_FormatFileName(char[] buffer, int size, char[] folder="sourcemod")
{
// No config set
if (strlen(g_sConfigFile) < 1)
{
return AUTOEXEC_NO_CONFIG;
}
// Can't be an cfgfile
if (StrContains(g_sConfigFile, ".cfg") != -1 && strlen(g_sConfigFile) < 4)
{
return AUTOEXEC_FORMAT_BAD_FILENAME;
}
// Pathprefix
char pathprefixbuffer[PLATFORM_MAX_PATH];
if (strlen(folder) > 0)
{
Format(pathprefixbuffer, sizeof(pathprefixbuffer), "cfg/%s/", folder);
if (g_bCreateDirectory && !DirExists(pathprefixbuffer))
{
CreateDirectory(pathprefixbuffer, g_bCreateDirectoryMode);
}
}
else
{
Format(pathprefixbuffer, sizeof(pathprefixbuffer), "cfg/");
}
char filebuffer[PLATFORM_MAX_PATH];
filebuffer[0] = '\0';
// Add path if file doesn't begin with it
if (StrContains(buffer, pathprefixbuffer) != 0)
{
StrCat(filebuffer, sizeof(filebuffer), pathprefixbuffer);
}
StrCat(filebuffer, sizeof(filebuffer), g_sConfigFile);
// Add .cfg extension if file doesn't end with it
if (StrContains(filebuffer[strlen(filebuffer) - 4], ".cfg") != 0)
{
StrCat(filebuffer, sizeof(filebuffer), ".cfg");
}
strcopy(buffer, size, filebuffer);
return AUTOEXEC_FORMAT_SUCCESS;
}
/**
* Appends a convar to the global autoconfigfile
*
* @param name Name of new convar.
* @param defaultValue String containing the default value of new convar.
* @param description Optional description of the convar.
* @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
* @param hasMin Optional boolean that determines if the convar has a minimum value.
* @param min Minimum floating point value that the convar can have if hasMin is true.
* @param hasMax Optional boolean that determines if the convar has a maximum value.
* @param max Maximum floating point value that the convar can have if hasMax is true.
* @return Returns one of the AUTOEXEC_APPEND values
*/
stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValue, const char[] description, int flags, bool hasMin, float min, bool hasMax, float max)
{
// No config set
if (strlen(g_sConfigFile) < 1)
{
return AUTOEXEC_NO_CONFIG;
}
char filebuffer[PLATFORM_MAX_PATH];
strcopy(filebuffer, sizeof(filebuffer), g_sConfigFile);
//PrintToServer("pathbuffer: %s", filebuffer);
bool bFileExists = FileExists(filebuffer);
if (g_bCreateFile || bFileExists)
{
// If the file already exists we open it in append mode, otherwise we use a write mode which creates the file
File fFile = OpenFile(filebuffer, (bFileExists ? "a" : "w"));
char writebuffer[2048];
if (fFile == null)
{
return AUTOEXEC_APPEND_BAD_HANDLE;
}
// We just created the file, so add some header about version and stuff
if (g_bCreateFile && !bFileExists)
{
fFile.WriteLine( "// This file was auto-generated by AutoExecConfig v%s (%s)", AUTOEXECCONFIG_VERSION, AUTOEXECCONFIG_URL);
GetPluginFilename(g_hPluginHandle, writebuffer, sizeof(writebuffer));
Format(writebuffer, sizeof(writebuffer), "// ConVars for plugin \"%s\"", writebuffer);
fFile.WriteLine(writebuffer);
}
// Spacer
fFile.WriteLine("\n");
// This is used for multiline comments
int newlines = GetCharCountInStr('\n', description);
if (newlines == 0)
{
// We have no newlines, we can write the description to the file as is
Format(writebuffer, sizeof(writebuffer), "// %s", description);
fFile.WriteLine(writebuffer);
}
else
{
char[][] newlineBuf = new char[newlines +1][2048];
ExplodeString(description, "\n", newlineBuf, newlines +1, 2048, false);
// Each newline gets a commented newline
for (int i; i <= newlines; i++)
{
if (strlen(newlineBuf[i]) > 0)
{
fFile.WriteLine("// %s", newlineBuf[i]);
}
}
}
// Descspacer
fFile.WriteLine("// -");
// Default
Format(writebuffer, sizeof(writebuffer), "// Default: \"%s\"", defaultValue);
fFile.WriteLine(writebuffer);
// Minimum
if (hasMin)
{
Format(writebuffer, sizeof(writebuffer), "// Minimum: \"%f\"", min);
fFile.WriteLine(writebuffer);
}
// Maximum
if (hasMax)
{
Format(writebuffer, sizeof(writebuffer), "// Maximum: \"%f\"", max);
fFile.WriteLine(writebuffer);
}
// Write end and defaultvalue
Format(writebuffer, sizeof(writebuffer), "%s \"%s\"", name, defaultValue);
fFile.WriteLine(writebuffer);
fFile.Close();
return AUTOEXEC_APPEND_SUCCESS;
}
return AUTOEXEC_APPEND_FILE_NOT_FOUND;
}
/**
* Returns a convar's value from the global autoconfigfile
*
* @param cvar Cvar to search for.
* @param value Buffer to store result into.
* @param size Maximum size of buffer.
* @param caseSensitive Whether or not the search should be case sensitive.
* @return Returns one of the AUTOEXEC_FIND values
*/
stock int AutoExecConfig_FindValue(const char[] cvar, char[] value, int size, bool caseSensitive=false)
{
// Security for decl users
value[0] = '\0';
// No config set
if (strlen(g_sConfigFile) < 1)
{
return AUTOEXEC_NO_CONFIG;
}
char filebuffer[PLATFORM_MAX_PATH];
strcopy(filebuffer, sizeof(filebuffer), g_sConfigFile);
//PrintToServer("pathbuffer: %s", filebuffer);
bool bFileExists = FileExists(filebuffer);
// We want to create the config file and it doesn't exist yet.
if (g_bCreateFile && !bFileExists)
{
return AUTOEXEC_FIND_FILE_NOT_FOUND;
}
if (bFileExists)
{
File fFile = OpenFile(filebuffer, "r");
int valuestart;
int valueend;
int cvarend;
// Just an reminder to self, leave the values that high
char sConvar[64];
char sValue[64];
char readbuffer[2048];
char copybuffer[2048];
if (fFile == null)
{
return AUTOEXEC_FIND_BAD_HANDLE;
}
while (!fFile.EndOfFile() && fFile.ReadLine(readbuffer, sizeof(readbuffer)))
{
// Is a comment or not valid
if (IsCharSpace(readbuffer[0]) || readbuffer[0] == '/' || (!IsCharNumeric(readbuffer[0]) && !IsCharAlpha(readbuffer[0])) )
{
continue;
}
// Has not enough spaces, must have at least 1
if (GetCharCountInStr(' ', readbuffer) < 1)
{
continue;
}
// Ignore cvars which aren't quoted
if (GetCharCountInStr('"', readbuffer) != 2)
{
continue;
}
// Get the start of the value
if ( (valuestart = StrContains(readbuffer, "\"")) == -1 )
{
continue;
}
// Get the end of the value
if ( (valueend = StrContains(readbuffer[valuestart+1], "\"")) == -1 )
{
continue;
}
// Get the start of the cvar,
if ( (cvarend = StrContains(readbuffer, " ")) == -1 || cvarend >= valuestart)
{
continue;
}
// Skip if cvarendindex is before valuestartindex
if (cvarend >= valuestart)
{
continue;
}
// Convar
// Tempcopy for security
strcopy(copybuffer, sizeof(copybuffer), readbuffer);
copybuffer[cvarend] = '\0';
strcopy(sConvar, sizeof(sConvar), copybuffer);
// Value
// Tempcopy for security
strcopy(copybuffer, sizeof(copybuffer), readbuffer[valuestart+1]);
copybuffer[valueend] = '\0';
strcopy(sValue, sizeof(sValue), copybuffer);
//PrintToServer("Cvar %s has a value of %s", sConvar, sValue);
if (StrEqual(sConvar, cvar, caseSensitive))
{
Format(value, size, "%s", sConvar);
fFile.Close();
return AUTOEXEC_FIND_SUCCESS;
}
}
fFile.Close();
return AUTOEXEC_FIND_NOT_FOUND;
}
return AUTOEXEC_FIND_FILE_NOT_FOUND;
}
/**
* Cleans the global autoconfigfile from too much spaces
*
* @return One of the AUTOEXEC_CLEAN values.
*/
stock int AutoExecConfig_CleanFile()
{
// No config set
if (strlen(g_sConfigFile) < 1)
{
return AUTOEXEC_NO_CONFIG;
}
char sfile[PLATFORM_MAX_PATH];
strcopy(sfile, sizeof(sfile), g_sConfigFile);
// Security
if (!FileExists(sfile))
{
return AUTOEXEC_CLEAN_FILE_NOT_FOUND;
}
char sfile2[PLATFORM_MAX_PATH];
Format(sfile2, sizeof(sfile2), "%s_tempcopy", sfile);
char readbuffer[2048];
int count;
bool firstreached;
// Open files
File fFile1 = OpenFile(sfile, "r");
File fFile2 = OpenFile(sfile2, "w");
// Check filehandles
if (fFile1 == null || fFile2 == null)
{
if (fFile1 != null)
{
//PrintToServer("Handle1 invalid");
fFile1.Close();
}
if (fFile2 != null)
{
//PrintToServer("Handle2 invalid");
fFile2.Close();
}
return AUTOEXEC_CLEAN_BAD_HANDLE;
}
while (!fFile1.EndOfFile() && fFile1.ReadLine(readbuffer, sizeof(readbuffer)))
{
// Is space
if (IsCharSpace(readbuffer[0]))
{
count++;
}
// No space, count from start
else
{
count = 0;
}
// Don't write more than 1 space if seperation after informations have been reached
if (count < 2 || !firstreached)
{
ReplaceString(readbuffer, sizeof(readbuffer), "\n", "");
fFile2.WriteLine(readbuffer);
}
// First bigger seperation after informations has been reached
if (count == 2)
{
firstreached = true;
}
}
fFile1.Close();
fFile2.Close();
// This might be a risk, for now it works
DeleteFile(sfile);
RenameFile(sfile, sfile2);
return AUTOEXEC_CLEAN_SUCCESS;
}
/**
* Returns how many times the given char occures in the given string.
*
* @param str String to search for in.
* @return Occurences of the given char found in string.
*/
stock static int GetCharCountInStr(int character, const char[] str)
{
int len = strlen(str);
int count;
for (int i; i < len; i++)
{
if (str[i] == character)
{
count++;
}
}
return count;
}
#pragma deprecated
stock bool AutoExecConfig_CacheConvars()
{
return false;
}
+191
View File
@@ -0,0 +1,191 @@
/**
* This is the include file for Custom Chat Colors
* https://forums.alliedmods.net/showthread.php?t=186695
* To check that Custom Chat Colors is installed and running, verify that the "ccc" library exists
*/
#if defined _ccc_included
#endinput
#endif
#define _ccc_included
enum CCC_ColorType {
CCC_TagColor,
CCC_NameColor,
CCC_ChatColor
};
#define COLOR_NULL -1
#define COLOR_NONE -2
#define COLOR_CGREEN -3 //0x40FF40
#define COLOR_OLIVE -4 //0x99FF99
#define COLOR_TEAM -5
/**
* Gets a client's color as a hexadecimal integer.
*
* @param client Client index
* @param type Color type to retreive
* @param alpha Pass a boolean variable by reference here and it will be true if the color has alpha specified or false if it doesn't (or is a stock color)
* @return Color as a hexadecimal integer (use %X in formatting to get a hexadecimal string)
*
* On error/errors: Invalid client index or client is not in game
*/
native int CCC_GetColor(int client, CCC_ColorType type, bool &alpha = false);
/**
* Sets a client's color as a hexadecimal integer.
*
* @param client Client index
* @param type Color type to set
* @param color Integer representation of the color (use StringToInt(input, 16) to convert a hexadecimal string) or one of the color defines
* @param alpha Are you specifying a color with alpha?
* @return True if the color is updated successfully, false otherwise
*
* On error/errors: Invalid client index or client is not in game
*/
native int CCC_SetColor(int client, CCC_ColorType type, int color, bool alpha);
/**
* Gets a client's tag
*
* @param client Client index
* @param buffer Buffer to store the tag in
* @param maxlen Maximum buffer length
* @noreturn
*
* On error/errors: Invalid client index or client is not in game
*/
native int CCC_GetTag(int client, char[] buffer, int maxlen);
/**
* Sets a client's tag
*
* @param client Client index
* @param tag String containing the new tag
* @noreturn
*
* On error/errors: Invalid client index or client is not in game
*/
native void CCC_SetTag(int client, const char[] tag);
/**
* Resets a client's color to the value in the config file.
*
* @param client Client index
* @param type Color type to restore
* @noreturn
*
* On error/errors: Invalid client index or client is not in game
*/
native int CCC_ResetColor(int client, CCC_ColorType type);
/**
* Resets a client's tag to the value in the config file.
*
* @param client Client index
* @noreturn
*
* On error/errors: Invalid client index or client is not in game
*/
native int CCC_ResetTag(int client);
/**
* Called when a cilent's name is about to be colored
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
*
* @param client Client index
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
*/
//#pragma deprecated Use CCC_OnColor instead
//forward Action:CCC_OnNameColor(client);
/**
* Called when a client's chat is about to be colored
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
*
* @param client Client index
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
*/
//#pragma deprecated Use CCC_OnColor instead
//forward Action:CCC_OnChatColor(client);
/**
* Called when a client's name is about to be tagged
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
*
* @param client Client index
* @return Plugin_Handled to prevent tagging, Plugin_Continue to allow tagging
*/
//#pragma deprecated Use CCC_OnColor instead
//forward Action:CCC_OnTagApplied(client);
/**
* Called when a client's name is about to be tagged
* DO NOT START A NEW USERMESSAGE (i.e. PrintToChat, PrintToChatAll) WITHIN THIS FORWARD
*
* @param client Client index
* @param message Chat message that will be printed
* @param type What type of color will be applied. If this is CCC_TagColor, it controls whether the tag will be applied at all, not whether the tag will be colored.
* @return Plugin_Handled to prevent coloring, Plugin_Continue to allow coloring
*/
//forward Action:CCC_OnColor(client, const String:message[], CCC_ColorType:type);
/**
* Called when a message has been fully colored and will be sent, unless further plugins modify it through Simple Chat Processor
*
* @param client Recieving client index
* @param author Author client index
* @param message Message
* @return Plugin_Handled to block message, Plugin_Continue to allow message
*/
forward Action CCC_OnChatMessage(int client, int author, const char[] message);
/**
* Called when a client's colors and tag are about to be loaded from the config file
* At this point, the client has NO COLORS
*
* @param client Client index
* @return Plugin_Handled or Plugin_Stop to prevent loading, Plugin_Continue or Plugin_Changed to allow
*/
forward Action CCC_OnUserConfigPreLoaded(int client);
/**
* Called when a client's colors and tag have been loaded from the config file
*
* @param client Client index
* @noreturn
*/
forward void CCC_OnUserConfigLoaded(int client);
/**
* Called when the configuration file is reloaded with the sm_reloadccc command
*
* @noreturn
*/
forward void CCC_OnConfigReloaded();
native int CCC_UpdateIgnoredArray(bool IgnoredArray[(MAXPLAYERS + 1) * (MAXPLAYERS + 1)]);
public SharedPlugin __pl_ccc =
{
name = "ccc",
file = "custom-chatcolors.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_ccc_SetNTVOptional() {
MarkNativeAsOptional("CCC_GetColor");
MarkNativeAsOptional("CCC_SetColor");
MarkNativeAsOptional("CCC_GetTag");
MarkNativeAsOptional("CCC_ResetTag");
MarkNativeAsOptional("CCC_ResetColor");
MarkNativeAsOptional("CCC_ResetTag");
MarkNativeAsOptional("CCC_UpdateIgnoredArray");
}
#endif
+51
View File
@@ -0,0 +1,51 @@
#if defined _connecthook_included
#endinput
#endif
#define _connecthook_included
enum EConnect
{
k_OnClientPreConnectEx_Reject = 0,
k_OnClientPreConnectEx_Async = 1,
k_OnClientPreConnectEx_Accept = 2,
};
typedef PreConnectHook = function EConnect (int id, const char[] sName, const char[] sPassword, const char[] sIP, const char[] sSteam32ID, char sRejectReason[512]);
// The lower priority value takes more precedence.
native void ClientPreConnect_Hook(int prio, PreConnectHook func);
native void ClientPreConnect_Unhook(int prio, PreConnectHook func);
native bool ClientPreConnect_Reject(int id, const char[] reason);
native bool ClientPreConnect_Accept(int id);
native int ClientPreConnect_GetConnectClientCount();
public Extension __ext_connecthook =
{
name = "connecthook",
file = "connecthook.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public void __ext_connecthook_SetNTVOptional()
{
MarkNativeAsOptional("ClientPreConnect_Hook");
MarkNativeAsOptional("ClientPreConnect_Unhook");
MarkNativeAsOptional("ClientPreConnect_Reject");
MarkNativeAsOptional("ClientPreConnect_Accept");
MarkNativeAsOptional("ClientPreConnect_GetConnectClientCount");
}
#endif
+603
View File
@@ -0,0 +1,603 @@
#if defined _dhooks_included
#endinput
#endif
#define _dhooks_included
enum ObjectValueType
{
ObjectValueType_Int = 0,
ObjectValueType_Bool,
ObjectValueType_Ehandle,
ObjectValueType_Float,
ObjectValueType_CBaseEntityPtr,
ObjectValueType_IntPtr,
ObjectValueType_BoolPtr,
ObjectValueType_EhandlePtr,
ObjectValueType_FloatPtr,
ObjectValueType_Vector,
ObjectValueType_VectorPtr,
ObjectValueType_CharPtr,
ObjectValueType_String
};
enum ListenType
{
ListenType_Created,
ListenType_Deleted
};
enum ReturnType
{
ReturnType_Unknown,
ReturnType_Void,
ReturnType_Int,
ReturnType_Bool,
ReturnType_Float,
ReturnType_String, //Note this is a string_t
ReturnType_StringPtr, //Note this is a string_t *
ReturnType_CharPtr,
ReturnType_Vector,
ReturnType_VectorPtr,
ReturnType_CBaseEntity,
ReturnType_Edict
};
enum HookParamType
{
HookParamType_Unknown,
HookParamType_Int,
HookParamType_Bool,
HookParamType_Float,
HookParamType_String, //Note this is a string_t
HookParamType_StringPtr, //Note this is a string_t *
HookParamType_CharPtr,
HookParamType_VectorPtr,
HookParamType_CBaseEntity,
HookParamType_ObjectPtr,
HookParamType_Edict,
HookParamType_Object
};
enum ThisPointerType
{
ThisPointer_Ignore,
ThisPointer_CBaseEntity,
ThisPointer_Address
};
enum HookType
{
HookType_Entity,
HookType_GameRules,
HookType_Raw
};
enum CallingConvention
{
CallConv_CDECL,
CallConv_THISCALL,
CallConv_STDCALL,
CallConv_FASTCALL,
};
enum MRESReturn
{
MRES_ChangedHandled = -2, // Use changed values and return MRES_Handled
MRES_ChangedOverride, // Use changed values and return MRES_Override
MRES_Ignored, // plugin didn't take any action
MRES_Handled, // plugin did something, but real function should still be called
MRES_Override, // call real function, but use my return value
MRES_Supercede // skip real function; use my return value
};
enum DHookPassFlag
{
DHookPass_ByVal = (1<<0), /**< Passing by value */
DHookPass_ByRef = (1<<1), /**< Passing by reference */
DHookPass_ODTOR = (1<<2), /**< Object has a destructor */
DHookPass_OCTOR = (1<<3), /**< Object has a constructor */
DHookPass_OASSIGNOP = (1<<4), /**< Object has an assignment operator */
};
enum DHookRegister
{
// Don't change the register and use the default for the calling convention.
DHookRegister_Default,
// 8-bit general purpose registers
DHookRegister_AL,
DHookRegister_CL,
DHookRegister_DL,
DHookRegister_BL,
DHookRegister_AH,
DHookRegister_CH,
DHookRegister_DH,
DHookRegister_BH,
// 32-bit general purpose registers
DHookRegister_EAX,
DHookRegister_ECX,
DHookRegister_EDX,
DHookRegister_EBX,
DHookRegister_ESP,
DHookRegister_EBP,
DHookRegister_ESI,
DHookRegister_EDI,
// 128-bit XMM registers
DHookRegister_XMM0,
DHookRegister_XMM1,
DHookRegister_XMM2,
DHookRegister_XMM3,
DHookRegister_XMM4,
DHookRegister_XMM5,
DHookRegister_XMM6,
DHookRegister_XMM7,
// 80-bit FPU registers
DHookRegister_ST0
};
typeset ListenCB
{
//Deleted
function void (int entity);
//Created
function void (int entity, const char[] classname);
};
typeset DHookRemovalCB
{
function void (int hookid);
};
typeset DHookCallback
{
//Function Example: void Ham::Test() with this pointer ignore
function MRESReturn ();
//Function Example: void Ham::Test() with this pointer passed
function MRESReturn (int pThis);
//Function Example: void Ham::Test(int cake) with this pointer ignore
function MRESReturn (Handle hParams);
//Function Example: void Ham::Test(int cake) with this pointer passed
function MRESReturn (int pThis, Handle hParams);
//Function Example: int Ham::Test() with this pointer ignore
function MRESReturn (Handle hReturn);
//Function Example: int Ham::Test() with this pointer passed
function MRESReturn (int pThis, Handle hReturn);
//Function Example: int Ham::Test(int cake) with this pointer ignore
function MRESReturn (Handle hReturn, Handle hParams);
//Function Example: int Ham::Test(int cake) with this pointer passed
function MRESReturn (int pThis, Handle hReturn, Handle hParams);
//Address NOW
//Function Example: void Ham::Test() with this pointer passed
function MRESReturn (Address pThis);
//Function Example: void Ham::Test(int cake) with this pointer passed
function MRESReturn (Address pThis, Handle hParams);
//Function Example: int Ham::Test() with this pointer passed
function MRESReturn (Address pThis, Handle hReturn);
//Function Example: int Ham::Test(int cake) with this pointer passed
function MRESReturn (Address pThis, Handle hReturn, Handle hParams);
};
/* Adds an entity listener hook
*
* @param type Type of listener to add
* @param callback Callback to use
*
* @noreturn
*/
native void DHookAddEntityListener(ListenType type, ListenCB callback);
/* Removes an entity listener hook
*
* @param type Type of listener to remove
* @param callback Callback this listener was using
*
* @return True if one was removed false otherwise.
*/
native bool DHookRemoveEntityListener(ListenType type, ListenCB callback);
/* Creates a hook
*
* @param offset vtable offset for function to hook
* @param hooktype Type of hook
* @param returntype Type type of return
* @param thistype Type of this pointer or ignore (ignore can be used if not needed)
* @param callback Optional callback function, if not set here must be set when hooking.
*
* @return Returns setup handle for the hook.
* @error Failed to create hook setup handle or invalid callback function.
*/
native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION);
/**
* Creates a detour
*
* @param funcaddr The address of the function to detour.
* Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf.
* @param callConv Calling convention of the function.
* @param returnType Type of the return value.
* @param thisType Type of this pointer or ignore (ignore can be used if not needed)
*
* @return Setup handle for the detour.
* @error Failed to create detour setup handle.
*/
native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType);
/**
* Setup a detour or hook for a function as described in a "Functions" section in gamedata.
*
* @param gameconf GameConfig handle
* @param name Name of the function in the gamedata to load.
*
* @return Setup handle for the detour or INVALID_HANDLE if offset/signature/address wasn't found.
* @error Failed to create detour setup handle, invalid gamedata handle, invalid callback function or failed to find function in gamedata.
*/
native Handle DHookCreateFromConf(Handle gameconf, const char[] name);
/**
* Load details for a vhook or detour from a gamedata file.
*
* @param setup Hook setup handle to set the offset or address on.
* @param gameconf GameConfig handle
* @param source Whether to look in Offsets or Signatures.
* @param name Name of the property to find.
*
* @return True on success, false if nothing was found.
* @error Invalid setup or gamedata handle.
*/
native bool DHookSetFromConf(Handle setup, Handle gameconf, SDKFuncConfSource source, const char[] name);
/**
* Enable the detour of the function described in the hook setup handle.
*
* @param setup Hook setup handle
* @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
* @param callback Callback function
*
* @return True if detour was enabled, false otherwise.
* @error Hook handle is not setup for a detour.
*/
native bool DHookEnableDetour(Handle setup, bool post, DHookCallback callback);
/**
* Disable the detour of the function described in the hook setup handle.
*
* @param setup Hook setup handle
* @param post True to disable a post hook.
* @param callback Callback function
*
* @return True if detour was disabled, false otherwise.
* @error Hook handle is not setup for a detour or function is not detoured.
*/
native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback);
/* Adds param to a hook setup
*
* @param setup Setup handle to add the param to.
* @param type Param type
* @param size Used for Objects (not Object ptr) to define the size of the object.
* @param flag Used to change the pass type.
* @param custom_register The register this argument is passed in instead of the stack.
*
* @error Invalid setup handle or too many params added (request upping the max in thread)
* @noreturn
*/
native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default);
/* Hook entity
*
* @param setup Setup handle to use to add the hook.
* @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
* @param entity Entity index to hook on.
* @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback)
* @param callback Optional callback function, if not set here must be set when creating the hook.
*
* @error Invalid setup handle, invalid entity, invalid hook type or invalid callback.
* @return -1 on fail a hookid on success
*/
native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Hook gamerules
*
* @param setup Setup handle to use to add the hook.
* @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
* @param removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback)
* @param callback Optional callback function, if not set here must be set when creating the hook.
*
* @error Invalid setup handle, failing to get gamerules pointer, invalid hook type or invalid callback.
* @return -1 on fail a hookid on success
*/
native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Hook a raw pointer
*
* @param setup Setup handle to use to add the hook.
* @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!)
* @param addr This pointer address.
* @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback)
* @param callback Optional callback function, if not set here must be set when creating the hook.
*
* @error Invalid setup handle, invalid address, invalid hook type or invalid callback.
* @return -1 on fail a hookid on success
*/
native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION);
/* Remove hook by hook id
*
* @param hookid Hook id to remove
*
* @return true on success false otherwise
* @note This will not fire the removal callback!
*/
native bool DHookRemoveHookID(int hookid);
/* Get param value (Only use for: int, entity, bool or float param types)
*
* @param hParams Handle to params structure
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1. 0 Will return the number of params stored)
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @return value if num greater than 0. If 0 returns paramcount.
*/
native any DHookGetParam(Handle hParams, int num);
/* Get vector param value
*
* @param hParams Handle to params structure
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.)
* @param vec Vector buffer to store result.
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn
*/
native void DHookGetParamVector(Handle hParams, int num, float vec[3]);
/* Get string param value
*
* @param hParams Handle to params structure
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first param num would be 1.)
* @param buffer String buffer to store result
* @param size Buffer size
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn
*/
native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size);
/* Set param value (Only use for: int, entity, bool or float param types)
*
* @param hParams Handle to params structure
* @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
* @param value Value to set it as (only pass int, bool, float or entity index)
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn
*/
native void DHookSetParam(Handle hParams, int num, any value);
/* Set vector param value
*
* @param hParams Handle to params structure
* @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
* @param vec Value to set vector as.
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn
*/
native void DHookSetParamVector(Handle hParams, int num, float vec[3]);
/* Set string param value
*
* @param hParams Handle to params structure
* @params num Param number to set (Example if the function has 2 params and you need to set the value of the first param num would be 1.)
* @param value Value to set string as.
*
* @error Invalid handle. Invalid param number. Invalid param type.
* @noreturn
*/
native void DHookSetParamString(Handle hParams, int num, char[] value);
/* Get return value (Only use for: int, entity, bool or float return types)
*
* @param hReturn Handle to return structure
*
* @error Invalid Handle, invalid type.
* @return Returns default value if prehook returns actual value if post hook.
*/
native any DHookGetReturn(Handle hReturn);
/* Get return vector value
*
* @param hReturn Handle to return structure
* @param vec Vector buffer to store result in. (In pre hooks will be default value (0.0,0.0,0.0))
*
* @error Invalid Handle, invalid type.
* @noreturn
*/
native void DHookGetReturnVector(Handle hReturn, float vec[3]);
/* Get return string value
*
* @param hReturn Handle to return structure
* @param buffer String buffer to store result in. (In pre hooks will be default value "")
* @param size String buffer size
*
* @error Invalid Handle, invalid type.
* @noreturn
*/
native void DHookGetReturnString(Handle hReturn, char[] buffer, int size);
/* Set return value (Only use for: int, entity, bool or float return types)
*
* @param hReturn Handle to return structure
* @param value Value to set return as
*
* @error Invalid Handle, invalid type.
* @noreturn
*/
native void DHookSetReturn(Handle hReturn, any value);
/* Set return vector value
*
* @param hReturn Handle to return structure
* @param vec Value to set return vector as
*
* @error Invalid Handle, invalid type.
* @noreturn
*/
native void DHookSetReturnVector(Handle hReturn, float vec[3]);
/* Set return string value
*
* @param hReturn Handle to return structure
* @param value Value to set return string as
*
* @error Invalid Handle, invalid type.
* @noreturn
*/
native void DHookSetReturnString(Handle hReturn, char[] value);
//WE SHOULD WRAP THESE AROUND STOCKS FOR NON PTR AS WE SUPPORT BOTH WITH THESE NATIVE'S
/* Gets an objects variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @return Value of the objects var. If EHANDLE type or entity returns entity index.
*/
native any DHookGetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type);
/* Sets an objects variable value
*
* @param hParams Handle to params structure
* @param num Param number to set.
* @param offset Offset within the object to the var to set.
* @param type Type of var it is
* @param value The value to set the var to.
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn
*/
native void DHookSetParamObjectPtrVar(Handle hParams, int num, int offset, ObjectValueType type, any value);
/* Gets an objects vector variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
* @param buffer Buffer to store the result vector
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn
*/
native void DHookGetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float buffer[3]);
/* Sets an objects vector variable value
*
* @param hParams Handle to params structure
* @param num Param number to set.
* @param offset Offset within the object to the var to set.
* @param type Type of var it is
* @param value The value to set the vector var to.
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn
*/
native void DHookSetParamObjectPtrVarVector(Handle hParams, int num, int offset, ObjectValueType type, float value[3]);
/* Gets an objects string variable value
*
* @param hParams Handle to params structure
* @param num Param number to get.
* @param offset Offset within the object to the var to get.
* @param type Type of var it is
* @param buffer Buffer to store the result vector
* @param size Size of the buffer
*
* @error Invalid handle. Invalid param number. Invalid param type. Invalid Object type.
* @noreturn
*/
native void DHookGetParamObjectPtrString(Handle hParams, int num, int offset, ObjectValueType type, char[] buffer, int size);
/* Checks if a pointer param is null
*
* @param hParams Handle to params structure
* @param num Param number to check.
*
* @error Non pointer param
* @return True if null false otherwise.
*/
native bool DHookIsNullParam(Handle hParams, int num);
public Extension __ext_dhooks =
{
name = "dhooks",
file = "dhooks.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_dhooks_SetNTVOptional()
{
MarkNativeAsOptional("DHookAddEntityListener");
MarkNativeAsOptional("DHookRemoveEntityListener");
MarkNativeAsOptional("DHookCreate");
MarkNativeAsOptional("DHookCreateDetour");
MarkNativeAsOptional("DHookCreateFromConf");
MarkNativeAsOptional("DHookSetFromConf");
MarkNativeAsOptional("DHookEnableDetour");
MarkNativeAsOptional("DHookDisableDetour");
MarkNativeAsOptional("DHookAddParam");
MarkNativeAsOptional("DHookEntity");
MarkNativeAsOptional("DHookGamerules");
MarkNativeAsOptional("DHookRaw");
MarkNativeAsOptional("DHookRemoveHookID");
MarkNativeAsOptional("DHookGetParam");
MarkNativeAsOptional("DHookGetParamVector");
MarkNativeAsOptional("DHookGetParamString");
MarkNativeAsOptional("DHookSetParam");
MarkNativeAsOptional("DHookSetParamVector");
MarkNativeAsOptional("DHookSetParamString");
MarkNativeAsOptional("DHookGetReturn");
MarkNativeAsOptional("DHookGetReturnVector");
MarkNativeAsOptional("DHookGetReturnString");
MarkNativeAsOptional("DHookSetReturn");
MarkNativeAsOptional("DHookSetReturnVector");
MarkNativeAsOptional("DHookSetReturnString");
MarkNativeAsOptional("DHookGetParamObjectPtrVar");
MarkNativeAsOptional("DHookSetParamObjectPtrVar");
MarkNativeAsOptional("DHookGetParamObjectPtrVarVector");
MarkNativeAsOptional("DHookSetParamObjectPtrVarVector");
MarkNativeAsOptional("DHookIsNullParam");
MarkNativeAsOptional("DHookGetParamObjectPtrString");
}
#endif
+26
View File
@@ -0,0 +1,26 @@
#if defined _hooksoundmsg_ext_included
#endinput
#endif
#define _hooksoundmsg_ext_included
forward Action OnSoundEmittingToClient(int client, int origin[3], int& volume, float& delay, int& seq, int& entity, int& channel, int& pitch, int& flags, int& soundnum, int& soundnum_handle, int& speaker_entity, int& sound_level, bool is_sentence, bool is_ambient);
/**
* Do not edit below this line!
*/
public Extension __ext_hooksoundmsg =
{
name = "hooksoundmsg",
file = "hooksoundmsg.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
+201
View File
@@ -0,0 +1,201 @@
#define LOGHELPER_VERSION 3
#include <sourcemod>
#include <sdktools>
new String:g_team_list[16][64];
// Call this on map start to cache team names in g_team_list
stock GetTeams(bool:insmod = false)
{
if (!insmod)
{
new max_teams_count = GetTeamCount();
for (new team_index = 0; (team_index < max_teams_count); team_index++)
{
decl String: team_name[64];
GetTeamName(team_index, team_name, sizeof(team_name));
if (strcmp(team_name, "") != 0)
{
g_team_list[team_index] = team_name;
}
}
}
else
{
// they really need to get their act together... GetTeamName() would be awesome since they can't even keep their team indexes consistent
decl String:mapname[64];
GetCurrentMap(mapname, sizeof(mapname));
if (strcmp(mapname, "ins_karam") == 0 || strcmp(mapname, "ins_baghdad") == 0)
{
g_team_list[1] = "Iraqi Insurgents";
g_team_list[2] = "U.S. Marines";
}
else
{
g_team_list[1] = "U.S. Marines";
g_team_list[2] = "Iraqi Insurgents";
}
g_team_list[0] = "Unassigned";
g_team_list[3] = "SPECTATOR";
}
}
stock LogPlayerEvent(client, const String:verb[], const String:event[], bool:display_location = false, const String:properties[] = "", iTeam=-1)
{
if (IsValidPlayer(client))
{
decl String:player_authid[32];
if (!GetClientAuthId(client, AuthId_Steam2, player_authid, sizeof(player_authid)))
{
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
}
if(iTeam == -1)
iTeam = GetClientTeam(client);
if (display_location)
{
decl Float:player_origin[3];
GetClientAbsOrigin(client, player_origin);
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\"%s (position \"%d %d %d\")", client, GetClientUserId(client), player_authid, g_team_list[iTeam], verb, event, properties, RoundFloat(player_origin[0]), RoundFloat(player_origin[1]), RoundFloat(player_origin[2]));
}
else
{
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\"%s", client, GetClientUserId(client), player_authid, g_team_list[iTeam], verb, event, properties);
}
}
}
stock LogPlyrPlyrEvent(client, victim, const String:verb[], const String:event[], bool:display_location = false, const String:properties[] = "")
{
if (IsValidPlayer(client) && IsValidPlayer(victim))
{
decl String:player_authid[32];
if (!GetClientAuthId(client, AuthId_Steam2, player_authid, sizeof(player_authid)))
{
strcopy(player_authid, sizeof(player_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}
if (display_location)
{
decl Float:player_origin[3];
GetClientAbsOrigin(client, player_origin);
decl Float:victim_origin[3];
GetClientAbsOrigin(victim, victim_origin);
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\" against \"%N<%d><%s><%s>\"%s (position \"%d %d %d\") (victim_position \"%d %d %d\")", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], properties, RoundFloat(player_origin[0]), RoundFloat(player_origin[1]), RoundFloat(player_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
}
else
{
LogToGame("\"%N<%d><%s><%s>\" %s \"%s\" against \"%N<%d><%s><%s>\"%s", client, GetClientUserId(client), player_authid, g_team_list[GetClientTeam(client)], verb, event, victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], properties);
}
}
}
stock LogKill(attacker, victim, const String:weapon[], bool:display_location = false, const String:properties[] = "")
{
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
{
decl String:attacker_authid[32];
if (!GetClientAuthId(attacker, AuthId_Steam2, attacker_authid, sizeof(attacker_authid)))
{
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}
if (display_location)
{
decl Float:attacker_origin[3];
GetClientAbsOrigin(attacker, attacker_origin);
decl Float:victim_origin[3];
GetClientAbsOrigin(victim, victim_origin);
LogToGame("\"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\"%s (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties, RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
}
else
{
LogToGame("\"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\"%s", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, properties);
}
}
}
// For Psychostats "KTRAJ" kill trajectory log lines
stock LogPSKillTraj(attacker, victim, const String:weapon[])
{
if (IsValidPlayer(attacker) && IsValidPlayer(victim))
{
decl String:attacker_authid[32];
if (!GetClientAuthId(attacker, AuthId_Steam2, attacker_authid, sizeof(attacker_authid)))
{
strcopy(attacker_authid, sizeof(attacker_authid), "UNKNOWN");
}
decl String:victim_authid[32];
if (!GetClientAuthId(victim, AuthId_Steam2, victim_authid, sizeof(victim_authid)))
{
strcopy(victim_authid, sizeof(victim_authid), "UNKNOWN");
}
decl Float:attacker_origin[3];
GetClientAbsOrigin(attacker, attacker_origin);
decl Float:victim_origin[3];
GetClientAbsOrigin(victim, victim_origin);
LogToGame("[KTRAJ] \"%N<%d><%s><%s>\" killed \"%N<%d><%s><%s>\" with \"%s\" (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", attacker, GetClientUserId(attacker), attacker_authid, g_team_list[GetClientTeam(attacker)], victim, GetClientUserId(victim), victim_authid, g_team_list[GetClientTeam(victim)], weapon, RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
}
}
// Verb should always be "triggered" for this.
stock LogTeamEvent(team, const String:verb[], const String:event[], const String:properties[] = "")
{
if (team > -1)
{
LogToGame("Team \"%s\" %s \"%s\"%s", g_team_list[team], verb, event, properties);
}
}
stock LogKillLoc(attacker, victim)
{
if (attacker > 0 && victim > 0)
{
decl Float:attacker_origin[3];
GetClientAbsOrigin(attacker, attacker_origin);
decl Float:victim_origin[3];
GetClientAbsOrigin(victim, victim_origin);
LogToGame("World triggered \"killlocation\" (attacker_position \"%d %d %d\") (victim_position \"%d %d %d\")", RoundFloat(attacker_origin[0]), RoundFloat(attacker_origin[1]), RoundFloat(attacker_origin[2]), RoundFloat(victim_origin[0]), RoundFloat(victim_origin[1]), RoundFloat(victim_origin[2]));
}
}
stock LogRoleChange(client, const String:role[], const String:properties[] = "")
{
LogPlayerEvent( client, "changed role to", role, false, properties );
}
stock LogMapLoad()
{
decl String:map[64];
GetCurrentMap(map, sizeof(map));
LogToGame("Loading map \"%s\"", map);
}
stock IsValidPlayer(client)
{
if (client > 0 && client <= MaxClients && IsClientInGame(client))
{
return true;
}
return false;
}
+52
View File
@@ -0,0 +1,52 @@
#if defined _mapmusic_interface
#endinput
#endif
#define _mapmusic_interface
native float MapMusicInterface_GetSoundVolume(int client);
native float MapMusicInterface_GetMusicVolume(int client);
native void MapMusicInterface_SetSoundVolume(int client, float volume);
native void MapMusicInterface_SetMusicVolume(int client, float volume);
native bool MapMusicInterface_IsDisabled(int client);
native void MapMusicInterface_SetDisabled(int client, bool disabled);
native bool MapMusicInterface_GetBlockAll();
native void MapMusicInterface_SetBlockAll(bool block);
native bool MapMusicInterface_HasExceedingLengthSound(float searchlength = 0.0);
forward Action MapMusicInterface_OnStartSound(const char[] sample, float length, bool& isMusic, int& volume);
/* DO NOT EDIT BELOW THIS LINE */
public SharedPlugin __pl_mapmusic_interface =
{
name = "mapmusic_interface",
file = "mapmusic_interface.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public void __pl_mapmusic_interface_SetNTVOptional()
{
MarkNativeAsOptional("MapMusicInterface_GetSoundVolume");
MarkNativeAsOptional("MapMusicInterface_GetMusicVolume");
MarkNativeAsOptional("MapMusicInterface_SetSoundVolume");
MarkNativeAsOptional("MapMusicInterface_SetMusicVolume");
MarkNativeAsOptional("MapMusicInterface_IsDisabled");
MarkNativeAsOptional("MapMusicInterface_SetDisabled");
MarkNativeAsOptional("MapMusicInterface_GetBlockAll");
MarkNativeAsOptional("MapMusicInterface_SetBlockAll");
MarkNativeAsOptional("MapMusicInterface_HasExceedingLengthSound");
}
#endif
+454
View File
@@ -0,0 +1,454 @@
#if defined _multicolors_included
#endinput
#endif
#define _multicolors_included
#define MuCo_VERSION "2.1.2"
#include <multicolors/morecolors>
#include <multicolors/colors>
/*
*
* Credits:
* - Popoklopsi
* - Powerlord
* - exvel
* - Dr. McKay
*
* Based on stamm-colors
* - https://github.com/popoklopsi/Stamm/blob/master/include/stamm/stamm-colors.inc
*
*/
#define PREFIX_MAX_LENGTH 64
#define PREFIX_SEPARATOR "{default} "
/* Global var to check whether colors are fixed or not */
static bool g_bCFixColors;
static char g_sCPrefix[PREFIX_MAX_LENGTH];
/**
* Add a chat prefix before all chat msg
*
* @param sPrefix Prefix
*/
stock void CSetPrefix(const char[] sPrefix, any ...) {
if (!sPrefix[0]) {
return;
}
VFormat(g_sCPrefix, sizeof(g_sCPrefix) - strlen(PREFIX_SEPARATOR), sPrefix, 2);
// Add ending space
Format(g_sCPrefix, sizeof(g_sCPrefix), "%s%s", g_sCPrefix, PREFIX_SEPARATOR);
}
/**
* Add a chat prefix before all chat msg
*
* @param sPrefix Prefix
*/
stock void CClearPrefix() {
g_sCPrefix[0] = '\0';
}
/**
* Writes a message to a client with the correct stock for the game.
*
* @param client Client index.
* @param message Message (formatting rules).
*
* @error If the client is not connected an error will be thrown.
*/
stock void CPrintToChat(int client, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules)
*/
stock void CPrintToChatAll(const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client))
{
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 2);
if (!IsSource2009()) {
C_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChat(client, "%s%s", g_sCPrefix, buffer);
}
}
}
}
/**
* Writes a message to all of a client's observers.
*
* @param target Client index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatObservers(int target, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client) && !IsPlayerAlive(client) && !IsFakeClient(client)) {
int observee = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
int ObserverMode = GetEntProp(client, Prop_Send, "m_iObserverMode");
if (observee == target && (ObserverMode == 4 || ObserverMode == 5)) {
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
CPrintToChat(client, buffer);
}
}
}
}
/**
* Writes a message to a client with the correct stock for the game.
*
* @param client Client index.
* @param author Author index.
* @param message Message (formatting rules).
*
* @error If the client is not connected an error will be thrown.
*/
stock void CPrintToChatEx(int client, int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Writes a message to all clients with the correct stock for the game.
*
* @param author Author index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatAllEx(int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client))
{
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 2);
if (!IsSource2009()) {
C_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_PrintToChatEx(client, author, "%s%s", g_sCPrefix, buffer);
}
}
}
}
/**
* Writes a message to all of a client's observers with the correct
* game stock.
*
* @param target Client index.
* @param message Message (formatting rules).
*/
stock void CPrintToChatObserversEx(int target, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
if (!g_bCFixColors) {
CFixColors();
}
for (int client = 1; client <= MaxClients; client++) {
if (IsClientInGame(client) && !IsPlayerAlive(client) && !IsFakeClient(client)) {
int observee = GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
int ObserverMode = GetEntProp(client, Prop_Send, "m_iObserverMode");
if (observee == target && (ObserverMode == 4 || ObserverMode == 5)) {
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
CPrintToChatEx(client, target, buffer);
}
}
}
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param message Message (formatting rules)
*/
stock void CReplyToCommand(int client, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ReplyToCommand(client, "%s%s", g_sCPrefix, buffer);
}
else {
MC_ReplyToCommand(client, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param author Client to use for {teamcolor}
* @param message Message (formatting rules)
*/
stock void CReplyToCommandEx(int client, int author, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ReplyToCommandEx(client, author, "%s%s", g_sCPrefix, buffer);
}
else {
MC_ReplyToCommandEx(client, author, "%s%s", g_sCPrefix, buffer);
}
}
/**
* Remove all tags and print to server
*
* @param message Message (formatting rules)
*/
stock void CPrintToServer(const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
char prefixBuffer[PREFIX_MAX_LENGTH];
SetGlobalTransTarget(LANG_SERVER);
VFormat(buffer, sizeof(buffer), message, 2);
strcopy(prefixBuffer, sizeof(prefixBuffer), g_sCPrefix);
if (!g_bCFixColors) {
CFixColors();
}
CRemoveTags(buffer, sizeof(buffer));
CRemoveTags(prefixBuffer, sizeof(prefixBuffer));
PrintToServer("%s%s", prefixBuffer, buffer);
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* CShowActivity2() is slightly more useful.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivity(int client, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivity(client, "%s", buffer);
}
else {
MC_ShowActivity(client, "%s", buffer);
}
}
/**
* Same as C_ShowActivity(), except the tag parameter is used instead of "[SM] " (note that you must supply any spacing).
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to display with.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivityEx(int client, const char[] tag, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivityEx(client, tag, "%s", buffer);
}
else {
MC_ShowActivityEx(client, tag, "%s", buffer);
}
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
*
* @error
*/
stock void CShowActivity2(int client, const char[] tag, const char[] message, any ...) {
char buffer[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
C_ShowActivity2(client, tag, "%s", buffer);
}
else {
MC_ShowActivity2(client, tag, "%s", buffer);
}
}
/**
* Replaces color tags in a string with color codes
*
* @param message String.
* @param maxlength Maximum length of the string buffer.
*/
stock void CFormatColor(char[] message, int maxlength, int author = -1, bool csgofix = true) {
if (!g_bCFixColors) {
CFixColors();
}
if (!IsSource2009()) {
if (author == 0) {
author = -1;
}
C_Format(message, maxlength, author, csgofix);
}
else {
if (author == -1) {
author = 0;
}
MC_ReplaceColorCodes(message, author, false, maxlength);
}
}
/**
* Removes color tags from a message
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
*/
stock void CRemoveTags(char[] message, int maxlen) {
if (!IsSource2009()) {
C_RemoveTags(message, maxlen);
}
else {
MC_RemoveTags(message, maxlen);
}
}
/**
* Fixes missing Lightgreen color.
*/
stock void CFixColors() {
g_bCFixColors = true;
// Replace lightgreen if not exists
if (!C_ColorAllowed(Color_Lightgreen)) {
if (C_ColorAllowed(Color_Lime)) {
C_ReplaceColor(Color_Lightgreen, Color_Lime);
}
else if (C_ColorAllowed(Color_Olive)) {
C_ReplaceColor(Color_Lightgreen, Color_Olive);
}
}
}
stock bool IsSource2009() {
return (GetEngineVersion() == Engine_CSS
|| GetEngineVersion() == Engine_HL2DM
|| GetEngineVersion() == Engine_DODS
|| GetEngineVersion() == Engine_TF2
|| GetEngineVersion() == Engine_SDK2013);
}
+923
View File
@@ -0,0 +1,923 @@
/**************************************************************************
* *
* Colored Chat Functions *
* Author: exvel, Editor: Popoklopsi, Powerlord, Bara *
* Version: 2.0.0-MC *
* *
**************************************************************************/
#if defined _colors_included
#endinput
#endif
#define _colors_included
#define MAX_MESSAGE_LENGTH 250
#define MAX_COLORS 19
#define SERVER_INDEX 0
#define NO_INDEX -1
#define NO_PLAYER -2
#define CSGO_TEAM_T 2
#define CSGO_TEAM_CT 3
#define CSGO_TAG_T "{t}"
#define CSGO_TAG_CT "{ct}"
enum C_Colors {
Color_Default = 0,
Color_Darkred,
Color_Green,
Color_Lightgreen,
Color_Red,
Color_Blue,
Color_Olive,
Color_Lime,
Color_Lightred,
Color_Purple,
Color_Grey,
Color_Yellow,
Color_Orange,
Color_Bluegrey,
Color_Lightblue,
Color_Darkblue,
Color_Grey2,
Color_Orchid,
Color_Lightred2
}
/* C_Colors' properties */
char C_Tag[][] = {"{default}", "{darkred}", "{green}", "{lightgreen}", "{red}", "{blue}", "{olive}", "{lime}", "{lightred}", "{purple}", "{grey}", "{yellow}", "{orange}", "{bluegrey}", "{lightblue}", "{darkblue}", "{grey2}", "{orchid}", "{lightred2}"};
char C_TagCode[][] = {"\x01", "\x02", "\x04", "\x03", "\x03", "\x03", "\x05", "\x06", "\x07", "\x03", "\x08", "\x09", "\x10", "\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F"};
bool C_TagReqSayText2[] = {false, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false};
bool C_EventIsHooked;
bool C_SkipList[MAXPLAYERS+1];
/* Game default profile */
bool C_Profile_Colors[] = {true, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
int C_Profile_TeamIndex[] = {NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX};
bool C_Profile_SayText2;
static ConVar sm_show_activity;
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock void C_PrintToChat(int client, const char[] szMessage, any ...) {
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
if (!IsClientInGame(client)) {
ThrowError("Client %d is not in game", client);
}
char szBuffer[MAX_MESSAGE_LENGTH];
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 3);
int index = C_Format(szCMessage, sizeof(szCMessage));
if (index == NO_INDEX) {
PrintToChat(client, "%s", szCMessage);
}
else {
C_SayText2(client, index, szCMessage);
}
}
/**
* Reples to a message in a command. A client index of 0 will use PrintToServer().
* If the command was from the console, PrintToConsole() is used. If the command was from chat, C_PrintToChat() is used.
* Supports color tags.
*
* @param client Client index, or 0 for server.
* @param szMessage Formatting rules.
* @param ... Variable number of format parameters.
* @return No return
*
* On error/Errors: If the client is not connected or invalid.
*/
stock void C_ReplyToCommand(int client, const char[] szMessage, any ...) {
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(szCMessage, sizeof(szCMessage), szMessage, 3);
if (client == 0) {
C_RemoveTags(szCMessage, sizeof(szCMessage));
PrintToServer("%s", szCMessage);
}
else if (GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
C_RemoveTags(szCMessage, sizeof(szCMessage));
PrintToConsole(client, "%s", szCMessage);
}
else {
C_PrintToChat(client, "%s", szCMessage);
}
}
/**
* Reples to a message in a command. A client index of 0 will use PrintToServer().
* If the command was from the console, PrintToConsole() is used. If the command was from chat, C_PrintToChat() is used.
* Supports color tags.
*
* @param client Client index, or 0 for server.
* @param author Author index whose color will be used for teamcolor tag.
* @param szMessage Formatting rules.
* @param ... Variable number of format parameters.
* @return No return
*
* On error/Errors: If the client is not connected or invalid.
*/
stock void C_ReplyToCommandEx(int client, int author, const char[] szMessage, any ...) {
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
VFormat(szCMessage, sizeof(szCMessage), szMessage, 4);
if (client == 0) {
C_RemoveTags(szCMessage, sizeof(szCMessage));
PrintToServer("%s", szCMessage);
}
else if (GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
C_RemoveTags(szCMessage, sizeof(szCMessage));
PrintToConsole(client, "%s", szCMessage);
}
else {
C_PrintToChatEx(client, author, "%s", szCMessage);
}
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param szMessage Message (formatting rules)
* @return No return
*/
stock void C_PrintToChatAll(const char[] szMessage, any ...) {
char szBuffer[MAX_MESSAGE_LENGTH];
for (int i = 1; i <= MaxClients; ++i) {
if (IsClientInGame(i) && !IsFakeClient(i) && !C_SkipList[i]) {
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 2);
C_PrintToChat(i, "%s", szBuffer);
}
C_SkipList[i] = false;
}
}
/**
* Prints a message to a specific client in the chat area.
* Supports color tags and teamcolor tag.
*
* @param client Client index.
* @param author Author index whose color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the client or author are not connected an error will be thrown.
*/
stock void C_PrintToChatEx(int client, int author, const char[] szMessage, any ...) {
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
if (!IsClientInGame(client)) {
ThrowError("Client %d is not in game", client);
}
if (author < 0 || author > MaxClients) {
ThrowError("Invalid client index %d", author);
}
char szBuffer[MAX_MESSAGE_LENGTH];
char szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 4);
int index = C_Format(szCMessage, sizeof(szCMessage), author);
if (index == NO_INDEX) {
PrintToChat(client, "%s", szCMessage);
}
else {
C_SayText2(client, author, szCMessage);
}
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags and teamcolor tag.
*
* @param author Author index whos color will be used for teamcolor tag.
* @param szMessage Message (formatting rules).
* @return No return
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock void C_PrintToChatAllEx(int author, const char[] szMessage, any ...) {
if (author < 0 || author > MaxClients) {
ThrowError("Invalid client index %d", author);
}
if (!IsClientInGame(author)) {
ThrowError("Client %d is not in game", author);
}
char szBuffer[MAX_MESSAGE_LENGTH];
for (int i = 1; i <= MaxClients; ++i) {
if (IsClientInGame(i) && !IsFakeClient(i) && !C_SkipList[i]) {
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 3);
C_PrintToChatEx(i, author, "%s", szBuffer);
}
C_SkipList[i] = false;
}
}
/**
* Removes color tags from the string.
*
* @param szMessage String.
* @return No return
*/
stock void C_RemoveTags(char[] szMessage, int maxlength) {
for (int i = 0; i < MAX_COLORS; i++) {
ReplaceString(szMessage, maxlength, C_Tag[i], "", false);
}
ReplaceString(szMessage, maxlength, "{teamcolor}", "", false);
}
/**
* Checks whether a color is allowed or not
*
* @param tag Color Tag.
* @return True when color is supported, otherwise false
*/
stock bool C_ColorAllowed(C_Colors color) {
if (!C_EventIsHooked) {
C_SetupProfile();
C_EventIsHooked = true;
}
return C_Profile_Colors[color];
}
/**
* Replace the color with another color
* Handle with care!
*
* @param color color to replace.
* @param newColor color to replace with.
* @noreturn
*/
stock void C_ReplaceColor(C_Colors color, C_Colors newColor) {
if (!C_EventIsHooked) {
C_SetupProfile();
C_EventIsHooked = true;
}
C_Profile_Colors[color] = C_Profile_Colors[newColor];
C_Profile_TeamIndex[color] = C_Profile_TeamIndex[newColor];
C_TagReqSayText2[color] = C_TagReqSayText2[newColor];
Format(C_TagCode[color], sizeof(C_TagCode[]), C_TagCode[newColor]);
}
/**
* This function should only be used right in front of
* C_PrintToChatAll or C_PrintToChatAllEx and it tells
* to those funcions to skip specified client when printing
* message to all clients. After message is printed client will
* no more be skipped.
*
* @param client Client index
* @return No return
*/
stock void C_SkipNextClient(int client) {
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
C_SkipList[client] = true;
}
/**
* Replaces color tags in a string with color codes
*
* @param szMessage String.
* @param maxlength Maximum length of the string buffer.
* @return Client index that can be used for SayText2 author index
*
* On error/Errors: If there is more then one team color is used an error will be thrown.
*/
stock int C_Format(char[] szMessage, int maxlength, int author = NO_INDEX, bool csgofix = true) {
/* Hook event for auto profile setup on map start */
if (!C_EventIsHooked) {
C_SetupProfile();
HookEvent("server_spawn", C_Event_MapStart, EventHookMode_PostNoCopy);
C_EventIsHooked = true;
}
int iRandomPlayer = NO_INDEX;
EngineVersion engine = GetEngineVersion();
// On CS:GO set invisible precolor
if (csgofix && engine == Engine_CSGO) {
Format(szMessage, maxlength, " %s", szMessage);
}
/* If author was specified replace {teamcolor} tag */
if (author != NO_INDEX) {
if (C_Profile_SayText2) {
ReplaceString(szMessage, maxlength, "{teamcolor}", "\x03", false);
iRandomPlayer = author;
}
/* If saytext2 is not supported by game replace {teamcolor} with green tag */
else {
ReplaceString(szMessage, maxlength, "{teamcolor}", C_TagCode[Color_Green], false);
}
}
else {
ReplaceString(szMessage, maxlength, "{teamcolor}", "", false);
}
/* For other color tags we need a loop */
for (int i = 0; i < MAX_COLORS; i++) {
int iTagStatus = -1;
if (StrContains(szMessage, C_Tag[i], false) != -1) {
iTagStatus = 0;
}
/* On CS:GO {red} and {blue} name is so strange for team colors. */
if (engine == Engine_CSGO) {
if ((C_Profile_TeamIndex[i] == CSGO_TEAM_T && StrContains(szMessage, CSGO_TAG_T, false) != -1) ||
(C_Profile_TeamIndex[i] == CSGO_TEAM_CT && StrContains(szMessage, CSGO_TAG_CT, false) != -1)) {
iTagStatus = 1;
}
}
/* If tag not found - skip */
if (iTagStatus == -1) {
continue;
}
/* If tag is not supported by game replace it with green tag */
else if (!C_Profile_Colors[i]) {
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
}
/* If tag doesn't need saytext2 simply replace */
else if (!C_TagReqSayText2[i]) {
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[i], false);
}
/* Tag needs saytext2 */
else {
/* If saytext2 is not supported by game replace tag with green tag */
if (!C_Profile_SayText2) {
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
}
/* Game supports saytext2 */
else {
/* If random player for tag wasn't specified replace tag and find player */
if (iRandomPlayer == NO_INDEX) {
/* Searching for valid client for tag */
iRandomPlayer = C_FindRandomPlayerByTeam(C_Profile_TeamIndex[i]);
/* If player not found replace tag with green color tag */
if (iRandomPlayer == NO_PLAYER) {
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[Color_Green], false);
if (iTagStatus == 1)
ReplaceString(szMessage, maxlength, C_Profile_TeamIndex[i] == CSGO_TEAM_T ? CSGO_TAG_T : CSGO_TAG_CT, C_TagCode[Color_Green], false);
}
/* If player was found simply replace */
else {
ReplaceString(szMessage, maxlength, C_Tag[i], C_TagCode[i], false);
if (iTagStatus == 1)
ReplaceString(szMessage, maxlength, C_Profile_TeamIndex[i] == CSGO_TEAM_T ? CSGO_TAG_T : CSGO_TAG_CT, C_TagCode[i], false);
}
}
/* If found another team color tag throw error */
else {
//ReplaceString(szMessage, maxlength, C_Tag[i], "");
ThrowError("Using two team colors in one message is not allowed");
}
}
}
}
return iRandomPlayer;
}
/**
* Finds a random player with specified team
*
* @param color_team Client team.
* @return Client index or NO_PLAYER if no player found
*/
stock int C_FindRandomPlayerByTeam(int color_team) {
if (color_team == SERVER_INDEX) {
return 0;
}
int[] players = new int[MaxClients];
int num;
for (int i = 1; i <= MaxClients; ++i) {
if (IsClientInGame(i) && GetClientTeam(i) == color_team) {
players[num++] = i;
}
}
if (num) {
return players[GetRandomInt(0, num-1)];
}
return NO_PLAYER;
}
/**
* Sends a SayText2 usermessage to a client
*
* @param szMessage Client index
* @param maxlength Author index
* @param szMessage Message
* @return No return.
*/
stock void C_SayText2(int client, int author, const char[] szMessage) {
Handle hBuffer = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) {
Protobuf pb = UserMessageToProtobuf(hBuffer);
pb.SetInt("ent_idx", author);
pb.SetBool("chat", true);
pb.SetString("msg_name", szMessage);
pb.AddString("params", "");
pb.AddString("params", "");
pb.AddString("params", "");
pb.AddString("params", "");
}
else {
BfWrite bf = UserMessageToBfWrite(hBuffer);
bf.WriteByte(author);
bf.WriteByte(true);
bf.WriteString(szMessage);
}
EndMessage();
}
/**
* Creates game color profile
* This function must be edited if you want to add more games support
*
* @return No return.
*/
stock void C_SetupProfile() {
EngineVersion engine = GetEngineVersion();
if (engine == Engine_CSS) {
C_Profile_Colors[Color_Lightgreen] = true;
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
C_Profile_TeamIndex[Color_Red] = 2;
C_Profile_TeamIndex[Color_Blue] = 3;
C_Profile_SayText2 = true;
}
else if (engine == Engine_CSGO) {
C_Profile_Colors[Color_Red] = true; // \x03 (T Color via SayText2)
C_Profile_Colors[Color_Blue] = true; // \x03 (CT Color via SayText2)
// Color_Default // \x01
C_Profile_Colors[Color_Darkred] = true; // \x02
C_Profile_Colors[Color_Purple] = true; // \x03
// Color_Green // \x04
C_Profile_Colors[Color_Olive] = true; // \x05
C_Profile_Colors[Color_Lime] = true; // \x06
C_Profile_Colors[Color_Lightred] = true; // \x07
C_Profile_Colors[Color_Grey] = true; // \x08
C_Profile_Colors[Color_Yellow] = true; // \x09
C_Profile_Colors[Color_Bluegrey] = true; // \x0A
C_Profile_Colors[Color_Lightblue] = true; // \x0B
C_Profile_Colors[Color_Darkblue] = true; // \x0C
C_Profile_Colors[Color_Grey2] = true; // \x0D
C_Profile_Colors[Color_Orchid] = true; // \x0E
C_Profile_Colors[Color_Lightred2] = true; // \x0F
C_Profile_Colors[Color_Orange] = true; // \x10
C_Profile_TeamIndex[Color_Red] = 2;
C_Profile_TeamIndex[Color_Blue] = 3;
C_Profile_SayText2 = true;
}
else if (engine == Engine_TF2) {
C_Profile_Colors[Color_Lightgreen] = true;
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
C_Profile_TeamIndex[Color_Red] = 2;
C_Profile_TeamIndex[Color_Blue] = 3;
C_Profile_SayText2 = true;
}
else if (engine == Engine_Left4Dead || engine == Engine_Left4Dead2) {
C_Profile_Colors[Color_Lightgreen] = true;
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
C_Profile_TeamIndex[Color_Red] = 3;
C_Profile_TeamIndex[Color_Blue] = 2;
C_Profile_SayText2 = true;
}
else if (engine == Engine_HL2DM) {
/* hl2mp profile is based on mp_teamplay convar */
if (GetConVarBool(FindConVar("mp_teamplay"))) {
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_Colors[Color_Olive] = true;
C_Profile_TeamIndex[Color_Red] = 3;
C_Profile_TeamIndex[Color_Blue] = 2;
C_Profile_SayText2 = true;
}
else {
C_Profile_SayText2 = false;
C_Profile_Colors[Color_Olive] = true;
}
}
else if (engine == Engine_DODS) {
C_Profile_Colors[Color_Olive] = true;
C_Profile_SayText2 = false;
}
/* Profile for other games */
else {
if (GetUserMessageId("SayText2") == INVALID_MESSAGE_ID) {
C_Profile_SayText2 = false;
}
else {
C_Profile_Colors[Color_Red] = true;
C_Profile_Colors[Color_Blue] = true;
C_Profile_TeamIndex[Color_Red] = 2;
C_Profile_TeamIndex[Color_Blue] = 3;
C_Profile_SayText2 = true;
}
}
}
public Action C_Event_MapStart(Event event, const char[] name, bool dontBroadcast) {
C_SetupProfile();
for (int i = 1; i <= MaxClients; ++i) {
C_SkipList[i] = false;
}
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* C_ShowActivity2() is slightly more useful.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn
* @error
*/
stock int C_ShowActivity(int client, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char tag[] = "[SM] ";
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client)) {
ThrowError("Client index %d is invalid", client);
}
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE) {
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
}
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || (display_in_chat && i == client)) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID || !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = GetAdminFlag(id, Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Same as C_ShowActivity(), except the tag parameter is used instead of "[SM] " (note that you must supply any spacing).
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to display with.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn
* @error
*/
stock int C_ShowActivityEx(int client, const char[] tag, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client)) {
ThrowError("Client index %d is invalid", client);
}
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE) {
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
}
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || (display_in_chat && i == client)) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID || !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = GetAdminFlag(id, Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @noreturn
* @error
*/
stock int C_ShowActivity2(int client, const char[] tag, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char szBuffer[MAX_MESSAGE_LENGTH];
//char szCMessage[MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
// ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client)) {
ThrowError("Client index %d is invalid", client);
}
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
* twice.
*/
C_PrintToChatEx(client, client, "%s%s", tag, szBuffer);
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || i == client) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID
|| !GetAdminFlag(id, Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = GetAdminFlag(id, Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
C_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
+992
View File
@@ -0,0 +1,992 @@
// MOAR COLORS
// By Dr. McKay
// Inspired by: https://forums.alliedmods.net/showthread.php?t=96831
#if defined _more_colors_included
#endinput
#endif
#define _more_colors_included
#pragma newdecls optional
#include <regex>
#define MORE_COLORS_VERSION "2.0.0-MC"
#define MC_MAX_MESSAGE_LENGTH 256
#define MAX_BUFFER_LENGTH (MC_MAX_MESSAGE_LENGTH * 4)
#define MCOLOR_RED 0xFF4040
#define MCOLOR_BLUE 0x99CCFF
#define MCOLOR_GRAY 0xCCCCCC
#define MCOLOR_GREEN 0x3EFF3E
#define MC_GAME_DODS 0
bool MC_SkipList[MAXPLAYERS+1];
StringMap MC_Trie;
int MC_TeamColors[][] = {{0xCCCCCC, 0x4D7942, 0xFF4040}}; // Multi-dimensional array for games that don't support SayText2. First index is the game index (as defined by the GAME_ defines), second index is team. 0 = spectator, 1 = team1, 2 = team2
static ConVar sm_show_activity;
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules).
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock void MC_PrintToChat(int client, const char[] message, any ...) {
MC_CheckTrie();
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
if (!IsClientInGame(client)) {
ThrowError("Client %i is not in game", client);
}
char buffer[MAX_BUFFER_LENGTH];
char buffer2[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 3);
MC_ReplaceColorCodes(buffer2);
MC_SendMessage(client, buffer2);
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules).
*/
stock void MC_PrintToChatAll(const char[] message, any ...) {
MC_CheckTrie();
char buffer[MAX_BUFFER_LENGTH], buffer2[MAX_BUFFER_LENGTH];
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || MC_SkipList[i]) {
MC_SkipList[i] = false;
continue;
}
SetGlobalTransTarget(i);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 2);
MC_ReplaceColorCodes(buffer2);
MC_SendMessage(i, buffer2);
}
}
/**
* Prints a message to a specific client in the chat area.
* Supports color tags and teamcolor tag.
*
* @param client Client index.
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
*
* On error/Errors: If the client or author are not connected an error will be thrown
*/
stock void MC_PrintToChatEx(int client, int author, const char[] message, any ...) {
MC_CheckTrie();
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
if (!IsClientInGame(client)) {
ThrowError("Client %i is not in game", client);
}
if (author <= 0 || author > MaxClients) {
ThrowError("Invalid client index %i", author);
}
if (!IsClientInGame(author)) {
ThrowError("Client %i is not in game", author);
}
char buffer[MAX_BUFFER_LENGTH], buffer2[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 4);
MC_ReplaceColorCodes(buffer2, author);
MC_SendMessage(client, buffer2, author);
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags and teamcolor tag.
*
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) {
MC_CheckTrie();
if (author <= 0 || author > MaxClients) {
ThrowError("Invalid client index %i", author);
}
if (!IsClientInGame(author)) {
ThrowError("Client %i is not in game", author);
}
char buffer[MAX_BUFFER_LENGTH];
char buffer2[MAX_BUFFER_LENGTH];
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || MC_SkipList[i]) {
MC_SkipList[i] = false;
continue;
}
SetGlobalTransTarget(i);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 3);
MC_ReplaceColorCodes(buffer2, author);
MC_SendMessage(i, buffer2, author);
}
}
/**
* Sends a SayText2 usermessage
*
* @param client Client to send usermessage to
* @param message Message to send
*/
stock void MC_SendMessage(int client, const char[] message, int author = 0) {
if (author == 0) {
author = client;
}
char buffer[MC_MAX_MESSAGE_LENGTH];
strcopy(buffer, sizeof(buffer), message);
UserMsg index = GetUserMessageId("SayText2");
if (index == INVALID_MESSAGE_ID) {
if (GetEngineVersion() == Engine_DODS) {
int team = GetClientTeam(author);
if (team == 0) {
ReplaceString(buffer, sizeof(buffer), "\x03", "\x04", false); // Unassigned gets green
}
else {
char temp[16];
Format(temp, sizeof(temp), "\x07%06X", MC_TeamColors[MC_GAME_DODS][team - 1]);
ReplaceString(buffer, sizeof(buffer), "\x03", temp, false);
}
}
PrintToChat(client, "%s", buffer);
return;
}
Handle buf = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) {
Protobuf pb = UserMessageToProtobuf(buf);
pb.SetInt("ent_idx", author);
pb.SetBool("chat", true);
pb.SetString("msg_name", buffer);
pb.AddString("params", "");
pb.AddString("params", "");
pb.AddString("params", "");
pb.AddString("params", "");
}
else {
BfWrite bf = UserMessageToBfWrite(buf);
bf.WriteByte(author); // Message author
bf.WriteByte(true); // Chat message
bf.WriteString(buffer); // Message text
}
EndMessage();
}
/**
* This function should only be used right in front of
* MC_PrintToChatAll or MC_PrintToChatAllEx. It causes those functions
* to skip the specified client when printing the message.
* After printing the message, the client will no longer be skipped.
*
* @param client Client index
*/
stock void MC_SkipNextClient(int client) {
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
MC_SkipList[client] = true;
}
/**
* Checks if the colors trie is initialized and initializes it if it's not (used internally)
*
* @return No return
*/
stock void MC_CheckTrie() {
if (MC_Trie == null) {
MC_Trie = MC_InitColorTrie();
}
}
/**
* Replaces color tags in a string with color codes (used internally by MC_PrintToChat, MC_PrintToChatAll, MC_PrintToChatEx, and MC_PrintToChatAllEx
*
* @param buffer String.
* @param author Optional client index to use for {teamcolor} tags, or 0 for none
* @param removeTags Optional boolean value to determine whether we're replacing tags with colors, or just removing tags, used by MC_RemoveTags
* @param maxlen Optional value for max buffer length, used by MC_RemoveTags
*
* On error/Errors: If the client index passed for author is invalid or not in game.
*/
stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = false, int maxlen = MAX_BUFFER_LENGTH) {
MC_CheckTrie();
if (!removeTags) {
ReplaceString(buffer, maxlen, "{default}", "\x01", false);
}
else {
ReplaceString(buffer, maxlen, "{default}", "", false);
ReplaceString(buffer, maxlen, "{teamcolor}", "", false);
}
if (author != 0 && !removeTags) {
if (author < 0 || author > MaxClients) {
ThrowError("Invalid client index %i", author);
}
if (!IsClientInGame(author)) {
ThrowError("Client %i is not in game", author);
}
ReplaceString(buffer, maxlen, "{teamcolor}", "\x03", false);
}
int cursor = 0;
int value;
char tag[32], buff[32];
char[] output = new char[maxlen];
strcopy(output, maxlen, buffer);
// Since the string's size is going to be changing, output will hold the replaced string and we'll search buffer
Regex regex = new Regex("{[#a-zA-Z0-9]+}");
for (int i = 0; i < 1000; i++) { // The RegEx extension is quite flaky, so we have to loop here :/. This loop is supposed to be infinite and broken by return, but conditions have been added to be safe.
if (regex.Match(buffer[cursor]) < 1) {
delete regex;
strcopy(buffer, maxlen, output);
return;
}
regex.GetSubString(0, tag, sizeof(tag));
MC_StrToLower(tag);
cursor = StrContains(buffer[cursor], tag, false) + cursor + 1;
strcopy(buff, sizeof(buff), tag);
ReplaceString(buff, sizeof(buff), "{", "");
ReplaceString(buff, sizeof(buff), "}", "");
if (buff[0] == '#') {
if (strlen(buff) == 7) {
Format(buff, sizeof(buff), "\x07%s", buff[1]);
}
else if (strlen(buff) == 9) {
Format(buff, sizeof(buff), "\x08%s", buff[1]);
}
else {
continue;
}
if (removeTags) {
ReplaceString(output, maxlen, tag, "", false);
}
else {
ReplaceString(output, maxlen, tag, buff, false);
}
}
else if (!MC_Trie.GetValue(buff, value)) {
continue;
}
if (removeTags) {
ReplaceString(output, maxlen, tag, "", false);
}
else {
Format(buff, sizeof(buff), "\x07%06X", value);
ReplaceString(output, maxlen, tag, buff, false);
}
}
LogError("[MORE COLORS] Infinite loop broken.");
}
/**
* Gets a part of a string
*
* @param input String to get the part from
* @param output Buffer to write to
* @param maxlen Max length of output buffer
* @param start Position to start at
* @param numChars Number of characters to return, or 0 for the end of the string
*/
stock void CSubString(const char[] input, char[] output, int maxlen, int start, int numChars = 0) {
int i = 0;
for (;;) {
if (i == maxlen - 1 || i >= numChars || input[start + i] == '\0') {
output[i] = '\0';
return;
}
output[i] = input[start + i];
i++;
}
}
/**
* Converts a string to lowercase
*
* @param buffer String to convert
*/
stock void MC_StrToLower(char[] buffer) {
int len = strlen(buffer);
for (int i = 0; i < len; i++) {
buffer[i] = CharToLower(buffer[i]);
}
}
/**
* Adds a color to the colors trie
*
* @param name Color name, without braces
* @param color Hexadecimal representation of the color (0xRRGGBB)
* @return True if color was added successfully, false if a color already exists with that name
*/
stock bool MC_AddColor(const char[] name, int color) {
MC_CheckTrie();
int value;
if (MC_Trie.GetValue(name, value)) {
return false;
}
char newName[64];
strcopy(newName, sizeof(newName), name);
MC_StrToLower(newName);
MC_Trie.SetValue(newName, color);
return true;
}
/**
* Removes color tags from a message
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
*/
stock void MC_RemoveTags(char[] message, int maxlen) {
MC_ReplaceColorCodes(message, 0, true, maxlen);
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param message Message (formatting rules)
*/
stock void MC_ReplyToCommand(int client, const char[] message, any ...) {
char buffer[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if (client == 0) {
MC_RemoveTags(buffer, sizeof(buffer));
PrintToServer("%s", buffer);
}
if (GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
MC_RemoveTags(buffer, sizeof(buffer));
PrintToConsole(client, "%s", buffer);
}
else {
MC_PrintToChat(client, "%s", buffer);
}
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param author Client to use for {teamcolor}
* @param message Message (formatting rules)
*/
stock void MC_ReplyToCommandEx(int client, int author, const char[] message, any ...) {
char buffer[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if (client == 0) {
MC_RemoveTags(buffer, sizeof(buffer));
PrintToServer("%s", buffer);
}
if (GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
MC_RemoveTags(buffer, sizeof(buffer));
PrintToConsole(client, "%s", buffer);
}
else {
MC_PrintToChatEx(client, author, "%s", buffer);
}
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* MC_ShowActivity2() is slightly more useful.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error
*/
stock int MC_ShowActivity(int client, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char tag[] = "[SM] ";
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE) {
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
}
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || (display_in_chat && i == client)) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = id.HasFlag(Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Same as MC_ShowActivity(), except the tag parameter is used instead of "[SM] " (note that you must supply any spacing).
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to display with.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error
*/
stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client)) {
ThrowError("Client index %d is invalid", client);
}
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE) {
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
}
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || (display_in_chat && i == client)) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = id.HasFlag(Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root) || (i == client)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
* @param client Client index doing the action, or 0 for server.
* @param tags Tag to prepend to the message.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @error
*/
stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, any ...) {
if (sm_show_activity == null) {
sm_show_activity = FindConVar("sm_show_activity");
}
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = sm_show_activity.IntValue;
// ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
if (client != 0) {
if (client < 0 || client > MaxClients || !IsClientConnected(client)) {
ThrowError("Client index %d is invalid", client);
}
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
sign = "PLAYER";
}
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
* twice.
*/
MC_PrintToChatEx(client, client, "%s%s", tag, szBuffer);
}
else {
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value) {
return 1;
}
for (int i = 1; i <= MaxClients; ++i) {
if (!IsClientInGame(i) || IsFakeClient(i) || i == client) {
continue;
}
AdminId id = GetUserAdmin(i);
SetGlobalTransTarget(i);
if (id == INVALID_ADMIN_ID || !id.HasFlag(Admin_Generic, Access_Effective)) {
/* Treat this as a normal user. */
if ((value & 1) | (value & 2)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 2)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
else {
/* Treat this as an admin user */
bool is_root = id.HasFlag(Admin_Root, Access_Effective);
if ((value & 4) || (value & 8) || ((value & 16) && is_root)) {
char newsign[MAX_NAME_LENGTH];
if ((value & 8) || ((value & 16) && is_root)) {
newsign = name;
}
else {
newsign = sign;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Determines whether a color name exists
*
* @param color The color name to check
* @return True if the color exists, false otherwise
*/
stock bool CColorExists(const char[] color) {
MC_CheckTrie();
int temp;
return MC_Trie.GetValue(color, temp);
}
/**
* Returns the hexadecimal representation of a client's team color (will NOT initialize the trie)
*
* @param client Client to get the team color for
* @return Client's team color in hexadecimal, or green if unknown
* On error/Errors: If the client index passed is invalid or not in game.
*/
stock int CGetTeamColor(int client) {
if (client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
if (!IsClientInGame(client)) {
ThrowError("Client %i is not in game", client);
}
int value;
switch(GetClientTeam(client)) {
case 1: {
value = MCOLOR_GRAY;
}
case 2: {
value = MCOLOR_RED;
}
case 3: {
value = MCOLOR_BLUE;
}
default: {
value = MCOLOR_GREEN;
}
}
return value;
}
stock StringMap MC_InitColorTrie() {
StringMap hTrie = new StringMap();
hTrie.SetValue("aliceblue", 0xF0F8FF);
hTrie.SetValue("allies", 0x4D7942); // same as Allies team in DoD:S
hTrie.SetValue("ancient", 0xEB4B4B); // same as Ancient item rarity in Dota 2
hTrie.SetValue("antiquewhite", 0xFAEBD7);
hTrie.SetValue("aqua", 0x00FFFF);
hTrie.SetValue("aquamarine", 0x7FFFD4);
hTrie.SetValue("arcana", 0xADE55C); // same as Arcana item rarity in Dota 2
hTrie.SetValue("axis", 0xFF4040); // same as Axis team in DoD:S
hTrie.SetValue("azure", 0x007FFF);
hTrie.SetValue("beige", 0xF5F5DC);
hTrie.SetValue("bisque", 0xFFE4C4);
hTrie.SetValue("black", 0x000000);
hTrie.SetValue("blanchedalmond", 0xFFEBCD);
hTrie.SetValue("blue", 0x99CCFF); // same as BLU/Counter-Terrorist team color
hTrie.SetValue("blueviolet", 0x8A2BE2);
hTrie.SetValue("brown", 0xA52A2A);
hTrie.SetValue("burlywood", 0xDEB887);
hTrie.SetValue("cadetblue", 0x5F9EA0);
hTrie.SetValue("chartreuse", 0x7FFF00);
hTrie.SetValue("chocolate", 0xD2691E);
hTrie.SetValue("collectors", 0xAA0000); // same as Collector's item quality in TF2
hTrie.SetValue("common", 0xB0C3D9); // same as Common item rarity in Dota 2
hTrie.SetValue("community", 0x70B04A); // same as Community item quality in TF2
hTrie.SetValue("coral", 0xFF7F50);
hTrie.SetValue("cornflowerblue", 0x6495ED);
hTrie.SetValue("cornsilk", 0xFFF8DC);
hTrie.SetValue("corrupted", 0xA32C2E); // same as Corrupted item quality in Dota 2
hTrie.SetValue("crimson", 0xDC143C);
hTrie.SetValue("cyan", 0x00FFFF);
hTrie.SetValue("darkblue", 0x00008B);
hTrie.SetValue("darkcyan", 0x008B8B);
hTrie.SetValue("darkgoldenrod", 0xB8860B);
hTrie.SetValue("darkgray", 0xA9A9A9);
hTrie.SetValue("darkgrey", 0xA9A9A9);
hTrie.SetValue("darkgreen", 0x006400);
hTrie.SetValue("darkkhaki", 0xBDB76B);
hTrie.SetValue("darkmagenta", 0x8B008B);
hTrie.SetValue("darkolivegreen", 0x556B2F);
hTrie.SetValue("darkorange", 0xFF8C00);
hTrie.SetValue("darkorchid", 0x9932CC);
hTrie.SetValue("darkred", 0x8B0000);
hTrie.SetValue("darksalmon", 0xE9967A);
hTrie.SetValue("darkseagreen", 0x8FBC8F);
hTrie.SetValue("darkslateblue", 0x483D8B);
hTrie.SetValue("darkslategray", 0x2F4F4F);
hTrie.SetValue("darkslategrey", 0x2F4F4F);
hTrie.SetValue("darkturquoise", 0x00CED1);
hTrie.SetValue("darkviolet", 0x9400D3);
hTrie.SetValue("deeppink", 0xFF1493);
hTrie.SetValue("deepskyblue", 0x00BFFF);
hTrie.SetValue("dimgray", 0x696969);
hTrie.SetValue("dimgrey", 0x696969);
hTrie.SetValue("dodgerblue", 0x1E90FF);
hTrie.SetValue("exalted", 0xCCCCCD); // same as Exalted item quality in Dota 2
hTrie.SetValue("firebrick", 0xB22222);
hTrie.SetValue("floralwhite", 0xFFFAF0);
hTrie.SetValue("forestgreen", 0x228B22);
hTrie.SetValue("frozen", 0x4983B3); // same as Frozen item quality in Dota 2
hTrie.SetValue("fuchsia", 0xFF00FF);
hTrie.SetValue("fullblue", 0x0000FF);
hTrie.SetValue("fullred", 0xFF0000);
hTrie.SetValue("gainsboro", 0xDCDCDC);
hTrie.SetValue("genuine", 0x4D7455); // same as Genuine item quality in TF2
hTrie.SetValue("ghostwhite", 0xF8F8FF);
hTrie.SetValue("gold", 0xFFD700);
hTrie.SetValue("goldenrod", 0xDAA520);
hTrie.SetValue("gray", 0xCCCCCC); // same as spectator team color
hTrie.SetValue("grey", 0xCCCCCC);
hTrie.SetValue("green", 0x3EFF3E);
hTrie.SetValue("greenyellow", 0xADFF2F);
hTrie.SetValue("haunted", 0x38F3AB); // same as Haunted item quality in TF2
hTrie.SetValue("honeydew", 0xF0FFF0);
hTrie.SetValue("hotpink", 0xFF69B4);
hTrie.SetValue("immortal", 0xE4AE33); // same as Immortal item rarity in Dota 2
hTrie.SetValue("indianred", 0xCD5C5C);
hTrie.SetValue("indigo", 0x4B0082);
hTrie.SetValue("ivory", 0xFFFFF0);
hTrie.SetValue("khaki", 0xF0E68C);
hTrie.SetValue("lavender", 0xE6E6FA);
hTrie.SetValue("lavenderblush", 0xFFF0F5);
hTrie.SetValue("lawngreen", 0x7CFC00);
hTrie.SetValue("legendary", 0xD32CE6); // same as Legendary item rarity in Dota 2
hTrie.SetValue("lemonchiffon", 0xFFFACD);
hTrie.SetValue("lightblue", 0xADD8E6);
hTrie.SetValue("lightcoral", 0xF08080);
hTrie.SetValue("lightcyan", 0xE0FFFF);
hTrie.SetValue("lightgoldenrodyellow", 0xFAFAD2);
hTrie.SetValue("lightgray", 0xD3D3D3);
hTrie.SetValue("lightgrey", 0xD3D3D3);
hTrie.SetValue("lightgreen", 0x99FF99);
hTrie.SetValue("lightpink", 0xFFB6C1);
hTrie.SetValue("lightsalmon", 0xFFA07A);
hTrie.SetValue("lightseagreen", 0x20B2AA);
hTrie.SetValue("lightskyblue", 0x87CEFA);
hTrie.SetValue("lightslategray", 0x778899);
hTrie.SetValue("lightslategrey", 0x778899);
hTrie.SetValue("lightsteelblue", 0xB0C4DE);
hTrie.SetValue("lightyellow", 0xFFFFE0);
hTrie.SetValue("lime", 0x00FF00);
hTrie.SetValue("limegreen", 0x32CD32);
hTrie.SetValue("linen", 0xFAF0E6);
hTrie.SetValue("magenta", 0xFF00FF);
hTrie.SetValue("maroon", 0x800000);
hTrie.SetValue("mediumaquamarine", 0x66CDAA);
hTrie.SetValue("mediumblue", 0x0000CD);
hTrie.SetValue("mediumorchid", 0xBA55D3);
hTrie.SetValue("mediumpurple", 0x9370D8);
hTrie.SetValue("mediumseagreen", 0x3CB371);
hTrie.SetValue("mediumslateblue", 0x7B68EE);
hTrie.SetValue("mediumspringgreen", 0x00FA9A);
hTrie.SetValue("mediumturquoise", 0x48D1CC);
hTrie.SetValue("mediumvioletred", 0xC71585);
hTrie.SetValue("midnightblue", 0x191970);
hTrie.SetValue("mintcream", 0xF5FFFA);
hTrie.SetValue("mistyrose", 0xFFE4E1);
hTrie.SetValue("moccasin", 0xFFE4B5);
hTrie.SetValue("mythical", 0x8847FF); // same as Mythical item rarity in Dota 2
hTrie.SetValue("navajowhite", 0xFFDEAD);
hTrie.SetValue("navy", 0x000080);
hTrie.SetValue("normal", 0xB2B2B2); // same as Normal item quality in TF2
hTrie.SetValue("oldlace", 0xFDF5E6);
hTrie.SetValue("olive", 0x9EC34F);
hTrie.SetValue("olivedrab", 0x6B8E23);
hTrie.SetValue("orange", 0xFFA500);
hTrie.SetValue("orangered", 0xFF4500);
hTrie.SetValue("orchid", 0xDA70D6);
hTrie.SetValue("palegoldenrod", 0xEEE8AA);
hTrie.SetValue("palegreen", 0x98FB98);
hTrie.SetValue("paleturquoise", 0xAFEEEE);
hTrie.SetValue("palevioletred", 0xD87093);
hTrie.SetValue("papayawhip", 0xFFEFD5);
hTrie.SetValue("peachpuff", 0xFFDAB9);
hTrie.SetValue("peru", 0xCD853F);
hTrie.SetValue("pink", 0xFFC0CB);
hTrie.SetValue("plum", 0xDDA0DD);
hTrie.SetValue("powderblue", 0xB0E0E6);
hTrie.SetValue("purple", 0x800080);
hTrie.SetValue("rare", 0x4B69FF); // same as Rare item rarity in Dota 2
hTrie.SetValue("red", 0xFF4040); // same as RED/Terrorist team color
hTrie.SetValue("rosybrown", 0xBC8F8F);
hTrie.SetValue("royalblue", 0x4169E1);
hTrie.SetValue("saddlebrown", 0x8B4513);
hTrie.SetValue("salmon", 0xFA8072);
hTrie.SetValue("sandybrown", 0xF4A460);
hTrie.SetValue("seagreen", 0x2E8B57);
hTrie.SetValue("seashell", 0xFFF5EE);
hTrie.SetValue("selfmade", 0x70B04A); // same as Self-Made item quality in TF2
hTrie.SetValue("sienna", 0xA0522D);
hTrie.SetValue("silver", 0xC0C0C0);
hTrie.SetValue("skyblue", 0x87CEEB);
hTrie.SetValue("slateblue", 0x6A5ACD);
hTrie.SetValue("slategray", 0x708090);
hTrie.SetValue("slategrey", 0x708090);
hTrie.SetValue("snow", 0xFFFAFA);
hTrie.SetValue("springgreen", 0x00FF7F);
hTrie.SetValue("steelblue", 0x4682B4);
hTrie.SetValue("strange", 0xCF6A32); // same as Strange item quality in TF2
hTrie.SetValue("tan", 0xD2B48C);
hTrie.SetValue("teal", 0x008080);
hTrie.SetValue("thistle", 0xD8BFD8);
hTrie.SetValue("tomato", 0xFF6347);
hTrie.SetValue("turquoise", 0x40E0D0);
hTrie.SetValue("uncommon", 0xB0C3D9); // same as Uncommon item rarity in Dota 2
hTrie.SetValue("unique", 0xFFD700); // same as Unique item quality in TF2
hTrie.SetValue("unusual", 0x8650AC); // same as Unusual item quality in TF2
hTrie.SetValue("valve", 0xA50F79); // same as Valve item quality in TF2
hTrie.SetValue("vintage", 0x476291); // same as Vintage item quality in TF2
hTrie.SetValue("violet", 0xEE82EE);
hTrie.SetValue("wheat", 0xF5DEB3);
hTrie.SetValue("white", 0xFFFFFF);
hTrie.SetValue("whitesmoke", 0xF5F5F5);
hTrie.SetValue("yellow", 0xFFFF00);
hTrie.SetValue("yellowgreen", 0x9ACD32);
return hTrie;
}
+66
View File
@@ -0,0 +1,66 @@
#if defined _OutputInfo_Included
#endinput
#endif
#define _OutputInfo_Included
native int GetOutputCount(int Entity, const char[] sOutput);
native int GetOutputTarget(int Entity, const char[] sOutput, int Index, char[] sTarget, int MaxLen);
native int GetOutputTargetInput(int Entity, const char[] sOutput, int Index, char[] sTargetInput, int MaxLen);
native int GetOutputParameter(int Entity, const char[] sOutput, int Index, char[] sParameter, int MaxLen);
native float GetOutputDelay(int Entity, const char[] sOutput, int Index);
native int GetOutputFormatted(int Entity, const char[] sOutput, int Index, char[] sFormatted, int MaxLen);
native int GetOutputValue(int Entity, const char[] sOutput);
native float GetOutputValueFloat(int Entity, const char[] sOutput);
native int GetOutputValueString(int Entity, const char[] sOutput, char[] sValue, int MaxLen);
native bool GetOutputValueVector(int Entity, const char[] sOutput, float afVec[3]);
native int FindOutput(int Entity, const char[] sOutput, int StartIndex,
const char[] sTarget = NULL_STRING, // or NULL_STRING to ignore
const char[] sTargetInput = NULL_STRING, // or NULL_STRING to ignore
const char[] sParameter = NULL_STRING, // or NULL_STRING to ignore
float fDelay = -1.0, // or -1.0 to ignore
int TimesToFire = 0 // or 0 to ignore
);
native int DeleteOutput(int Entity, const char[] sOutput, int Index);
native int DeleteAllOutputs(int Entity, const char[] sOutput);
native int GetOutputNames(int Entity, int Index, const char[] sOutput, int MaxLen);
/**
* Do not edit below this line!
*/
public Extension __ext_outputinfo =
{
name = "OutputInfo",
file = "outputinfo.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public __ext_outputinfo_SetNTVOptional()
{
MarkNativeAsOptional("GetOutputCount");
MarkNativeAsOptional("GetOutputTarget");
MarkNativeAsOptional("GetOutputTargetInput");
MarkNativeAsOptional("GetOutputParameter");
MarkNativeAsOptional("GetOutputDelay");
MarkNativeAsOptional("GetOutputFormatted");
MarkNativeAsOptional("FindOutput");
MarkNativeAsOptional("DeleteOutput");
MarkNativeAsOptional("DeleteAllOutputs");
MarkNativeAsOptional("GetOutputNames");
}
#endif
File diff suppressed because it is too large Load Diff
+141
View File
@@ -0,0 +1,141 @@
#if defined _soundlib2_ext_included
#endinput
#endif
#define _soundlib2_ext_included
methodmap SoundFile < Handle
{
/**
* Opens a sound file.
*
* @note Sound files are closed with delete operator.
*
* @param file File to open
* @param valve if true, path is opened in Valve Filesystem.
* @return A Handle to the sound file, null on open error.
*/
public native SoundFile(const char[] path, bool value_file_system = false);
/**
* Gets the length of the sound file in seconds
*
* @return T The song length in seconds
*/
property int Length
{
// getter
public native get();
}
/**
* Gets the length of the sound file in milliseconds
*
* @return The song length in milliseconds
*/
property int LengthInMilliseconds
{
// getter
public native get();
}
/**
* Get the Bit rate of sound (kbps)
*
* @return sound bitrate (int)
*/
property int BitRate
{
// getter
public native get();
}
/**
* Get the Sampling rate of sound (hz)
*
* @return sampling rate (int)
*/
property int SamplingRate
{
// getter
public native get();
}
};
/**
* Opens a sound file.
*
* @note Sound files are closed with delete operator.
*
* @param file File to open
* @param valve if true, path is opened in Valve Filesystem.
* @return A Handle to the sound file, null on open error.
*/
native SoundFile OpenSoundFile(const char[] path, bool valve=false);
/**
* Gets the length of the sound file in seconds
*
* @param hndl Handle to the sound file.
* @return T The song length in seconds
*/
native int GetSoundLength(SoundFile soundfile);
/**
* Gets the length of the sound file in milliseconds
*
* @param hndl Handle to the sound file.
* @return The song length in milliseconds
*/
native int GetSoundLengthInMilliseconds(SoundFile soundfile);
/**
* Get the Bit rate of sound (kbps)
*
* @param hndl Handle to the sound file
* @return sound bitrate (int)
*/
native int GetSoundBitrate(SoundFile soundfile);
/**
* Get the Sampling rate of sound (hz)
*
* @param hndl Handle to the sound file
* @return sampling rate (int)
*/
native int GetSoundSamplingRate(SoundFile soundfile);
/**
* Do not edit below this line!
*/
public Extension __ext_soundlib2 =
{
name = "SoundLib2",
file = "soundlib2.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_EXTENSIONS
public void __ext_soundlib2_SetNTVOptional()
{
MarkNativeAsOptional("SoundFile.SoundFile");
MarkNativeAsOptional("SoundFile.Length.get");
MarkNativeAsOptional("SoundFile.LengthInMilliseconds.get");
MarkNativeAsOptional("SoundFile.Bitrate.get");
MarkNativeAsOptional("SoundFile.SamplingRate.get");
MarkNativeAsOptional("OpenSoundFile");
MarkNativeAsOptional("GetSoundLength");
MarkNativeAsOptional("GetSoundLengthInMilliseconds");
MarkNativeAsOptional("GetSoundBitrate");
MarkNativeAsOptional("GetSoundSamplingRate");
}
#endif
+62
View File
@@ -0,0 +1,62 @@
// *************************************************************************
// This file is part of SourceBans++.
//
// Copyright (C) 2014-2016 Sarabveer Singh <[email protected]>
//
// SourceBans++ is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, per version 3 of the License.
//
// SourceBans++ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SourceBans++. If not, see <http://www.gnu.org/licenses/>.
//
// This file incorporates work covered by the following copyright(s):
//
// SourceBans 1.4.11
// Copyright (C) 2007-2015 SourceBans Team - Part of GameConnect
// Licensed under GNU GPL version 3, or later.
// Page: <http://www.sourcebans.net/> - <https://github.com/GameConnect/sourcebansv1>
//
// *************************************************************************
#if defined _sourcebans_included
#endinput
#endif
#define _sourcebans_included
public SharedPlugin:__pl_sourcebans =
{
name = "SourceBans",
file = "sourcebans.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_sourcebans_SetNTVOptional()
{
MarkNativeAsOptional("SBBanPlayer");
}
#endif
/*********************************************************
* Ban Player from server
*
* @param client The client index of the admin who is banning the client
* @param target The client index of the player to ban
* @param time The time to ban the player for (in minutes, 0 = permanent)
* @param reason The reason to ban the player from the server
* @noreturn
*********************************************************/
native SBBanPlayer(client, target, time, String:reason[]);
//Yarr!
+103
View File
@@ -0,0 +1,103 @@
// *************************************************************************
// This file is part of SourceBans++.
//
// Copyright (C) 2014-2016 Sarabveer Singh <[email protected]>
//
// SourceBans++ is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, per version 3 of the License.
//
// SourceBans++ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SourceBans++. If not, see <http://www.gnu.org/licenses/>.
//
// This file incorporates work covered by the following copyright(s):
//
// SourceComms 0.9.266
// Copyright (C) 2013-2014 Alexandr Duplishchev
// Licensed under GNU GPL version 3, or later.
// Page: <https://forums.alliedmods.net/showthread.php?p=1883705> - <https://github.com/d-ai/SourceComms>
//
// *************************************************************************
#if defined _sourcecomms_included
#endinput
#endif
#define _sourcecomms_included
/* Punishments types */
enum bType {
bNot = 0, // Player chat or voice is not blocked
bSess, // ... blocked for player session (until reconnect)
bTime, // ... blocked for some time
bPerm // ... permanently blocked
}
/**
* Sets a client's mute state.
*
* @param client Client index.
* @param muteState True to mute client, false to unmute.
* -------------------------------------Parameters below this line are used only for muteState=true-------------------------------------
* ----------------------------------for muteState=false these parameters are ignored (saveToDB=false)----------------------------------
* @param muteLength Length of punishment in minutes. Value < 0 muting client for session. Permanent (0) is not allowed at this time.
* @param saveToDB If true, punishment will be saved in database.
* @param reason Reason for punishment.
* @return True if this caused a change in mute state, false otherwise.
*/
native bool:SourceComms_SetClientMute(client, bool:muteState, muteLength = -1, bool:saveToDB = false, const String:reason[] = "Muted through natives");
/**
* Sets a client's gag state.
*
* @param client Client index.
* @param gagState True to gag client, false to ungag.
* --------------------------------------Parameters below this line are used only for gagState=true--------------------------------------
* -----------------------------------for gagState=false these parameters are ignored (saveToDB=false)-----------------------------------
* @param gagLength Length of punishment in minutes. Value < 0 gagging client for session. Permanent (0) is not allowed at this time.
* @param saveToDB If true, punishment will be saved in database.
* @param reason Reason for punishment.
* @return True if this caused a change in gag state, false otherwise.
*/
native bool:SourceComms_SetClientGag(client, bool:gagState, gagLength = -1, bool:saveToDB = false, const String:reason[] = "Gagged through natives");
/**
* Returns the client's mute type
*
* @param client The client index of the player to check mute status
* @return The client's current mute type index (see enum bType in the begin).
*/
native bType:SourceComms_GetClientMuteType(client);
/**
* Returns the client's gag type
*
* @param client The client index of the player to check gag status
* @return The client's current gag type index (see enum bType in the begin).
*/
native bType:SourceComms_GetClientGagType(client);
public SharedPlugin:__pl_sourcecomms =
{
name = "sourcecomms",
file = "sourcecomms.smx",
#if defined REQUIRE_PLUGIN
required = 1
#else
required = 0
#endif
};
public __pl_sourcecomms_SetNTVOptional()
{
MarkNativeAsOptional("SourceComms_SetClientMute");
MarkNativeAsOptional("SourceComms_SetClientGag");
MarkNativeAsOptional("SourceComms_GetClientMuteType");
MarkNativeAsOptional("SourceComms_GetClientGagType");
}
+30
View File
@@ -0,0 +1,30 @@
#if defined _UNLOZE_ForumIntegration_Included
#endinput
#endif
#define _UNLOZE_ForumIntegration_Included
typeset AsyncHasSteamIDReservedSlotCallbackFunc
{
function void (const char[] sSteam32ID, int Result);
function void (const char[] sSteam32ID, int Result, any Data);
};
native void AsyncHasSteamIDReservedSlot(const char[] sSteam32ID, AsyncHasSteamIDReservedSlotCallbackFunc Callback, any Data = 0);
public SharedPlugin __pl_UNLOZE_ForumIntegration =
{
name = "UNLOZE_ForumIntegration",
file = "UNLOZE_ForumIntegration.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
#if !defined REQUIRE_PLUGIN
public __pl_UNLOZE_ForumIntegration_SetNTVOptional()
{
MarkNativeAsOptional("AsyncHasSteamIDReservedSlot");
}
#endif
+57
View File
@@ -0,0 +1,57 @@
#if defined _voiceannounceex_included_
#endinput
#endif
#define _voiceannounceex_included_
public SharedPlugin __pl_voiceannounceex =
{
name = "voiceannounce_ex",
file = "voiceannounce_ex.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
public void __pl_voiceannounceex_SetNTVOptional()
{
MarkNativeAsOptional("IsClientSpeaking");
}
/**
*
* Checks whether a client is speaking or not.
*
* @param client The client index to check against.
*
* @error Client is not valid, ingame, or client is a bot.
*
* @return True if client is speaking, false otherwise.
*
*/
native bool IsClientSpeaking(int client);
/**
*
* Called while a client is speaking.
*
* @param client Client index.
*
* @noreturn
*
*/
forward void OnClientSpeakingEx(int client);
/**
*
* Called when a client ends speaking.
*
* @param client Client index.
*
* @noreturn
*
*/
forward void OnClientSpeakingEnd(int client);