initial commit

This commit is contained in:
BotoX
2016-01-06 02:11:56 +01:00
commit 72f7665358
106 changed files with 17675 additions and 0 deletions
+324
View File
@@ -0,0 +1,324 @@
#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
};
/* 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,
// 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,
};
native bool:SteamWorks_IsVACEnabled();
native bool:SteamWorks_GetPublicIP(ipaddr[4]);
native SteamWorks_GetPublicIPCell();
native bool:SteamWorks_IsLoaded();
native bool:SteamWorks_SetGameDescription(String:sDesc[]);
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 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[]);
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)
};
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_SetHTTPRequestRawPostBody(Handle:hRequest, const String:sContentType[], const String:sBody[], bodylen);
funcenum SteamWorksHTTPBodyCallback
{
public(const String:sData[]),
public(const String:sData[], any:value),
public(const data[], any:value, datalen)
};
native bool:SteamWorks_GetHTTPResponseBodyCallback(Handle:hRequest, SteamWorksHTTPBodyCallback:fCallback, any:data = 0, Handle:hPlugin = INVALID_HANDLE);
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);
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_SetGameDescription");
MarkNativeAsOptional("SteamWorks_IsConnected");
MarkNativeAsOptional("SteamWorks_SetRule");
MarkNativeAsOptional("SteamWorks_ClearRules");
MarkNativeAsOptional("SteamWorks_ForceHeartbeat");
MarkNativeAsOptional("SteamWorks_GetUserGroupStatus");
MarkNativeAsOptional("SteamWorks_GetUserGroupStatusAuthID");
MarkNativeAsOptional("SteamWorks_HasLicenseForApp");
MarkNativeAsOptional("SteamWorks_GetClientSteamID");
MarkNativeAsOptional("SteamWorks_RequestStatsAuthID");
MarkNativeAsOptional("SteamWorks_RequestStats");
MarkNativeAsOptional("SteamWorks_GetStatCell");
MarkNativeAsOptional("SteamWorks_GetStatAuthIDCell");
MarkNativeAsOptional("SteamWorks_GetStatFloat");
MarkNativeAsOptional("SteamWorks_GetStatAuthIDFloat");
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_GetHTTPResponseBodyCallback");
MarkNativeAsOptional("SteamWorks_WriteHTTPResponseBodyToFile");
}
#endif
+539
View File
@@ -0,0 +1,539 @@
/**************************************************************************
* *
* Colored Chat Functions *
* Author: exvel, Editor: Popoklopsi, Powerlord, Bara *
* Version: 1.1.3 *
* *
**************************************************************************/
#if defined _colors_included
#endinput
#endif
#define _colors_included
#define MAX_MESSAGE_LENGTH 250
#define MAX_COLORS 12
#define SERVER_INDEX 0
#define NO_INDEX -1
#define NO_PLAYER -2
enum 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_Orange
}
/* Colors' properties */
new String:CTag[][] = {"{default}", "{darkred}", "{green}", "{lightgreen}", "{red}", "{blue}", "{olive}", "{lime}", "{lightred}", "{purple}", "{grey}", "{orange}"};
new String:CTagCode[][] = {"\x01", "\x02", "\x04", "\x03", "\x03", "\x03", "\x05", "\x06", "\x07", "\x03", "\x08", "\x09"};
new bool:CTagReqSayText2[] = {false, false, false, true, true, true, false, false, false, false, false, false};
new bool:CEventIsHooked = false;
new bool:CSkipList[MAXPLAYERS+1] = {false,...};
/* Game default profile */
new bool:CProfile_Colors[] = {true, false, true, false, false, false, false, false, false, false, false, false};
new CProfile_TeamIndex[] = {NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX, NO_INDEX};
new bool:CProfile_SayText2 = false;
/**
* 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 CPrintToChat(client, const String:szMessage[], any:...)
{
if (client <= 0 || client > MaxClients)
ThrowError("Invalid client index %d", client);
if (!IsClientInGame(client))
ThrowError("Client %d is not in game", client);
decl String:szBuffer[MAX_MESSAGE_LENGTH];
decl String:szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 3);
new index = CFormat(szCMessage, sizeof(szCMessage));
if (index == NO_INDEX)
PrintToChat(client, "%s", szCMessage);
else
CSayText2(client, index, szCMessage);
}
stock CReplyToCommand(client, const String:szMessage[], any:...)
{
decl String:szCMessage[MAX_MESSAGE_LENGTH];
VFormat(szCMessage, sizeof(szCMessage), szMessage, 3);
if (client == 0)
{
CRemoveTags(szCMessage, sizeof(szCMessage));
PrintToServer("%s", szCMessage);
}
else if (GetCmdReplySource() == SM_REPLY_TO_CONSOLE)
{
CRemoveTags(szCMessage, sizeof(szCMessage));
PrintToConsole(client, "%s", szCMessage);
}
else
{
CPrintToChat(client, "%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 CPrintToChatAll(const String:szMessage[], any:...)
{
decl String:szBuffer[MAX_MESSAGE_LENGTH];
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i) && !CSkipList[i])
{
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 2);
CPrintToChat(i, "%s", szBuffer);
}
CSkipList[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 CPrintToChatEx(client, author, const String: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);
decl String:szBuffer[MAX_MESSAGE_LENGTH];
decl String:szCMessage[MAX_MESSAGE_LENGTH];
SetGlobalTransTarget(client);
Format(szBuffer, sizeof(szBuffer), "\x01%s", szMessage);
VFormat(szCMessage, sizeof(szCMessage), szBuffer, 4);
new index = CFormat(szCMessage, sizeof(szCMessage), author);
if (index == NO_INDEX)
PrintToChat(client, "%s", szCMessage);
else
CSayText2(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 CPrintToChatAllEx(author, const String:szMessage[], any:...)
{
if (author < 0 || author > MaxClients)
ThrowError("Invalid client index %d", author);
if (!IsClientInGame(author))
ThrowError("Client %d is not in game", author);
decl String:szBuffer[MAX_MESSAGE_LENGTH];
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && !IsFakeClient(i) && !CSkipList[i])
{
SetGlobalTransTarget(i);
VFormat(szBuffer, sizeof(szBuffer), szMessage, 3);
CPrintToChatEx(i, author, "%s", szBuffer);
}
CSkipList[i] = false;
}
}
/**
* Removes color tags from the string.
*
* @param szMessage String.
* @return No return
*/
stock CRemoveTags(String:szMessage[], maxlength)
{
for (new i = 0; i < MAX_COLORS; i++)
ReplaceString(szMessage, maxlength, CTag[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 CColorAllowed(Colors:color)
{
if (!CEventIsHooked)
{
CSetupProfile();
CEventIsHooked = true;
}
return CProfile_Colors[color];
}
/**
* Replace the color with another color
* Handle with care!
*
* @param color color to replace.
* @param newColor color to replace with.
* @noreturn
*/
stock CReplaceColor(Colors:color, Colors:newColor)
{
if (!CEventIsHooked)
{
CSetupProfile();
CEventIsHooked = true;
}
CProfile_Colors[color] = CProfile_Colors[newColor];
CProfile_TeamIndex[color] = CProfile_TeamIndex[newColor];
CTagReqSayText2[color] = CTagReqSayText2[newColor];
Format(CTagCode[color], sizeof(CTagCode[]), CTagCode[newColor])
}
/**
* This function should only be used right in front of
* CPrintToChatAll or CPrintToChatAllEx 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 CSkipNextClient(client)
{
if (client <= 0 || client > MaxClients)
ThrowError("Invalid client index %d", client);
CSkipList[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 CFormat(String:szMessage[], maxlength, author=NO_INDEX)
{
decl String:szGameName[30];
GetGameFolderName(szGameName, sizeof(szGameName));
/* Hook event for auto profile setup on map start */
if (!CEventIsHooked)
{
CSetupProfile();
HookEvent("server_spawn", CEvent_MapStart, EventHookMode_PostNoCopy);
CEventIsHooked = true;
}
new iRandomPlayer = NO_INDEX;
// On CS:GO set invisible precolor
if (StrEqual(szGameName, "csgo", false))
Format(szMessage, maxlength, " \x01\x0B\x01%s", szMessage);
/* If author was specified replace {teamcolor} tag */
if (author != NO_INDEX)
{
if (CProfile_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}", CTagCode[Color_Green], false);
}
else
ReplaceString(szMessage, maxlength, "{teamcolor}", "", false);
/* For other color tags we need a loop */
for (new i = 0; i < MAX_COLORS; i++)
{
/* If tag not found - skip */
if (StrContains(szMessage, CTag[i], false) == -1)
continue;
/* If tag is not supported by game replace it with green tag */
else if (!CProfile_Colors[i])
ReplaceString(szMessage, maxlength, CTag[i], CTagCode[Color_Green], false);
/* If tag doesn't need saytext2 simply replace */
else if (!CTagReqSayText2[i])
ReplaceString(szMessage, maxlength, CTag[i], CTagCode[i], false);
/* Tag needs saytext2 */
else
{
/* If saytext2 is not supported by game replace tag with green tag */
if (!CProfile_SayText2)
ReplaceString(szMessage, maxlength, CTag[i], CTagCode[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 = CFindRandomPlayerByTeam(CProfile_TeamIndex[i]);
/* If player not found replace tag with green color tag */
if (iRandomPlayer == NO_PLAYER)
ReplaceString(szMessage, maxlength, CTag[i], CTagCode[Color_Green], false);
/* If player was found simply replace */
else
ReplaceString(szMessage, maxlength, CTag[i], CTagCode[i], false);
}
/* If found another team color tag throw error */
else
{
//ReplaceString(szMessage, maxlength, CTag[i], "");
ThrowError("Using two team colors in one message is not allowed");
}
}
}
}
return iRandomPlayer;
}
/**
* Founds a random player with specified team
*
* @param color_team Client team.
* @return Client index or NO_PLAYER if no player found
*/
stock CFindRandomPlayerByTeam(color_team)
{
if (color_team == SERVER_INDEX)
return 0;
else
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == color_team)
return i;
}
}
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 CSayText2(client, author, const String:szMessage[])
{
new Handle:hBuffer = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
PbSetInt(hBuffer, "ent_idx", author);
PbSetBool(hBuffer, "chat", true);
PbSetString(hBuffer, "msg_name", szMessage);
PbAddString(hBuffer, "params", "");
PbAddString(hBuffer, "params", "");
PbAddString(hBuffer, "params", "");
PbAddString(hBuffer, "params", "");
}
else
{
BfWriteByte(hBuffer, author);
BfWriteByte(hBuffer, true);
BfWriteString(hBuffer, szMessage);
}
EndMessage();
}
/**
* Creates game color profile
* This function must be edited if you want to add more games support
*
* @return No return.
*/
stock CSetupProfile()
{
decl String:szGameName[30];
GetGameFolderName(szGameName, sizeof(szGameName));
if (StrEqual(szGameName, "cstrike", false))
{
CProfile_Colors[Color_Lightgreen] = true;
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_Colors[Color_Olive] = true;
CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
CProfile_TeamIndex[Color_Red] = 2;
CProfile_TeamIndex[Color_Blue] = 3;
CProfile_SayText2 = true;
}
else if (StrEqual(szGameName, "csgo", false))
{
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_Colors[Color_Olive] = true;
CProfile_Colors[Color_Darkred] = true;
CProfile_Colors[Color_Lime] = true;
CProfile_Colors[Color_Lightred] = true;
CProfile_Colors[Color_Purple] = true;
CProfile_Colors[Color_Grey] = true;
CProfile_Colors[Color_Orange] = true;
CProfile_TeamIndex[Color_Red] = 2;
CProfile_TeamIndex[Color_Blue] = 3;
CProfile_SayText2 = true;
}
else if (StrEqual(szGameName, "tf", false))
{
CProfile_Colors[Color_Lightgreen] = true;
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_Colors[Color_Olive] = true;
CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
CProfile_TeamIndex[Color_Red] = 2;
CProfile_TeamIndex[Color_Blue] = 3;
CProfile_SayText2 = true;
}
else if (StrEqual(szGameName, "left4dead", false) || StrEqual(szGameName, "left4dead2", false))
{
CProfile_Colors[Color_Lightgreen] = true;
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_Colors[Color_Olive] = true;
CProfile_TeamIndex[Color_Lightgreen] = SERVER_INDEX;
CProfile_TeamIndex[Color_Red] = 3;
CProfile_TeamIndex[Color_Blue] = 2;
CProfile_SayText2 = true;
}
else if (StrEqual(szGameName, "hl2mp", false))
{
/* hl2mp profile is based on mp_teamplay convar */
if (GetConVarBool(FindConVar("mp_teamplay")))
{
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_Colors[Color_Olive] = true;
CProfile_TeamIndex[Color_Red] = 3;
CProfile_TeamIndex[Color_Blue] = 2;
CProfile_SayText2 = true;
}
else
{
CProfile_SayText2 = false;
CProfile_Colors[Color_Olive] = true;
}
}
else if (StrEqual(szGameName, "dod", false))
{
CProfile_Colors[Color_Olive] = true;
CProfile_SayText2 = false;
}
/* Profile for other games */
else
{
if (GetUserMessageId("SayText2") == INVALID_MESSAGE_ID)
{
CProfile_SayText2 = false;
}
else
{
CProfile_Colors[Color_Red] = true;
CProfile_Colors[Color_Blue] = true;
CProfile_TeamIndex[Color_Red] = 2;
CProfile_TeamIndex[Color_Blue] = 3;
CProfile_SayText2 = true;
}
}
}
public Action:CEvent_MapStart(Handle:event, const String:name[], bool:dontBroadcast)
{
CSetupProfile();
for (new i = 1; i <= MaxClients; i++)
CSkipList[i] = false;
}
+482
View File
@@ -0,0 +1,482 @@
#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 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),
DHookPass_ByRef = (1<<1)
};
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 Callback function
*
* @return Returns setup handle for the hook or INVALID_HANDLE.
*/
native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, 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.
*
* @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);
//native DHookAddParam(Handle:setup, HookParamType:type);
/* 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 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 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)
*
* @error Invalid setup handle, invalid entity or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=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 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 removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback)
*
* @error Invalid setup handle, failing to get gamerules pointer or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=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 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 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)
*
* @error Invalid setup handle, invalid address or invalid hook type.
* @return -1 on fail a hookid on success
*/
native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=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("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
+674
View File
@@ -0,0 +1,674 @@
// MOAR COLORS
// By Dr. McKay
// Inspired by: https://forums.alliedmods.net/showthread.php?t=96831
#if defined _colors_included
#endinput
#endif
#define _colors_included
#include <regex>
#define MORE_COLORS_VERSION "1.9.1"
#define MAX_MESSAGE_LENGTH 256
#define MAX_BUFFER_LENGTH (MAX_MESSAGE_LENGTH * 4)
#define COLOR_RED 0xFF4040
#define COLOR_BLUE 0x99CCFF
#define COLOR_GRAY 0xCCCCCC
#define COLOR_GREEN 0x3EFF3E
#define GAME_DODS 0
new bool:CSkipList[MAXPLAYERS + 1];
new Handle:CTrie;
new CTeamColors[][] = {{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
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock CPrintToChat(client, const String:message[], any:...) {
CCheckTrie();
if(client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
if(!IsClientInGame(client)) {
ThrowError("Client %i is not in game", client);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 3);
CReplaceColorCodes(buffer2);
CSendMessage(client, buffer2);
}
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
*/
stock CPrintToChatAll(const String:message[], any:...) {
CCheckTrie();
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
for(new i = 1; i <= MaxClients; i++) {
if(!IsClientInGame(i) || CSkipList[i]) {
CSkipList[i] = false;
continue;
}
SetGlobalTransTarget(i);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 2);
CReplaceColorCodes(buffer2);
CSendMessage(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).
* @noreturn
*
* On error/Errors: If the client or author are not connected an error will be thrown
*/
stock CPrintToChatEx(client, author, const String:message[], any:...) {
CCheckTrie();
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);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 4);
CReplaceColorCodes(buffer2, author);
CSendMessage(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).
* @noreturn
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock CPrintToChatAllEx(author, const String:message[], any:...) {
CCheckTrie();
if(author <= 0 || author > MaxClients) {
ThrowError("Invalid client index %i", author);
}
if(!IsClientInGame(author)) {
ThrowError("Client %i is not in game", author);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
for(new i = 1; i <= MaxClients; i++) {
if(!IsClientInGame(i) || CSkipList[i]) {
CSkipList[i] = false;
continue;
}
SetGlobalTransTarget(i);
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 3);
CReplaceColorCodes(buffer2, author);
CSendMessage(i, buffer2, author);
}
}
/**
* Sends a SayText2 usermessage
*
* @param client Client to send usermessage to
* @param message Message to send
* @noreturn
*/
stock CSendMessage(client, const String:message[], author=0) {
if(author == 0) {
author = client;
}
decl String:buffer[MAX_MESSAGE_LENGTH], String:game[16];
GetGameFolderName(game, sizeof(game));
strcopy(buffer, sizeof(buffer), message);
new UserMsg:index = GetUserMessageId("SayText2");
if(index == INVALID_MESSAGE_ID) {
if(StrEqual(game, "dod")) {
new team = GetClientTeam(author);
if(team == 0) {
ReplaceString(buffer, sizeof(buffer), "\x03", "\x04", false); // Unassigned gets green
} else {
decl String:temp[16];
Format(temp, sizeof(temp), "\x07%06X", CTeamColors[GAME_DODS][team - 1]);
ReplaceString(buffer, sizeof(buffer), "\x03", temp, false);
}
}
PrintToChat(client, "%s", buffer);
return;
}
new Handle:buf = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) {
PbSetInt(buf, "ent_idx", author);
PbSetBool(buf, "chat", true);
PbSetString(buf, "msg_name", buffer);
PbAddString(buf, "params", "");
PbAddString(buf, "params", "");
PbAddString(buf, "params", "");
PbAddString(buf, "params", "");
} else {
BfWriteByte(buf, author); // Message author
BfWriteByte(buf, true); // Chat message
BfWriteString(buf, buffer); // Message text
}
EndMessage();
}
/**
* This function should only be used right in front of
* CPrintToChatAll or CPrintToChatAllEx. 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
* @noreturn
*/
stock CSkipNextClient(client) {
if(client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
CSkipList[client] = true;
}
/**
* Checks if the colors trie is initialized and initializes it if it's not (used internally)
*
* @return No return
*/
stock CCheckTrie() {
if(CTrie == INVALID_HANDLE) {
CTrie = InitColorTrie();
}
}
/**
* Replaces color tags in a string with color codes (used internally by CPrintToChat, CPrintToChatAll, CPrintToChatEx, and CPrintToChatAllEx
*
* @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 CRemoveTags
* @param maxlen Optional value for max buffer length, used by CRemoveTags
* @noreturn
*
* On error/Errors: If the client index passed for author is invalid or not in game.
*/
stock CReplaceColorCodes(String:buffer[], author=0, bool:removeTags=false, maxlen=MAX_BUFFER_LENGTH) {
CCheckTrie();
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);
}
new cursor = 0;
new value;
decl String:tag[32], String:buff[32], String:output[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
new Handle:regex = CompileRegex("{[a-zA-Z0-9]+}");
for(new 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(MatchRegex(regex, buffer[cursor]) < 1) {
CloseHandle(regex);
strcopy(buffer, maxlen, output);
return;
}
GetRegexSubString(regex, 0, tag, sizeof(tag));
CStrToLower(tag);
cursor = StrContains(buffer[cursor], tag, false) + cursor + 1;
strcopy(buff, sizeof(buff), tag);
ReplaceString(buff, sizeof(buff), "{", "");
ReplaceString(buff, sizeof(buff), "}", "");
if(!GetTrieValue(CTrie, 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
* @noreturn
*/
stock CSubString(const String:input[], String:output[], maxlen, start, numChars=0) {
new 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
* @noreturn
*/
stock CStrToLower(String:buffer[]) {
new len = strlen(buffer);
for(new 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:CAddColor(const String:name[], color) {
CCheckTrie();
new value;
if(GetTrieValue(CTrie, name, value)) {
return false;
}
decl String:newName[64];
strcopy(newName, sizeof(newName), name);
CStrToLower(newName);
SetTrieValue(CTrie, newName, color);
return true;
}
/**
* Removes color tags from a message
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
* @noreturn
*/
stock CRemoveTags(String:message[], maxlen) {
CReplaceColorCodes(message, 0, true, maxlen);
}
/**
* Replies to a command with colors
*
* @param client Client to reply to
* @param message Message (formatting rules)
* @noreturn
*/
stock CReplyToCommand(client, const String:message[], any:...) {
decl String:buffer[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 3);
if(GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
CRemoveTags(buffer, sizeof(buffer));
PrintToConsole(client, "%s", buffer);
} else {
CPrintToChat(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)
* @noreturn
*/
stock CReplyToCommandEx(client, author, const String:message[], any:...) {
decl String:buffer[MAX_BUFFER_LENGTH];
SetGlobalTransTarget(client);
VFormat(buffer, sizeof(buffer), message, 4);
if(GetCmdReplySource() == SM_REPLY_TO_CONSOLE) {
CRemoveTags(buffer, sizeof(buffer));
PrintToConsole(client, "%s", buffer);
} else {
CPrintToChatEx(client, author, "%s", buffer);
}
}
/**
* Shows admin activity with colors
*
* @param client Client performing an action
* @param message Message (formatting rules)
* @noreturn
*/
stock CShowActivity(client, const String:message[], any:...) {
CCheckTrie();
if(client < 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
if(client != 0 && !IsClientInGame(client)) {
ThrowError("Client %d is not in game", client);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 3);
CReplaceColorCodes(buffer2);
ShowActivity(client, "%s", buffer2);
}
/**
* Shows admin activity with colors
*
* @param client Client performing an action
* @param tag Tag to prepend to the message (color tags supported)
* @param message Message (formatting rules)
* @noreturn
*/
stock CShowActivityEx(client, const String:tag[], const String:message[], any:...) {
CCheckTrie();
if(client < 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
if(client != 0 && !IsClientInGame(client)) {
ThrowError("Client %d is not in game", client);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 4);
CReplaceColorCodes(buffer2);
strcopy(buffer, sizeof(buffer), tag);
CReplaceColorCodes(buffer);
ShowActivityEx(client, tag, "%s", buffer2);
}
/**
* Shows admin activity with colors
*
* @param client Client performing an action
* @param tag Tag to prepend to the message (color tags supported)
* @param message Message (formatting rules)
* @noreturn
*/
stock CShowActivity2(client, const String:tag[], const String:message[], any:...) {
CCheckTrie();
if(client < 0 || client > MaxClients) {
ThrowError("Invalid client index %d", client);
}
if(client != 0 && !IsClientInGame(client)) {
ThrowError("Client %d is not in game", client);
}
decl String:buffer[MAX_BUFFER_LENGTH], String:buffer2[MAX_BUFFER_LENGTH];
Format(buffer, sizeof(buffer), "\x01%s", message);
VFormat(buffer2, sizeof(buffer2), buffer, 4);
CReplaceColorCodes(buffer2);
strcopy(buffer, sizeof(buffer), tag);
CReplaceColorCodes(buffer);
ShowActivity2(client, buffer, "%s", buffer2);
}
/**
* 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 String:color[]) {
CCheckTrie();
new temp;
return GetTrieValue(CTrie, 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 CGetTeamColor(client) {
if(client <= 0 || client > MaxClients) {
ThrowError("Invalid client index %i", client);
}
if(!IsClientInGame(client)) {
ThrowError("Client %i is not in game", client);
}
new value;
switch(GetClientTeam(client)) {
case 1: {
value = COLOR_GRAY;
}
case 2: {
value = COLOR_RED;
}
case 3: {
value = COLOR_BLUE;
}
default: {
value = COLOR_GREEN;
}
}
return value;
}
stock Handle:InitColorTrie() {
new Handle:hTrie = CreateTrie();
SetTrieValue(hTrie, "aliceblue", 0xF0F8FF);
SetTrieValue(hTrie, "allies", 0x4D7942); // same as Allies team in DoD:S
SetTrieValue(hTrie, "ancient", 0xEB4B4B); // same as Ancient item rarity in Dota 2
SetTrieValue(hTrie, "antiquewhite", 0xFAEBD7);
SetTrieValue(hTrie, "aqua", 0x00FFFF);
SetTrieValue(hTrie, "aquamarine", 0x7FFFD4);
SetTrieValue(hTrie, "arcana", 0xADE55C); // same as Arcana item rarity in Dota 2
SetTrieValue(hTrie, "axis", 0xFF4040); // same as Axis team in DoD:S
SetTrieValue(hTrie, "azure", 0x007FFF);
SetTrieValue(hTrie, "beige", 0xF5F5DC);
SetTrieValue(hTrie, "bisque", 0xFFE4C4);
SetTrieValue(hTrie, "black", 0x000000);
SetTrieValue(hTrie, "blanchedalmond", 0xFFEBCD);
SetTrieValue(hTrie, "blue", 0x99CCFF); // same as BLU/Counter-Terrorist team color
SetTrieValue(hTrie, "blueviolet", 0x8A2BE2);
SetTrieValue(hTrie, "brown", 0xA52A2A);
SetTrieValue(hTrie, "burlywood", 0xDEB887);
SetTrieValue(hTrie, "cadetblue", 0x5F9EA0);
SetTrieValue(hTrie, "chartreuse", 0x7FFF00);
SetTrieValue(hTrie, "chocolate", 0xD2691E);
SetTrieValue(hTrie, "collectors", 0xAA0000); // same as Collector's item quality in TF2
SetTrieValue(hTrie, "common", 0xB0C3D9); // same as Common item rarity in Dota 2
SetTrieValue(hTrie, "community", 0x70B04A); // same as Community item quality in TF2
SetTrieValue(hTrie, "coral", 0xFF7F50);
SetTrieValue(hTrie, "cornflowerblue", 0x6495ED);
SetTrieValue(hTrie, "cornsilk", 0xFFF8DC);
SetTrieValue(hTrie, "corrupted", 0xA32C2E); // same as Corrupted item quality in Dota 2
SetTrieValue(hTrie, "crimson", 0xDC143C);
SetTrieValue(hTrie, "cyan", 0x00FFFF);
SetTrieValue(hTrie, "darkblue", 0x00008B);
SetTrieValue(hTrie, "darkcyan", 0x008B8B);
SetTrieValue(hTrie, "darkgoldenrod", 0xB8860B);
SetTrieValue(hTrie, "darkgray", 0xA9A9A9);
SetTrieValue(hTrie, "darkgrey", 0xA9A9A9);
SetTrieValue(hTrie, "darkgreen", 0x006400);
SetTrieValue(hTrie, "darkkhaki", 0xBDB76B);
SetTrieValue(hTrie, "darkmagenta", 0x8B008B);
SetTrieValue(hTrie, "darkolivegreen", 0x556B2F);
SetTrieValue(hTrie, "darkorange", 0xFF8C00);
SetTrieValue(hTrie, "darkorchid", 0x9932CC);
SetTrieValue(hTrie, "darkred", 0x8B0000);
SetTrieValue(hTrie, "darksalmon", 0xE9967A);
SetTrieValue(hTrie, "darkseagreen", 0x8FBC8F);
SetTrieValue(hTrie, "darkslateblue", 0x483D8B);
SetTrieValue(hTrie, "darkslategray", 0x2F4F4F);
SetTrieValue(hTrie, "darkslategrey", 0x2F4F4F);
SetTrieValue(hTrie, "darkturquoise", 0x00CED1);
SetTrieValue(hTrie, "darkviolet", 0x9400D3);
SetTrieValue(hTrie, "deeppink", 0xFF1493);
SetTrieValue(hTrie, "deepskyblue", 0x00BFFF);
SetTrieValue(hTrie, "dimgray", 0x696969);
SetTrieValue(hTrie, "dimgrey", 0x696969);
SetTrieValue(hTrie, "dodgerblue", 0x1E90FF);
SetTrieValue(hTrie, "exalted", 0xCCCCCD); // same as Exalted item quality in Dota 2
SetTrieValue(hTrie, "firebrick", 0xB22222);
SetTrieValue(hTrie, "floralwhite", 0xFFFAF0);
SetTrieValue(hTrie, "forestgreen", 0x228B22);
SetTrieValue(hTrie, "frozen", 0x4983B3); // same as Frozen item quality in Dota 2
SetTrieValue(hTrie, "fuchsia", 0xFF00FF);
SetTrieValue(hTrie, "fullblue", 0x0000FF);
SetTrieValue(hTrie, "fullred", 0xFF0000);
SetTrieValue(hTrie, "gainsboro", 0xDCDCDC);
SetTrieValue(hTrie, "genuine", 0x4D7455); // same as Genuine item quality in TF2
SetTrieValue(hTrie, "ghostwhite", 0xF8F8FF);
SetTrieValue(hTrie, "gold", 0xFFD700);
SetTrieValue(hTrie, "goldenrod", 0xDAA520);
SetTrieValue(hTrie, "gray", 0xCCCCCC); // same as spectator team color
SetTrieValue(hTrie, "grey", 0xCCCCCC);
SetTrieValue(hTrie, "green", 0x3EFF3E);
SetTrieValue(hTrie, "greenyellow", 0xADFF2F);
SetTrieValue(hTrie, "haunted", 0x38F3AB); // same as Haunted item quality in TF2
SetTrieValue(hTrie, "honeydew", 0xF0FFF0);
SetTrieValue(hTrie, "hotpink", 0xFF69B4);
SetTrieValue(hTrie, "immortal", 0xE4AE33); // same as Immortal item rarity in Dota 2
SetTrieValue(hTrie, "indianred", 0xCD5C5C);
SetTrieValue(hTrie, "indigo", 0x4B0082);
SetTrieValue(hTrie, "ivory", 0xFFFFF0);
SetTrieValue(hTrie, "khaki", 0xF0E68C);
SetTrieValue(hTrie, "lavender", 0xE6E6FA);
SetTrieValue(hTrie, "lavenderblush", 0xFFF0F5);
SetTrieValue(hTrie, "lawngreen", 0x7CFC00);
SetTrieValue(hTrie, "legendary", 0xD32CE6); // same as Legendary item rarity in Dota 2
SetTrieValue(hTrie, "lemonchiffon", 0xFFFACD);
SetTrieValue(hTrie, "lightblue", 0xADD8E6);
SetTrieValue(hTrie, "lightcoral", 0xF08080);
SetTrieValue(hTrie, "lightcyan", 0xE0FFFF);
SetTrieValue(hTrie, "lightgoldenrodyellow", 0xFAFAD2);
SetTrieValue(hTrie, "lightgray", 0xD3D3D3);
SetTrieValue(hTrie, "lightgrey", 0xD3D3D3);
SetTrieValue(hTrie, "lightgreen", 0x99FF99);
SetTrieValue(hTrie, "lightpink", 0xFFB6C1);
SetTrieValue(hTrie, "lightsalmon", 0xFFA07A);
SetTrieValue(hTrie, "lightseagreen", 0x20B2AA);
SetTrieValue(hTrie, "lightskyblue", 0x87CEFA);
SetTrieValue(hTrie, "lightslategray", 0x778899);
SetTrieValue(hTrie, "lightslategrey", 0x778899);
SetTrieValue(hTrie, "lightsteelblue", 0xB0C4DE);
SetTrieValue(hTrie, "lightyellow", 0xFFFFE0);
SetTrieValue(hTrie, "lime", 0x00FF00);
SetTrieValue(hTrie, "limegreen", 0x32CD32);
SetTrieValue(hTrie, "linen", 0xFAF0E6);
SetTrieValue(hTrie, "magenta", 0xFF00FF);
SetTrieValue(hTrie, "maroon", 0x800000);
SetTrieValue(hTrie, "mediumaquamarine", 0x66CDAA);
SetTrieValue(hTrie, "mediumblue", 0x0000CD);
SetTrieValue(hTrie, "mediumorchid", 0xBA55D3);
SetTrieValue(hTrie, "mediumpurple", 0x9370D8);
SetTrieValue(hTrie, "mediumseagreen", 0x3CB371);
SetTrieValue(hTrie, "mediumslateblue", 0x7B68EE);
SetTrieValue(hTrie, "mediumspringgreen", 0x00FA9A);
SetTrieValue(hTrie, "mediumturquoise", 0x48D1CC);
SetTrieValue(hTrie, "mediumvioletred", 0xC71585);
SetTrieValue(hTrie, "midnightblue", 0x191970);
SetTrieValue(hTrie, "mintcream", 0xF5FFFA);
SetTrieValue(hTrie, "mistyrose", 0xFFE4E1);
SetTrieValue(hTrie, "moccasin", 0xFFE4B5);
SetTrieValue(hTrie, "mythical", 0x8847FF); // same as Mythical item rarity in Dota 2
SetTrieValue(hTrie, "navajowhite", 0xFFDEAD);
SetTrieValue(hTrie, "navy", 0x000080);
SetTrieValue(hTrie, "normal", 0xB2B2B2); // same as Normal item quality in TF2
SetTrieValue(hTrie, "oldlace", 0xFDF5E6);
SetTrieValue(hTrie, "olive", 0x9EC34F);
SetTrieValue(hTrie, "olivedrab", 0x6B8E23);
SetTrieValue(hTrie, "orange", 0xFFA500);
SetTrieValue(hTrie, "orangered", 0xFF4500);
SetTrieValue(hTrie, "orchid", 0xDA70D6);
SetTrieValue(hTrie, "palegoldenrod", 0xEEE8AA);
SetTrieValue(hTrie, "palegreen", 0x98FB98);
SetTrieValue(hTrie, "paleturquoise", 0xAFEEEE);
SetTrieValue(hTrie, "palevioletred", 0xD87093);
SetTrieValue(hTrie, "papayawhip", 0xFFEFD5);
SetTrieValue(hTrie, "peachpuff", 0xFFDAB9);
SetTrieValue(hTrie, "peru", 0xCD853F);
SetTrieValue(hTrie, "pink", 0xFFC0CB);
SetTrieValue(hTrie, "plum", 0xDDA0DD);
SetTrieValue(hTrie, "powderblue", 0xB0E0E6);
SetTrieValue(hTrie, "purple", 0x800080);
SetTrieValue(hTrie, "rare", 0x4B69FF); // same as Rare item rarity in Dota 2
SetTrieValue(hTrie, "red", 0xFF4040); // same as RED/Terrorist team color
SetTrieValue(hTrie, "rosybrown", 0xBC8F8F);
SetTrieValue(hTrie, "royalblue", 0x4169E1);
SetTrieValue(hTrie, "saddlebrown", 0x8B4513);
SetTrieValue(hTrie, "salmon", 0xFA8072);
SetTrieValue(hTrie, "sandybrown", 0xF4A460);
SetTrieValue(hTrie, "seagreen", 0x2E8B57);
SetTrieValue(hTrie, "seashell", 0xFFF5EE);
SetTrieValue(hTrie, "selfmade", 0x70B04A); // same as Self-Made item quality in TF2
SetTrieValue(hTrie, "sienna", 0xA0522D);
SetTrieValue(hTrie, "silver", 0xC0C0C0);
SetTrieValue(hTrie, "skyblue", 0x87CEEB);
SetTrieValue(hTrie, "slateblue", 0x6A5ACD);
SetTrieValue(hTrie, "slategray", 0x708090);
SetTrieValue(hTrie, "slategrey", 0x708090);
SetTrieValue(hTrie, "snow", 0xFFFAFA);
SetTrieValue(hTrie, "springgreen", 0x00FF7F);
SetTrieValue(hTrie, "steelblue", 0x4682B4);
SetTrieValue(hTrie, "strange", 0xCF6A32); // same as Strange item quality in TF2
SetTrieValue(hTrie, "tan", 0xD2B48C);
SetTrieValue(hTrie, "teal", 0x008080);
SetTrieValue(hTrie, "thistle", 0xD8BFD8);
SetTrieValue(hTrie, "tomato", 0xFF6347);
SetTrieValue(hTrie, "turquoise", 0x40E0D0);
SetTrieValue(hTrie, "uncommon", 0xB0C3D9); // same as Uncommon item rarity in Dota 2
SetTrieValue(hTrie, "unique", 0xFFD700); // same as Unique item quality in TF2
SetTrieValue(hTrie, "unusual", 0x8650AC); // same as Unusual item quality in TF2
SetTrieValue(hTrie, "valve", 0xA50F79); // same as Valve item quality in TF2
SetTrieValue(hTrie, "vintage", 0x476291); // same as Vintage item quality in TF2
SetTrieValue(hTrie, "violet", 0xEE82EE);
SetTrieValue(hTrie, "wheat", 0xF5DEB3);
SetTrieValue(hTrie, "white", 0xFFFFFF);
SetTrieValue(hTrie, "whitesmoke", 0xF5F5F5);
SetTrieValue(hTrie, "yellow", 0xFFFF00);
SetTrieValue(hTrie, "yellowgreen", 0x9ACD32);
return hTrie;
}
+915
View File
@@ -0,0 +1,915 @@
/**
* vim: set ts=4 :
* =============================================================================
* NativeVotes
* Copyright (C) 2011-2013 Ross Bemrose (Powerlord). 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/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*
* Version: $Id$
*/
#include <menus>
#include <sourcemod>
// NativeVotes 0.8 series
#if defined _nativevotes_included
#endinput
#endif
#define _nativevotes_included
#define CLIENT_DISCONNECTED -1
#define NATIVEVOTES_EXTEND "Extend current Map" /** Defined in TF2, but doesn't appear to be localized */
#define NATIVEVOTES_ALL_TEAMS -1 // Defined by TF2, may be the same in L4D/L4D2
#define NATIVEVOTES_TF2_ALL_TEAMS 0 // Defined by TF2, may be the same in L4D/L4D2
#define NATIVEVOTES_TEAM_UNASSIGNED 0 // For completeness, do not otherwise use
#define NATIVEVOTES_TEAM_SPECTATOR 1 // Spectators
#define NATIVEVOTES_TEAM_1 2 // RED/Survivors/Terrorists
#define NATIVEVOTES_TEAM_2 3 // BLU/Infected/Counter-Terrorists
#define NATIVEVOTES_SERVER_INDEX 99 // Defined by TF2, may be the same in L4D/L4D2
// These may seem backwards, but this is the order that the votes appear in the vote screen
#define NATIVEVOTES_VOTE_INVALID -1 /**< Vote was invalid, currently only valid internally */
#define NATIVEVOTES_VOTE_YES 0 /**< Vote was yes */
#define NATIVEVOTES_VOTE_NO 1 /**< Vote was no */
/*
The following MenuActions are supported. Arguments are also listed, as they differ slightly from the default
MenuAction_Start A menu has been started (nothing passed). Only exists for compat reasons.
MenuAction_Display A menu is about to be displayed (param1=client). If you choose to change the vote text,
To change the text, use RedrawVoteTitle()
If you do so, return 1 or _:Plugin_Changed Otherwise, return _:Plugin_Continue or 0.
MenuAction_Select An item was selected (param1=client, param2=item). For subplugin support.
MenuAction_End A vote has fully ended and the vote object is ready to be cleaned up
param1 is MenuEnd reason, either MenuEnd_VotingCancelled or MenuEnd_VotingDone
MenuAction_VoteEnd A vote sequence has succeeded (param1=chosen item)
This is not called if NativeVotes_SetResultCallback has been used on the vote.
You should call NativeVotes_DisplayPass or NativeVotes_DisplayPassEx after this
MenuAction_VoteStart A vote sequence has started (nothing passed). Use this instead of MenuAction_Start
MenuAction_VoteCancel A vote sequence has been cancelled (param1=reason)
MenuAction_DisplayItem Item text is being drawn to the display (param1=client, param2=item)
To change the text, use RedrawVoteItem().
If you do so, return 1 or _:Plugin_Changed. Otherwise, return _:Plugin_Continue or 0.
*/
#define NATIVEVOTES_ACTIONS_DEFAULT MenuAction_VoteStart|MenuAction_VoteCancel|MenuAction_VoteEnd|MenuAction_End
/**
* Vote types. These are mapped to translation strings and pass strings by VoteStart and VotePass handlers
*/
enum NativeVotesType
{
NativeVotesType_None = 0, /** Special placeholder for callvote with no arguments for NativeVotes_OnCallVote */
NativeVotesType_Custom_YesNo, /**< Yes/No, details are vote text. */
NativeVotesType_Custom_Mult, /**< TF2/CS:GO: Multiple-choice, details are vote text. */
NativeVotesType_ChgCampaign, /**< L4D/L4D2: Yes/No, details are campaign name */
NativeVotesType_ChgDifficulty, /**< L4D/L4D2: Yes/No, details are difficulty number in L4D/L4D2 */
NativeVotesType_ReturnToLobby, /**< L4D/L4D2: Yes/No, details are ignored */
NativeVotesType_AlltalkOn, /**< L4D2: Yes/No, details are ignored (handled internally by extension) */
NativeVotesType_AlltalkOff, /**< L4D2: Yes/No, details are ignored (handled internally by extension) */
NativeVotesType_Restart, /**< Yes/No, details are ignored */
NativeVotesType_Kick, /**< Yes/No, target is player userid, details are auto-set by target */
NativeVotesType_KickIdle, /**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
NativeVotesType_KickScamming, /**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
NativeVotesType_KickCheating, /**< TF2/CS:GO: Yes/No, target is player userid, details are auto-set by target */
NativeVotesType_ChgLevel, /**< Yes/No, details are level number in L4D/L4D2 or map name in TF2 */
NativeVotesType_NextLevel, /**< TF2/CS:GO: Yes/No, details are map name */
NativeVotesType_NextLevelMult, /**< TF2/CS:GO: Multiple-choice, details are ignored */
NativeVotesType_ScrambleNow, /**< TF2/CS:GO: Yes/No, details are ignored */
NativeVotesType_ScrambleEnd, /**< TF2: Yes/No, details are ignored */
NativeVotesType_ChgMission, /**< TF2: Yes/No, details are popfile */
NativeVotesType_SwapTeams, /**< CS:GO: Yes/No, details are ignored */
NativeVotesType_Surrender, /**< CS:GO: Yes/No, details are ignored */
NativeVotesType_Rematch, /**< CS:GO: Yes/No, details are ignored */
NativeVotesType_Continue, /**< CS:GO: Yes/No, details are ignored */
NativeVotesType_StartRound, /**< TF2: Yes/No, details are ignored */
NativeVotesType_Eternaween, /**< TF2: Yes/No, details are ignored */
NativeVotesType_AutoBalanceOn, /**< TF2: Yes/No, details are ignored */
NativeVotesType_AutoBalanceOff, /**< TF2: Yes/No, details are ignored */
NativeVotesType_ClassLimitsOn, /**< TF2: Yes/No, details are ignored */
NativeVotesType_ClassLimitsOff, /**< TF2: Yes/No, details are ignored */
};
enum NativeVotesPassType
{
NativeVotesPass_None = 0, /**< Special placeholder for error value */
NativeVotesPass_Custom, /**< Details are custom pass message */
NativeVotesPass_ChgCampaign, /**< L4D/L4D2: Details are campaign name */
NativeVotesPass_ChgDifficulty, /**< L4D/L4D2/TF2: Details are difficulty number in L4D/L4D2 and mission name in TF2 */
NativeVotesPass_ReturnToLobby, /**< L4D/L4D2: Details are ignored */
NativeVotesPass_AlltalkOn, /**< L4D2: Details are ignored */
NativeVotesPass_AlltalkOff, /**< L4D2: Details are ignored */
NativeVotesPass_Restart, /**< Details are ignored */
NativeVotesPass_Kick, /**< Details are player name */
NativeVotesPass_ChgLevel, /**< Details are level number in L4D/L4D2 or map name in TF2/CS:GO */
NativeVotesPass_NextLevel, /**< TF2/CS:GO: Details are map name */
NativeVotesPass_Extend, /**< TF2/CS:GO: Details are ignored */
NativeVotesPass_Scramble, /**< TF2/CS:GO: Details are ignored */
NativeVotesPass_ChgMission, /**< TF2: Details are popfile */
NativeVotesPass_SwapTeams, /**< CS:GO: Details are ignored */
NativeVotesPass_Surrender, /**< CS:GO: Details are ignored */
NativeVotesPass_Rematch, /**< CS:GO: Details are ignored */
NativeVotesPass_Continue, /**< CS:GO: Details are ignored */
NativeVotesPass_StartRound, /**< TF2: Details are ignored */
NativeVotesPass_Eternaween, /**< TF2: Details are ignored */
NativeVotesPass_AutoBalanceOn, /**< TF2: Yes/No, details are ignored */
NativeVotesPass_AutoBalanceOff, /**< TF2: Yes/No, details are ignored */
NativeVotesPass_ClassLimitsOn, /**< TF2: Yes/No, details are ignored */
NativeVotesPass_ClassLimitsOff, /**< TF2: Yes/No, details are ignored */
};
/**
* Reasons a vote was canceled. Not used for L4D/L4D2, as they don't care
*/
enum NativeVotesFailType
{
NativeVotesFail_Generic = 0, /**< Vote was generically cancelled. */
NativeVotesFail_Loses = 3, /**< No votes outnumbered Yes votes */
NativeVotesFail_NotEnoughVotes = 4, /**< Vote did not receive enough votes. */
};
/**
* Reasons a callvote command failed.
* This is provided as a convenience to plugin authors as it's not strictly part of the vote system
*/
enum NativeVotesCallFailType
{
NativeVotesCallFail_Generic = 0, /**< Generic fail. */
NativeVotesCallFail_Loading = 1, /**< L4D/L4D2: Players are still loading. */
NativeVotesCallFail_Recent = 2, /**< TF2/CS:GO: You can't call another vote yet: Argument is seconds until you can call another vote. */
NativeVotesCallFail_Disabled = 5, /**< TF2/CS:GO: Server has disabled that issue. */
NativeVotesCallFail_MapNotFound = 6, /**< TF2/CS:GO: Server does not have that map. */
NativeVotesCallFail_SpecifyMap = 7, /**< TF2/CS:GO: You must specify a map. */
NativeVotesCallFail_Failed = 8, /**< TF2/CS:GO: This vote failed recently. */
NativeVotesCallFail_WrongTeam = 9, /**< TF2/CS:GO: Team can't call this vote. */
NativeVotesCallFail_Waiting = 10, /**< TF2/CS:GO: Vote can't be called during Waiting For Players. */
NativeVotesCallFail_PlayerNotFound = 11, /**< TF2/CS:GO: Player to kick can't be found. Buggy in TF2. */
NativeVotesCallFail_Unknown = 11,
NativeVotesCallFail_CantKickAdmin = 12, /**< TF2/CS:GO: Can't kick server admin. */
NativeVotesCallFail_ScramblePending = 13, /**< TF2/CS:GO: Team Scramble is pending.. */
NativeVotesCallFail_Spectators = 14, /**< TF2/CS:GO: Spectators aren't allowed to call votes. */
NativeVotesCallFail_LevelSet = 15, /**< TF2/CS:GO: Next level already set. */
NativeVotesCallFail_MapNotValid = 16, /**< ???: Map is invalid. */
NativeVotesCallFail_KickTime = 17, /**< ???: Cannot kick for time. */
NativeVotesCallFail_KickDuringRound = 18, /**< ???: Cannot kick during a round. */
NativeVotesCallFail_AlreadyActive = 19 /**< TF2: Cannot call vote because modification (Eternaween) is already active (may not work) */
};
/*
* Is a specific vote type supported by this game?
*
* @param voteType Vote type
*/
native bool:NativeVotes_IsVoteTypeSupported(NativeVotesType:voteType);
/**
* Creates a new, empty vote.
*
* @param handler Function which will receive vote actions.
* @param voteType Vote type, cannot be changed after set
* @param actions Optionally set which actions to receive. Start,
* Cancel, and End will always be received regardless
* of whether they are set or not. They are also
* the only default actions.
* @return A new vote Handle on INVALID_HANDLE if a vote type is unsupported by this game.
*/
native Handle:NativeVotes_Create(MenuHandler:handler, NativeVotesType:voteType,
MenuAction:actions=NATIVEVOTES_ACTIONS_DEFAULT);
/**
* Frees all handles related to a vote.
*
* THIS MUST BE CALLED TO AVOID HANDLE LEAKS
*
* @param vote Vote handle
* @noreturn
*/
native Handle:NativeVotes_Close(Handle:vote);
/**
* Appends a new item to the end of a vote. Only valid for Multiple Choice votes
*
* @param vote NativeVotes Handle.
* @param info Item information string.
* @return True on success, false on failure.
* @error Invalid Handle, item limit reached, or if the vote is not multiple choice.
*/
native bool:NativeVotes_AddItem(Handle:vote, const String:info[], const String:display[]);
/**
* Inserts an item into the menu before a certain position; the new item will
* be at the given position and all next items pushed forward.
*
* @param vote Vote Handle.
* @param position Position, starting from 0.
* @param info Item information string.
* @return True on success, false on failure.
* @error Invalid Handle or vote position, or if the vote is not multiple choice.
*/
native bool:NativeVotes_InsertItem(Handle:vote, position, const String:info[], const String:display[]);
/**
* Removes an item from the menu.
*
* @param vote Vote Handle.
* @param position Position, starting from 0.
* @return True on success, false on failure.
* @error Invalid Handle or vote position, or if the vote is not multiple choice.
*/
native bool:NativeVotes_RemoveItem(Handle:vote, position);
/**
* Removes all items from a vote.
*
* @param vote Vote Handle.
* @noreturn
* @error Invalid Handle or vote position, or if the vote is not multiple choice.
*/
native NativeVotes_RemoveAllItems(Handle:vote);
/**
* Retrieves information about a vote item.
*
* @param vote Vote Handle.
* @param position Position, starting from 0.
* @param infoBuf Info buffer.
* @param infoBufLen Maximum length of the info buffer.
* @return True on success, false if position is invalid.
* @error Invalid Handlem
*/
native bool:NativeVotes_GetItem(Handle:vote,
position,
String:infoBuf[],
infoBufLen,
String:dispBuf[]="",
dispBufLen=0);
/**
* Returns the number of items in a vote.
*
* @param vote Vote Handle.
* @return Number of items in the vote.
* @error Invalid Handle.
*/
native NativeVotes_GetItemCount(Handle:vote);
/**
* Sets the vote's details for votes that support details
* If this is a custom vote, use NativeVotes_SetTitle to set the vote's title.
*
* @param vote Vote Handle.
* @param argument Details string. See vote types for what details stands for.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_SetDetails(Handle:vote, const String:argument[]);
/**
* Returns the text of a vote's details if set.
*
* @param vote Vote Handle.
* @param buffer Buffer to store details.
* @param maxlength Maximum length of the buffer.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_GetDetails(Handle:vote, String:buffer[], maxlength);
/**
* Sets a custom vote's title
*
* @param vote Vote Handle.
* @param title Vote title string.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_SetTitle(Handle:vote, const String:argument[]);
/**
* Return the vote's Title.
* If not set, returns Details instead.
* This behavior is for compatibility with NativeVotes 0.8.0 and below.
*
* @param vote Vote Handle.
* @param buffer Buffer to store title.
* @param maxlength Maximum length of the buffer.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_GetTitle(Handle:vote, String:buffer[], maxlength);
/**
* Sets the target userid for vote
* This should be used instead of SetArgument for votes that target players
*
* Also sets target SteamID
*
* @param vote Vote Handle.
* @param userid Client index of target player
* @param setDetails If true, also sets vote details to client's name
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_SetTarget(Handle:vote, client, bool:setDetails=true);
/**
* Returns the userid of a vote's target
*
* @param vote Vote Handle.
* @return Client index of target player or 0 for no target or target disconnected since vote started
* @error Invalid Handle.
*/
native NativeVotes_GetTarget(Handle:vote);
/**
* Get the Steam ID of a vote's target
* Useful if the target has disconnect from the server during a vote.
* This was added in specifically for Kick/Ban votes
*
* @param vote Vote Handle.
* @param buffer Buffer to store steamId. Should be 19 characters or more..
* @param maxlength Maximum length of the buffer.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_GetTargetSteam(Handle:vote, String:buffer[], maxlength);
/**
* Returns whether a vote is in progress.
*
* @return True if a NativeVotes vote is in progress, false otherwise.
*/
native bool:NativeVotes_IsVoteInProgress();
/**
* Returns a style's maximum items
*
* @return Maximum items
*/
native NativeVotes_GetMaxItems();
/**
* Sets a vote's option flags.
*
* If a certain bit is not supported, it will be stripped before being set.
*
* NOTE: This is currently unused, but reserved for future use.
*
* @param menu Builtin Vote Handle.
* @param flags A new bitstring of VOTEFLAG bits.
* @noreturn
* @error Invalid Handle.
*/
native NativeVotes_SetOptionFlags(Handle:vote, flags);
/**
* Retrieves a menu's option flags.
*
* NOTE: This is currently unused, but reserved for future use.
*
* @param vote Builtin Vote Handle.
* @return A bitstring of VOTEFLAG bits.
* @error Invalid Handle.
*/
native NativeVotes_GetOptionFlags(Handle:vote);
/**
* Cancels the vote in progress.
*
* @noreturn
* @error If no vote is in progress.
*/
native NativeVotes_Cancel();
/**
* Callback for when a vote has ended and results are available.
*
* Due to SourceMod Forward limitations in plugins, multi-dimension arrays can't be passed
* to forwards. This means we have to split the client_info and item_info arrays into
* their components.
*
* @param vote The vote being voted on.
* @param num_votes Number of votes tallied in total.
* @param num_clients Number of clients who could vote.
* @param client_indexes Array of client indexes. Parallel with client_votes.
* @param client_votes Array of client votes. Parallel with client_indexes.
* @param num_items Number of unique items that were selected.
* @param item_indexes Array of vote item indexes. Parallel with item_votes..
* @param item_votes Array of vote vote counts. Parallel with item_indexes.
* @noreturn
*/
functag public NativeVotes_VoteHandler(Handle:vote,
num_votes,
num_clients,
const client_indexes[],
const client_votes[],
num_items,
const item_indexes[],
const item_votes[]);
/**
* Function to convert client/vote arrays into their two-dimensional versions,
* which can then be passed to a standard vote handler.
*
* client_info and item_info are the resulting arrays.
*
* Note: When declaring client_info and item_info, you'll probably want to declare them like this:
* new client_info[num_clients][2];
* new item_info[num_items][2];
*
* @param num_clients Number of clients who could vote.
* @param client_indexes Array of client indexes. Parallel with client_votes.
* @param client_votes Array of client votes. Parallel with client_indexes.
* @param num_items Number of unique items that were selected.
* @param item_indexes Array of vote item indexes. Parallel with item_votes..
* @param item_votes Array of vote vote counts. Parallel with item_indexes.
* @param client_info Array of clients. Use VOTEINFO_CLIENT_ defines.
* @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM
* defines.
* @noreturn
*/
stock NativeVotes_FixResults(num_clients,
const client_indexes[],
const client_votes[],
num_items,
const item_indexes[],
const item_votes[],
client_info[][2],
item_info[][2])
{
for (new i = 0; i < num_clients; ++i)
{
client_info[i][VOTEINFO_CLIENT_INDEX] = client_indexes[i];
client_info[i][VOTEINFO_CLIENT_ITEM] = client_votes[i];
}
for (new i = 0; i < num_items; ++i)
{
item_info[i][VOTEINFO_ITEM_INDEX] = item_indexes[i];
item_info[i][VOTEINFO_ITEM_VOTES] = item_votes[i];
}
}
/**
* Sets an advanced vote handling callback. If this callback is set,
* MenuAction_VoteEnd will not be called.
*
* @param vote NativeVotes Handle.
* @param callback Callback function.
* @noreturn
* @error Invalid Handle or callback.
*/
native NativeVotes_SetResultCallback(Handle:vote, NativeVotes_VoteHandler:callback);
/**
* Returns the number of seconds you should "wait" before displaying
* a public vote. This number is the time remaining until
* (last_vote + sm_vote_delay).
*
* @return Number of seconds to wait, or 0 for none.
*/
native NativeVotes_CheckVoteDelay();
/**
* Returns whether a client is in the pool of clients allowed
* to participate in the current vote. This is determined by
* the client list passed to NativeVotes_Display().
*
* @param client Client index.
* @return True if client is allowed to vote, false otherwise.
* @error If no vote is in progress or client index is invalid.
*/
native bool:NativeVotes_IsClientInVotePool(client);
/**
* Redraws the current vote to a client in the voting pool.
*
* @param client Client index.
* @param revotes True to allow revotes, false otherwise.
* @return True on success, false if the client is in the vote pool
* but cannot vote again.
* @error No vote in progress, client is not in the voting pool,
* or client index is invalid.
*/
native bool:NativeVotes_RedrawClientVote(client, bool:revotes=true);
/**
* Retrieve the vote type
*
* @param vote NativeVotes Handle.
* @return The built in vote type
* @error Invalid Handle
*/
native NativeVotesType:NativeVotes_GetType(Handle:vote);
/**
* Set the team this vote is for, or NATIVEVOTES_ALL_TEAMS for all teams.
*
* Defaults to NATIVEVOTES_ALL_TEAMS if not explicitly set.
*
* @param vote NativeVotes Handle.
* @param team Team number this vote is for
* @noreturn
* @error Invalid Handle
*/
native NativeVotes_SetTeam(Handle:vote, team);
/**
* Retrieve the team this vote is for
*
* @param vote NativeVotes Handle.
* @return Team index or NATIVEVOTES_ALL_TEAMS for all teams.
* @error Invalid Handle
*/
native NativeVotes_GetTeam(Handle:vote);
/**
* Set the client index of the player who initiated the vote.
* Use NATIVEVOTES_SERVER_INDEX if initiated by the server itself.
*
* Defaults to NATIVEVOTES_SERVER_INDEX if not explicitly set.
*
* @param vote NativeVotes Handle.
* @param client Client who initiated the vote or NATIVEVOTES_SERVER_INDEX
* @noreturn
* @error Invalid Handle
*/
native NativeVotes_SetInitiator(Handle:vote, client);
/**
* Retrieve the client index of the player who initiated the vote or NATIVEVOTES_SERVER_INDEX if
* initiated by the server itself.
*
* @param Vote handle
* @return Client index or NATIVEVOTES_SERVER_INDEX
* @error Invalid Handle
*/
native NativeVotes_GetInitiator(Handle:vote);
/**
* Broadcasts a vote to a list of clients. The most selected item will be
* returned through MenuAction_VoteEnd. On a tie, a random item will be returned
* from a list of the tied items.
*
* Note that MenuAction_VoteStart, MenuAction_VoteCancel, MenuAction_VoteEnd, and MenuAction_End are all
* default callbacks and do not need to be enabled.
*
* @param vote Vote Handle.
* @param clients Array of clients to broadcast to.
* @param numClients Number of clients in the array.
* @param time Maximum time to leave menu on the screen.
* @return True on success, false if a vote is already in progress.
* @error Invalid Handle, or a vote is already in progress.
*/
native bool:NativeVotes_Display(Handle:vote, clients[], numClients, time);
/**
* Sends a vote menu to all clients. See NativeVotes_Display() for more information.
*
* @param vote Vote Handle.
* @param time Maximum time to leave menu on the screen.
* @return True on success, false if this menu already has a vote session
* in progress.
* @error Invalid Handle, or a vote is already in progress.
*/
stock bool:NativeVotes_DisplayToAll(Handle:vote, time)
{
new total = 0;
decl players[MaxClients];
for (new i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i) || IsFakeClient(i))
{
continue;
}
players[total++] = i;
}
return NativeVotes_Display(vote, players, total, time);
}
/**
* Sends a vote menu to a single team. See NativeVotes_Display() for more information.
*
* @param vote Vote Handle.
* @param team Team to send vote to. 1 = spectators, 2 = RED/Survivors/Terrorists, 3 = BLU/Infected/Counter-Terrorists
* @param time Maximum time to leave menu on the screen.
* @return True on success, false if this menu already has a vote session
* in progress.
* @error Invalid Handle, or a vote is already in progress.
*/
stock bool:NativeVotes_DisplayToTeam(Handle:vote, team, time)
{
NativeVotes_SetTeam(vote, team);
new total;
decl players[MaxClients];
for (new i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i) || IsFakeClient(i) || (GetClientTeam(i) != team))
{
continue;
}
players[total++] = i;
}
return NativeVotes_Display(vote, players, total, time);
}
/**
* Sends a vote menu to all clients who are not spectators or waiting to choose a team. See NativeVotes_Display() for more information.
*
* @param vote Vote Handle.
* @param time Maximum time to leave menu on the screen.
* @return True on success, false if this menu already has a vote session
* in progress.
* @error Invalid Handle, or a vote is already in progress.
*/
stock bool:NativeVotes_DisplayToAllNonSpectators(Handle:vote, time)
{
new total;
decl players[MaxClients];
for (new i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i) || IsFakeClient(i) || (GetClientTeam(i) < 2))
{
continue;
}
players[total++] = i;
}
return NativeVotes_Display(vote, players, total, time);
}
/**
* Display vote passed screen
*
* You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
* to hide the vote screen for users who didn't vote, and to clear out their selection
* for the next vote.
*
* @param vote Vote handle
* @param details Normally the item that won the vote or format string. Also used for custom vote winners
* @param ... Variable number of format parameters.
* @noreturn
*/
native NativeVotes_DisplayPass(Handle:vote, const String:details[]="");
/**
* Display vote passed screen with custom text to a single user
*
* You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
* to hide the vote screen for users who didn't vote, and to clear out their selection
* for the next vote.
*
* @param vote Vote handle
* @param client client to display to
* @param format A format string.
* @param any Variable number of format parameters
* @noreturn
*/
native NativeVotes_DisplayPassCustomToOne(Handle:vote, client, const String:format[], any:...);
/**
* Display vote passed screen with custom text
*
* You MUST call one of the NativeVotesDisplayPass* or NativeVotes_DisplayFail functions
* to hide the vote screen for users who didn't vote, and to clear out their selection
* for the next vote.
*
* @param vote Vote handle
* @param format A format string.
* @param any Variable number of format parameters
* @noreturn
*/
stock NativeVotes_DisplayPassCustom(Handle:vote, const String:format[], any:...)
{
decl String:buffer[192];
for (new i = 1; i <= MaxClients; ++i)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, sizeof(buffer), format, 3);
NativeVotes_DisplayPassCustomToOne(vote, i, "%s", buffer);
}
}
}
/**
* Display vote passed screen with a custom type.
*
* A sample usage of this would be if Extend won an RTV vote: NativeVotes_DisplayPassEx(vote, NativeVotesPass_Extend, map);
*
* You MUST call one of NativeVotes_DisplayPass, NativeVotes_DisplayPassEx,
* or NativeVotes_DisplayFail to hide the vote screen for users who didn't vote
* and to clear out their selection for the next vote.
*
* #param vote Vote handle
* @param passType The pass screen to display
* @param details Normally the item that won the vote. Also used for custom vote winners
* @noreturn
*/
native NativeVotes_DisplayPassEx(Handle:vote, NativeVotesPassType:passType, const String:details[]="");
/**
* Display failure screen.
*
* You MUST call one of NativeVotes_DisplayPass, NativeVotes_DisplayPassEx,
* or NativeVotes_DisplayFail to hide the vote screen for users who didn't vote,
* and to clear out their selection for the next vote.
*
* @param reason Vote failure reason from NativeVotesFailType enum
* @noreturn
*/
native NativeVotes_DisplayFail(Handle:vote, NativeVotesFailType:reason=NativeVotesFail_Generic);
/**
* Quick stock to determine whether voting is allowed. This doesn't let you
* fine-tune a reason for not voting, so it's not recommended for lazily
* telling clients that voting isn't allowed.
*
* @return True if voting is allowed, false if voting is in progress
* or the cooldown is active.
*/
stock bool:NativeVotes_IsNewVoteAllowed()
{
if (NativeVotes_IsVoteInProgress() || NativeVotes_CheckVoteDelay() != 0)
{
return false;
}
return true;
}
/**
* Used when callvote is called with no arguments.
*
* This is used to configure the VoteSetup usermessage on TF2 and CS:GO
*
* @param client Client, in case the votes are restricted by client
* @param voteTypes Populate this array with the vote types this server supports
* Custom and multiple choice votes are not supported from
* the GUI and are thus ignored.
* @return Plugin_Continue to allow the server itself (or another plugin) to process the callvote
* Plugin_Changed if you're changing the voteTypes,
* Plugin_Handled to return a blank VoteSetup usermessage
* Plugin_Stop to prevent VoteSetup usermessage (not recommended)
*/
//functag public Action:NativeVotes_CallVoteSetupHandler(client, NativeVotesType:voteTypes[]);
/**
* Forward for "callvote" handling
*
* You should respond to this by starting a vote or by calling NativeVotes_DisplayCallVoteFail
*
* @param client Client
* @param voteType Type of vote being called. This will NEVER be a multiple-choice or custom vote.
* @param voteArgument Vote argument or blank if the vote type has no argument.
* @param target target userid for kick votes or 0 for all other votes
* @return Plugin_Continue to allow the server itself (or another plugin) to process the callvote
* Plugin_Handled if you processed this vote type
* Plugin_Stop to block the vote type (not recommended)
*/
//functag public Action:NativeVotes_CallVoteHandler(client, NativeVotesType:voteType, const String:voteArgument[], target);
/**
* Register a plugin as a vote manager.
* This is used to abstract away the details of the callvote command.
*
* @param callHandler Handler for callvote commands.
* @param setupHandler Handler to override the which vote types your server supports. Only useful on TF2 and CS:GO.
* @noreturn
*/
//native NativeVotes_RegisterVoteManager(NativeVotes_CallVoteHandler:callHandler, NativeVotes_CallVoteSetupHandler:setupHandler=INVALID_FUNCTION);
/**
* Send a call vote fail screen to a user
* Used to respond to a callvote with invalid arguments or for other reasons
* (such as trying to target an admin for a kick/ban vote)
*
* @param client The client to display the fail screen to
* @param reason A vote call fail reason
* @param time For NativeVotesCallFail_Recent, the number of seconds until the vote
* can be called again
*/
native NativeVotes_DisplayCallVoteFail(client, NativeVotesCallFailType:reason, time);
/**
* Redraws the vote title from inside a MenuAction_Display callback
* Not supported on L4D
*
* @param text Vote title to draw
* @error If called from outside MenuAction_Display
* @return Plugin_Changed if the change is allowed, Plugin_Continue if it isn't.
*/
native Action:NativeVotes_RedrawVoteTitle(const String:text[]);
/**
* Redraws the vote text from inside a MenuAction_DisplayItem callback.
* Only supported on multiple-choice votes
*
* @param text Vote text to draw.
* @error If called from outside MenuAction_DisplayItem
* @return Plugin_Changed if the change is allowed, Plugin_Continue if it isn't.
*/
native Action:NativeVotes_RedrawVoteItem(const String:text[]);
/**
* Retrieves voting information from MenuAction_VoteEnd.
*
* @param param2 Second parameter of MenuAction_VoteEnd.
* @param winningVotes Number of votes received by the winning option.
* @param totalVotes Number of total votes received.
* @noreturn
*/
stock NativeVotes_GetInfo(param2, &winningVotes, &totalVotes)
{
winningVotes = param2 & 0xFFFF;
totalVotes = param2 >> 16;
}
/**
* Do not edit below this line!
*/
public SharedPlugin:__pl_nativevotes =
{
name = "nativevotes",
file = "nativevotes.smx",
#if defined REQUIRE_PLUGINS
required = 1,
#else
required = 0,
#endif
};
public __pl_nativevotes_SetNTVOptional()
{
MarkNativeAsOptional("NativeVotes_IsVoteTypeSupported");
MarkNativeAsOptional("NativeVotes_Create");
MarkNativeAsOptional("NativeVotes_Close");
MarkNativeAsOptional("NativeVotes_AddItem");
MarkNativeAsOptional("NativeVotes_InsertItem");
MarkNativeAsOptional("NativeVotes_RemoveItem");
MarkNativeAsOptional("NativeVotes_RemoveAllItems");
MarkNativeAsOptional("NativeVotes_GetItem");
MarkNativeAsOptional("NativeVotes_GetItemCount");
MarkNativeAsOptional("NativeVotes_SetDetails");
MarkNativeAsOptional("NativeVotes_GetDetails");
MarkNativeAsOptional("NativeVotes_SetTitle");
MarkNativeAsOptional("NativeVotes_GetTitle");
MarkNativeAsOptional("NativeVotes_SetTarget");
MarkNativeAsOptional("NativeVotes_GetTarget");
MarkNativeAsOptional("NativeVotes_GetTargetSteam");
MarkNativeAsOptional("NativeVotes_IsVoteInProgress");
MarkNativeAsOptional("NativeVotes_GetMaxItems");
MarkNativeAsOptional("NativeVotes_SetOptionFlags");
MarkNativeAsOptional("NativeVotes_GetOptionFlags");
MarkNativeAsOptional("NativeVotes_Cancel");
MarkNativeAsOptional("NativeVotes_SetResultCallback");
MarkNativeAsOptional("NativeVotes_CheckVoteDelay");
MarkNativeAsOptional("NativeVotes_IsClientInVotePool");
MarkNativeAsOptional("NativeVotes_RedrawClientVote");
MarkNativeAsOptional("NativeVotes_RedrawClientVote");
MarkNativeAsOptional("NativeVotes_GetType");
MarkNativeAsOptional("NativeVotes_SetTeam");
MarkNativeAsOptional("NativeVotes_GetTeam");
MarkNativeAsOptional("NativeVotes_SetInitiator");
MarkNativeAsOptional("NativeVotes_GetInitiator");
MarkNativeAsOptional("NativeVotes_Display");
MarkNativeAsOptional("NativeVotes_DisplayPass");
MarkNativeAsOptional("NativeVotes_DisplayPassCustomToOne");
MarkNativeAsOptional("NativeVotes_DisplayPassEx");
MarkNativeAsOptional("NativeVotes_DisplayFail");
MarkNativeAsOptional("NativeVotes_RegisterVoteManager");
MarkNativeAsOptional("NativeVotes_DisplayCallVoteFail");
MarkNativeAsOptional("NativeVotes_RedrawVoteTitle");
MarkNativeAsOptional("NativeVotes_RedrawVoteItem");
}
+40
View File
@@ -0,0 +1,40 @@
#if defined _OutputInfo_Included
#endinput
#endif
#define _OutputInfo_Included
native GetOutputCount(int Entity, const char[] sOutput);
native GetOutputTarget(int Entity, const char[] sOutput, int Index, char[] sTarget);
native GetOutputTargetInput(int Entity, const char[] sOutput, int Index, char[] sTargetInput);
native GetOutputParameter(int Entity, const char[] sOutput, int Index, char[] sParameter);
native Float:GetOutputDelay(int Entity, const char[] sOutput, int Index);
/**
* 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");
}
#endif
+36
View File
@@ -0,0 +1,36 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: zombiereloaded.inc
* Type: Include
* Description: Main API include file.
* Notes: Include this file to include the whole ZR API.
*
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
*
* 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
* (at your option) 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 _zr_included
#endinput
#endif
#define _zr_included
#include <zr/infect.zr>
#include <zr/respawn.zr>
#include <zr/class.zr>
+127
View File
@@ -0,0 +1,127 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: class.zr.inc
* Type: Include
* Description: Player class API.
*
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
*
* 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
* (at your option) 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/>.
*
* ============================================================================
*/
/**
* @section Internal class cache types. Specifies which class data to access.
*/
#define ZR_CLASS_CACHE_ORIGINAL 0 /** Original class data loaded from file. */
#define ZR_CLASS_CACHE_MODIFIED 1 /** Default cache. Class data modified by eventual multipliers, map configs, commands, etc. */
#define ZR_CLASS_CACHE_PLAYER 2 /** Current player class attributes. The class index parameter is used as client index when reading from this cache. */
/**
* @endsection
*/
/**
* Results when selecting a class for a player.
*/
enum ClassSelectResult
{
ClassSelected_NoChange, /** No class change was necessary (class already selected). */
ClassSelected_Instant, /** Class was instantly changed. */
ClassSelected_NextSpawn /** Class will be used next spawn. */
}
/**
* Returns whether a class index is valid or not.
*
* @param classIndex Class index to validate.
*
* @return True if valid, false otherwise.
*/
native bool:ZR_IsValidClassIndex(classIndex);
/**
* Gets the currently active class index that the player is using.
*
* @param client The client index.
*
* @return The active class index.
*/
native bool:ZR_GetActiveClass(client);
/**
* Gets the current human class index that the player is using.
*
* @param client The client index.
*
* @return The human class index.
*/
native bool:ZR_GetHumanClass(client);
/**
* Gets the current zombie class index that the player is using.
*
* @param client The client index.
*
* @return The zombie class index.
*/
native bool:ZR_GetZombieClass(client);
/**
* Selects a class for a player.
*
* Human class attribute may be instantly applied if player is alive, human and
* instant class change is enabled. Otherwise only the selected index will be
* updated for next spawn.
*
* Class selection will be saved in client cookies if enabled.
*
* @param client Client index.
* @param classIndex Class index.
* @param applyIfPossible Optional. Apply class attributes if conditions allow
* it. Default is true.
* @param saveIfEnabled Optional. Save class selection in client cookies if
* enabled. Default is true.
*
* @return Class selection result. See enum ClassSelectResult.
*/
native ClassSelectResult:ZR_SelectClientClass(client, classIndex, bool:applyIfPossible = true, bool:saveIfEnabled = true);
/**
* Gets the class index of the class with the specified name.
*
* Note: This search is linear and probably won't perform well in large loops.
*
* @param className Class name to search for.
* @param cacheType Optional. Specifies which class cache to read from,
* except player cache.
*
* @return Class index, or -1 if none found.
*/
native ZR_GetClassByName(const String:className[], cacheType = ZR_CLASS_CACHE_MODIFIED);
/**
* Gets the class name displayed in the class menu.
*
* @param index Index of the class in a class cache or a client index,
* depending on the cache type specified.
* @param buffer The destination string buffer.
* @param maxlen The length of the destination string buffer.
* @param cacheType Optional. Specifies which class cache to read from.
* @return Number of cells written. -1 on error.
*/
native ZR_GetClassDisplayName(index, String:buffer[], maxlen, cacheType = ZR_CLASS_CACHE_MODIFIED);
+123
View File
@@ -0,0 +1,123 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: infect.zr.inc
* Type: Include
* Description: Infect-related natives/forwards.
*
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
*
* 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
* (at your option) 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/>.
*
* ============================================================================
*/
/**
* Returns true if the player is a zombie, false if not.
*
* @param client The client index.
*
* @return True if zombie, false if not.
* @error Invalid client index, not connected or not alive.
*/
native bool:ZR_IsClientZombie(client);
/**
* Returns true if the player is a human, false if not.
*
* @param client The client index.
*
* @return True if human, false if not.
* @error Invalid client index, not connected or not alive.
*/
native bool:ZR_IsClientHuman(client);
/**
* Infects a player.
*
* Note: If the player already is a zombie, the player will be re-infected.
*
* @param client The client to infect.
* @param attacker (Optional) The attacker who did the infect.
* @param motherInfect (Optional) Infect as a mother zombie.
* @param respawnOverride (Optional) Set to true to override respawn cvar.
* @param respawn (Optional) Value to override with.
*
* @error Invalid client index, not connected or not alive.
*/
native ZR_InfectClient(client, attacker = -1, bool:motherInfect = false, bool:respawnOverride = false, bool:respawn = false);
/**
* Turns a zombie back into a human.
*
* Note: If the player already is a human, this code will still run as the
* player was a zombie.
*
* @param client The client to make human.
* @param respawn Teleport client back to spawn.
* @param protect Start spawn protection on client.
*
* @error Invalid client index, not connected or not alive.
*/
native ZR_HumanClient(client, bool:respawn = false, bool:protect = false);
/**
* Called when a player is about to become a zombie.
* Here you can modify any variable or block the infection entirely.
*
* @param client The client index.
* @param attacker The the infecter. (-1 if there is no infecter)
* @param motherInfect If the client is becoming a mother zombie.
* @param respawnOverride True if the respawn cvar is being overridden.
* @param respawn The value that respawn is being overridden with.
*
* @return Plugin_Handled to block infection. Anything else
* (like Plugin_Continue) to allow infection.
*/
forward Action:ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:respawnOverride, &bool:respawn);
/**
* Called after a player has become a zombie.
*
* @param client The client that was infected.
* @param attacker The the infecter. (-1 if there is no infecter)
* @param motherInfect If the client is a mother zombie.
* @param respawnOverride True if the respawn cvar was overridden.
* @param respawn The value that respawn was overridden with.
*/
forward ZR_OnClientInfected(client, attacker, bool:motherInfect, bool:respawnOverride, bool:respawn);
/**
* Called when a player is about to become a human. (Through an admin command).
* Here you can modify any variable or block the action entirely.
*
* @param client The client index.
* @param respawn True if the client was respawned, false if not.
* @param protect True if the client spawn protected, false if not.
*
* @return Plugin_Handled to block infection. Anything else
* (like Plugin_Continue) to allow acion.
*/
forward Action:ZR_OnClientHuman(&client, &bool:respawn, &bool:protect);
/**
* Called after a player has become a human. (Through an admin command.)
*
* @param client The client index.
* @param respawn Whether the client was respawned.
* @param protect Whether the client has spawn protection.
*/
forward ZR_OnClientHumanPost(client, bool:respawn, bool:protect);
+95
View File
@@ -0,0 +1,95 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: respawn.zr.inc
* Type: Include
* Description: Infect-related natives/forwards.
*
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
*
* 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
* (at your option) 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/>.
*
* ============================================================================
*/
/**
* Conditions for respawning players.
*/
enum ZR_RespawnCondition
{
ZR_Repsawn_Default = -1, /** Let ZR decide according to its settings. */
ZR_Respawn_Human = 0, /** Respawn as a human. */
ZR_Respawn_Zombie, /** Respawn as a zombie. */
ZR_Respawn_ZombieIfSuicide /** Respawn as a zombie if killed by world damage. */
}
/**
* Spawns a player into the round.
*
* @param client The client index.
* @param condition Optional. Set respawn condition, defaults to current
* ZR settings. See ZR_RespawnCondition for details.
* @error Invalid client index, not connected or already alive.
*/
native ZR_RespawnClient(client, ZR_RespawnCondition:condition = ZR_Repsawn_Default);
/**
* Called right before ZR is about to respawn a player.
* Here you can modify any variable or stop the action entirely.
*
* @param client The client index.
* @param condition Respawn condition. See ZR_RespawnCondition for
* details.
*
* @return Plugin_Handled to block respawn.
*/
forward Action:ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition);
/**
* Called after ZR respawned a player.
*
* @param client The client index.
* @param condition Current condition of the respawned player. See
* ZR_RespawnCondition for details.
*/
forward ZR_OnClientRespawned(client, ZR_RespawnCondition:condition);
/**
* Set if a player died by a suicide or world damage.
* Note: This will change the respawn condition.
* Note: This value is reset to default by ZR when a zombie player dies.
*
* @param client The client index.
* @param suicide True to say the player suicided, false if killed by another
* player.
*
* @error Invalid client index or not connected.
*/
native ZR_SetKilledByWorld(client, bool:suicide);
/**
* Get whether the player died by a suicide or world damage.
*
* Note: This value is only valid after death event, and before respawn.
*
* @param client The client index.
*
* @return True if the player died by suicide, false if killed by
* another player.
* @error Invalid client index or not connected.
*/
native bool:ZR_GetKilledByWorld(client);