diff --git a/addons/sourcemod/scripting/fistful_of_zombies.sp b/addons/sourcemod/scripting/fistful_of_zombies.sp index 8128667..8434cb5 100644 --- a/addons/sourcemod/scripting/fistful_of_zombies.sp +++ b/addons/sourcemod/scripting/fistful_of_zombies.sp @@ -12,7 +12,10 @@ #include #include #include -#include +#include +#include +#include +#include #undef REQUIRE_EXTENSIONS #tryinclude @@ -328,7 +331,7 @@ void PlayerSpawnDelay(int userid) int client = GetClientOfUserId(userid); if (!IsEnabled()) return; - if (!Client_IsIngame(client)) return; + if (!IsClientIngame(client)) return; if (!IsPlayerAlive(client)) return; g_GivenPrimary[client] = false; @@ -363,7 +366,7 @@ void BecomeZombieDelay(int userid) int client = GetClientOfUserId(userid); if (!IsEnabled()) return; - if (!Client_IsIngame(client)) return; + if (!IsClientIngame(client)) return; JoinZombieTeam(client); } @@ -373,7 +376,7 @@ Action Timer_GivePrimaryWeapon(Handle timer, int userid) int client = GetClientOfUserId(userid); if (!IsEnabled()) return Plugin_Handled; - if (!Client_IsIngame(client)) return Plugin_Handled; + if (!IsClientIngame(client)) return Plugin_Handled; if (IsZombie(client)) return Plugin_Handled; if (g_GivenPrimary[client]) return Plugin_Handled; char weapon[MAX_KEY_LENGTH]; @@ -393,7 +396,7 @@ Action Timer_GiveSecondaryWeapon(Handle timer, int userid) int client = GetClientOfUserId(userid); if (!IsEnabled()) return Plugin_Handled; - if (!Client_IsIngame(client)) return Plugin_Handled; + if (!IsClientIngame(client)) return Plugin_Handled; if (IsZombie(client)) return Plugin_Handled; if (g_GivenSecondary[client]) return Plugin_Handled; @@ -474,8 +477,8 @@ Action Hook_OnTakeDamage(int victim, int& attacker, int& inflictor, float damagePosition[3]) { if (!IsEnabled()) return Plugin_Continue; - if (!Client_IsIngame(attacker)) return Plugin_Continue; - if (!Client_IsIngame(victim)) return Plugin_Continue; + if (!IsClientIngame(attacker)) return Plugin_Continue; + if (!IsClientIngame(victim)) return Plugin_Continue; if (attacker == victim) return Plugin_Continue; if (weapon > 0 && IsHuman(victim) && IsZombie(attacker)) @@ -504,7 +507,7 @@ Action Hook_OnTakeDamage(int victim, int& attacker, int& inflictor, Action Command_JoinTeam(int client, const char[] command, int argc) { if (!IsEnabled()) return Plugin_Continue; - if (!Client_IsIngame(client)) return Plugin_Continue; + if (!IsClientIngame(client)) return Plugin_Continue; char arg[32]; GetCmdArg(1, arg, sizeof(arg)); @@ -1067,7 +1070,7 @@ bool InfectionStep(int& client, float& interval, int& currentCall) // this steps through the process of an infected human to a zombie takes // 300 steps or 30 seconds if (!IsEnabled()) return false; - if (!Client_IsIngame(client)) return false; + if (!IsClientIngame(client)) return false; if (!IsPlayerAlive(client)) return false; if (!IsHuman(client)) return false; if (GetRoundState() != RoundActive) return false; @@ -1124,7 +1127,7 @@ void RewardSurvivingHumans() for (int client = 1; client <= MaxClients; client++) { - if (!Client_IsIngame(client)) continue; + if (!IsClientIngame(client)) continue; if (!IsPlayerAlive(client)) continue; if (!IsHuman(client)) continue; @@ -1141,6 +1144,19 @@ bool SetGameDescription(const char[] description) #endif } +stock bool IsClientIngame(int client) +{ + if (client > 4096) { + client = EntRefToEntIndex(client); + } + + if (client < 1 || client > MaxClients) { + return false; + } + + return IsClientInGame(client); +} + stock void WriteLog(const char[] format, any ...) { #if defined DEBUG diff --git a/addons/sourcemod/scripting/include/smlib.inc b/addons/sourcemod/scripting/include/smlib.inc deleted file mode 100644 index e41fda5..0000000 --- a/addons/sourcemod/scripting/include/smlib.inc +++ /dev/null @@ -1,32 +0,0 @@ -#if defined _smlib_included - #endinput -#endif -#define _smlib_included - -#define SMLIB_VERSION "0.9.7" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -#include -#include -#include -#include diff --git a/addons/sourcemod/scripting/include/smlib/concommands.inc b/addons/sourcemod/scripting/include/smlib/concommands.inc deleted file mode 100644 index d3909f2..0000000 --- a/addons/sourcemod/scripting/include/smlib/concommands.inc +++ /dev/null @@ -1,45 +0,0 @@ -#if defined _smlib_concommands_included - #endinput -#endif -#define _smlib_concommands_included - -#include -#include - -/** - * Checks if a ConCommand has one or more flags set. - * - * @param command ConCommand name. - * @param flags Flags to check. - * @return True if flags are set, false otherwise. - */ -stock bool ConCommand_HasFlags(const char[] command, int flags) -{ - return GetCommandFlags(command) & flags > 0; -} - -/** - * Adds one or more flags to a ConCommand. - * - * @param command ConCommand name. - * @param flags Flags to add. - */ -stock void ConCommand_AddFlags(const char[] command, int flags) -{ - int newFlags = GetCommandFlags(command); - newFlags |= flags; - SetCommandFlags(command, newFlags); -} - -/** - * Removes one ore more flags from a ConCommand. - * - * @param command ConCommand name. - * @param flags Flags to remove - */ -stock void ConCommand_RemoveFlags(const char[] command, int flags) -{ - int newFlags = GetCommandFlags(command); - newFlags &= ~flags; - SetCommandFlags(command, newFlags); -} diff --git a/addons/sourcemod/scripting/include/smlib/convars.inc b/addons/sourcemod/scripting/include/smlib/convars.inc deleted file mode 100644 index 8da1529..0000000 --- a/addons/sourcemod/scripting/include/smlib/convars.inc +++ /dev/null @@ -1,71 +0,0 @@ -#if defined _smlib_convars_included - #endinput -#endif -#define _smlib_convars_included - -#include - -/** - * Checks if a ConVar has one or more flags set. - * - * @param convar ConVar Handle. - * @param flags Flags to check. - * @return True if flags are set, false otherwise. - */ -stock bool Convar_HasFlags(ConVar convar, int flags) -{ - return convar.Flags & flags > 0; -} - -/** - * Adds one or more flags to a ConVar. - * - * @param convar ConVar Handle. - * @param flags Flags to add. - */ -stock void Convar_AddFlags(ConVar convar, int flags) -{ - int newFlags = convar.Flags; - newFlags |= flags; - convar.Flags = newFlags; -} - -/** - * Removes one ore more flags from a ConVar. - * - * @param convar ConVar Handle. - * @param flags Flags to remove - * @noreturn - */ -stock void Convar_RemoveFlags(ConVar convar, int flags) -{ - int newFlags = convar.Flags; - newFlags &= ~flags; - convar.Flags = newFlags; -} - -/** - * Checks if a String is a valid ConVar or - * Console Command name. - * - * @param name String Name. - * @return True if the name specified is a valid ConVar or console command name, false otherwise. - */ -stock bool Convar_IsValidName(const char[] name) -{ - if (name[0] == '\0') { - return false; - } - - int n=0; - while (name[n] != '\0') { - - if (!IsValidConVarChar(name[n])) { - return false; - } - - n++; - } - - return true; -} diff --git a/addons/sourcemod/scripting/include/smlib/crypt.inc b/addons/sourcemod/scripting/include/smlib/crypt.inc deleted file mode 100644 index e2903e9..0000000 --- a/addons/sourcemod/scripting/include/smlib/crypt.inc +++ /dev/null @@ -1,625 +0,0 @@ -#if defined _smlib_crypt_included - #endinput -#endif -#define _smlib_crypt_included - -#include - -/********************************************************************************** - * - * Base64 Encoding/Decoding Functions - * All Credits to to SirLamer & ScriptCoderPro - * Taken from http://forums.alliedmods.net/showthread.php?t=101764 - * - ***********************************************************************************/ - -// The Base64 encoding table -static const char base64_sTable[] = - // 0000000000111111111122222222223333333333444444444455555555556666 - // 0123456789012345678901234567890123456789012345678901234567890123 - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -// The Base64 decoding table -static const int base64_decodeTable[] = { -// 0 1 2 3 4 5 6 7 8 9 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 9 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10 - 19 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20 - 29 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 30 - 39 - 0, 0, 0, 62, 0, 0, 0, 63, 52, 53, // 40 - 49 - 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, // 50 - 59 - 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, // 60 - 69 - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 70 - 79 - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 80 - 89 - 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, // 90 - 99 - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // 100 - 109 - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // 110 - 119 - 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, // 120 - 129 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 130 - 139 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 140 - 149 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 150 - 159 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160 - 169 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 170 - 179 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 180 - 189 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 190 - 199 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 200 - 209 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 210 - 219 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 220 - 229 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 230 - 239 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 240 - 249 - 0, 0, 0, 0, 0, 0 // 250 - 256 -}; - -/* - * For some reason the standard demands a string in 24-bit (3 character) intervals. - * This fill character is used to identify unused bytes at the end of the string. - */ -static const char base64_cFillChar = '='; - -// The conversion characters between the standard and URL-compliance Base64 protocols -static const char base64_mime_chars[] = "+/="; -static const char base64_url_chars[] = "-_."; - -/* - * Encodes a string or binary data into Base64 - * - * @param sString The input string or binary data to be encoded. - * @param sResult The storage buffer for the Base64-encoded result. - * @param len The maximum length of the storage buffer, in characters/bytes. - * @param sourcelen (optional): The number of characters or length in bytes to be read from the input source. - * This is not needed for a text string, but is important for binary data since there is no end-of-line character. - * @return The length of the written Base64 string, in bytes. - */ -stock int Crypt_Base64Encode(const char[] sString, char[] sResult, int len, int sourcelen=0) -{ - int nLength; // The string length to be read from the input - int resPos; // The string position in the result buffer - - // If the read length was specified, use it; otherwise, pull the string length from the input. - if (sourcelen > 0) { - nLength = sourcelen; - } - else { - nLength = strlen(sString); - } - - // Loop through and generate the Base64 encoded string - // NOTE: This performs the standard encoding process. Do not manipulate the logic within this loop. - for (int nPos = 0; nPos < nLength; nPos++) { - int cCode; - - cCode = (sString[nPos] >> 2) & 0x3f; - - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_sTable[cCode]); - - cCode = (sString[nPos] << 4) & 0x3f; - if (++nPos < nLength) { - cCode |= (sString[nPos] >> 4) & 0x0f; - } - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_sTable[cCode]); - - if ( nPos < nLength ) { - cCode = (sString[nPos] << 2) & 0x3f; - if (++nPos < nLength) { - cCode |= (sString[nPos] >> 6) & 0x03; - } - - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_sTable[cCode]); - } - else { - nPos++; - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_cFillChar); - } - - if (nPos < nLength) { - cCode = sString[nPos] & 0x3f; - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_sTable[cCode]); - } - else { - resPos += FormatEx(sResult[resPos], len - resPos, "%c", base64_cFillChar); - } - } - - return resPos; -} - - -/* - * Decodes a Base64 string. - * - * @param sString The input string in compliant Base64 format to be decoded. - * @param sResult The storage buffer for the decoded text strihg or binary data. - * @param len The maximum length of the storage buffer, in characters/bytes. - * @return The length of the decoded data, in bytes. - */ -stock int Crypt_Base64Decode(const char[] sString, char[] sResult, int len) -{ - int nLength = strlen(sString); // The string length to be read from the input - int resPos; // The string position in the result buffer - - // Loop through and generate the Base64 encoded string - // NOTE: This performs the standard encoding process. Do not manipulate the logic within this loop. - for (int nPos = 0; nPos < nLength; nPos++) { - - int c, c1; - - c = base64_decodeTable[sString[nPos++]]; - c1 = base64_decodeTable[sString[nPos]]; - - c = (c << 2) | ((c1 >> 4) & 0x3); - - resPos += FormatEx(sResult[resPos], len - resPos, "%c", c); - - if (++nPos < nLength) { - - c = sString[nPos]; - - if (c == base64_cFillChar) - break; - - c = base64_decodeTable[sString[nPos]]; - c1 = ((c1 << 4) & 0xf0) | ((c >> 2) & 0xf); - - resPos += FormatEx(sResult[resPos], len - resPos, "%c", c1); - } - - if (++nPos < nLength) { - - c1 = sString[nPos]; - - if (c1 == base64_cFillChar) - break; - - c1 = base64_decodeTable[sString[nPos]]; - c = ((c << 6) & 0xc0) | c1; - - resPos += FormatEx(sResult[resPos], len - resPos, "%c", c); - } - } - - return resPos; -} - - -/* - * Converts a standards-compliant Base64 string to the commonly accepted URL-compliant alternative. - * Note: The result will be the same length as the input string as long as the output buffer is large enough. - * - * @param sString The standards-compliant Base64 input string to converted. - * @param sResult The storage buffer for the URL-compliant result. - * @param len The maximum length of the storage buffer in characters/bytes. - * @return Number of cells written. - */ -stock int Crypt_Base64MimeToUrl(const char[] sString, char[] sResult, int len) -{ - int chars_len = sizeof(base64_mime_chars); // Length of the two standards vs. URL character lists - int nLength; // The string length to be read from the input - int temp_char; // Buffer character - - nLength = strlen(sString); - - char[] sTemp = new char[nLength+1]; // Buffer string - - // Loop through string - for (int i = 0; i < nLength; i++) { - temp_char = sString[i]; - - for (int j = 0; j < chars_len; j++) { - - if(temp_char == base64_mime_chars[j]) { - temp_char = base64_url_chars[j]; - break; - } - } - - sTemp[i] = temp_char; - } - - sTemp[nLength] = '\0'; - - return strcopy(sResult, len, sTemp); -} - -/* - * Base64UrlToMime(String:sResult[], len, const String:sString[], sourcelen) - * Converts a URL-compliant Base64 string to the standards-compliant version. - * Note: The result will be the same length as the input string as long as the output buffer is large enough. - * - * @param sString The URL-compliant Base64 input string to converted. - * @param sResult The storage buffer for the standards-compliant result. - * @param len The maximum length of the storage buffer in characters/bytes. - * @return Number of cells written. - */ -stock int Crypt_Base64UrlToMime(const char[] sString, char[] sResult, int len) -{ - int chars_len = sizeof(base64_mime_chars); // Length of the two standards vs. URL character lists - int nLength; // The string length to be read from the input - int temp_char; // Buffer character - - nLength = strlen(sString); - - char[] sTemp = new char[nLength+1]; // Buffer string - - // Loop through string - for (int i = 0; i < nLength; i++) { - temp_char = sString[i]; - for (int j = 0; j < chars_len; j++) { - if (temp_char == base64_url_chars[j]) { - temp_char = base64_mime_chars[j]; - break; - } - } - - sTemp[i] = temp_char; - } - - sTemp[nLength] = '\0'; - - return strcopy(sResult, len, sTemp); -} - -/********************************************************************************** - * - * MD5 Encoding Functions - * All Credits go to sslice - * RSA Data Security, Inc. MD5 Message Digest Algorithm - * Taken from http://forums.alliedmods.net/showthread.php?t=67683 - * - ***********************************************************************************/ - -/* - * Calculate the md5 hash of a string. - * - * @param str Input String - * @param output Output String Buffer - * @param maxlen Size of the Output String Buffer - */ -stock void Crypt_MD5(const char[] str, char[] output, int maxlen) -{ - int x[2]; - int buf[4]; - int input[64]; - int i, ii; - - int len = strlen(str); - - // MD5Init - x[0] = x[1] = 0; - buf[0] = 0x67452301; - buf[1] = 0xefcdab89; - buf[2] = 0x98badcfe; - buf[3] = 0x10325476; - - // MD5Update - int update[16]; - - update[14] = x[0]; - update[15] = x[1]; - - int mdi = (x[0] >>> 3) & 0x3F; - - if ((x[0] + (len << 3)) < x[0]) { - x[1] += 1; - } - - x[0] += len << 3; - x[1] += len >>> 29; - - int c = 0; - while (len--) { - input[mdi] = str[c]; - mdi += 1; - c += 1; - - if (mdi == 0x40) { - - for (i = 0, ii = 0; i < 16; ++i, ii += 4) - { - update[i] = (input[ii + 3] << 24) | (input[ii + 2] << 16) | (input[ii + 1] << 8) | input[ii]; - } - - // Transform - MD5Transform(buf, update); - - mdi = 0; - } - } - - // MD5Final - int padding[64] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; - - int inx[16]; - inx[14] = x[0]; - inx[15] = x[1]; - - mdi = (x[0] >>> 3) & 0x3F; - - len = (mdi < 56) ? (56 - mdi) : (120 - mdi); - update[14] = x[0]; - update[15] = x[1]; - - mdi = (x[0] >>> 3) & 0x3F; - - if ((x[0] + (len << 3)) < x[0]) { - x[1] += 1; - } - - x[0] += len << 3; - x[1] += len >>> 29; - - c = 0; - while (len--) { - input[mdi] = padding[c]; - mdi += 1; - c += 1; - - if (mdi == 0x40) { - - for (i = 0, ii = 0; i < 16; ++i, ii += 4) { - update[i] = (input[ii + 3] << 24) | (input[ii + 2] << 16) | (input[ii + 1] << 8) | input[ii]; - } - - // Transform - MD5Transform(buf, update); - - mdi = 0; - } - } - - for (i = 0, ii = 0; i < 14; ++i, ii += 4) { - inx[i] = (input[ii + 3] << 24) | (input[ii + 2] << 16) | (input[ii + 1] << 8) | input[ii]; - } - - MD5Transform(buf, inx); - - int digest[16]; - for (i = 0, ii = 0; i < 4; ++i, ii += 4) { - digest[ii] = (buf[i]) & 0xFF; - digest[ii + 1] = (buf[i] >>> 8) & 0xFF; - digest[ii + 2] = (buf[i] >>> 16) & 0xFF; - digest[ii + 3] = (buf[i] >>> 24) & 0xFF; - } - - FormatEx(output, maxlen, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - digest[0], digest[1], digest[2], digest[3], digest[4], digest[5], digest[6], digest[7], - digest[8], digest[9], digest[10], digest[11], digest[12], digest[13], digest[14], digest[15]); -} - -static stock void MD5Transform_FF(int &a, int &b, int &c, int &d, int x, int s, int ac) -{ - a += (((b) & (c)) | ((~b) & (d))) + x + ac; - a = (((a) << (s)) | ((a) >>> (32-(s)))); - a += b; -} - -static stock void MD5Transform_GG(int &a, int &b, int &c, int &d, int x, int s, int ac) -{ - a += (((b) & (d)) | ((c) & (~d))) + x + ac; - a = (((a) << (s)) | ((a) >>> (32-(s)))); - a += b; -} - -static stock void MD5Transform_HH(int &a, int &b, int &c, int &d, int x, int s, int ac) - { - a += ((b) ^ (c) ^ (d)) + x + ac; - a = (((a) << (s)) | ((a) >>> (32-(s)))); - a += b; -} - -static stock void MD5Transform_II(int &a, int &b, int &c, int &d, int x, int s, int ac) -{ - a += ((c) ^ ((b) | (~d))) + x + ac; - a = (((a) << (s)) | ((a) >>> (32-(s)))); - a += b; -} - -static stock void MD5Transform(int[] buf, int[] input){ - int a = buf[0]; - int b = buf[1]; - int c = buf[2]; - int d = buf[3]; - - MD5Transform_FF(a, b, c, d, input[0], 7, 0xd76aa478); - MD5Transform_FF(d, a, b, c, input[1], 12, 0xe8c7b756); - MD5Transform_FF(c, d, a, b, input[2], 17, 0x242070db); - MD5Transform_FF(b, c, d, a, input[3], 22, 0xc1bdceee); - MD5Transform_FF(a, b, c, d, input[4], 7, 0xf57c0faf); - MD5Transform_FF(d, a, b, c, input[5], 12, 0x4787c62a); - MD5Transform_FF(c, d, a, b, input[6], 17, 0xa8304613); - MD5Transform_FF(b, c, d, a, input[7], 22, 0xfd469501); - MD5Transform_FF(a, b, c, d, input[8], 7, 0x698098d8); - MD5Transform_FF(d, a, b, c, input[9], 12, 0x8b44f7af); - MD5Transform_FF(c, d, a, b, input[10], 17, 0xffff5bb1); - MD5Transform_FF(b, c, d, a, input[11], 22, 0x895cd7be); - MD5Transform_FF(a, b, c, d, input[12], 7, 0x6b901122); - MD5Transform_FF(d, a, b, c, input[13], 12, 0xfd987193); - MD5Transform_FF(c, d, a, b, input[14], 17, 0xa679438e); - MD5Transform_FF(b, c, d, a, input[15], 22, 0x49b40821); - - MD5Transform_GG(a, b, c, d, input[1], 5, 0xf61e2562); - MD5Transform_GG(d, a, b, c, input[6], 9, 0xc040b340); - MD5Transform_GG(c, d, a, b, input[11], 14, 0x265e5a51); - MD5Transform_GG(b, c, d, a, input[0], 20, 0xe9b6c7aa); - MD5Transform_GG(a, b, c, d, input[5], 5, 0xd62f105d); - MD5Transform_GG(d, a, b, c, input[10], 9, 0x02441453); - MD5Transform_GG(c, d, a, b, input[15], 14, 0xd8a1e681); - MD5Transform_GG(b, c, d, a, input[4], 20, 0xe7d3fbc8); - MD5Transform_GG(a, b, c, d, input[9], 5, 0x21e1cde6); - MD5Transform_GG(d, a, b, c, input[14], 9, 0xc33707d6); - MD5Transform_GG(c, d, a, b, input[3], 14, 0xf4d50d87); - MD5Transform_GG(b, c, d, a, input[8], 20, 0x455a14ed); - MD5Transform_GG(a, b, c, d, input[13], 5, 0xa9e3e905); - MD5Transform_GG(d, a, b, c, input[2], 9, 0xfcefa3f8); - MD5Transform_GG(c, d, a, b, input[7], 14, 0x676f02d9); - MD5Transform_GG(b, c, d, a, input[12], 20, 0x8d2a4c8a); - - MD5Transform_HH(a, b, c, d, input[5], 4, 0xfffa3942); - MD5Transform_HH(d, a, b, c, input[8], 11, 0x8771f681); - MD5Transform_HH(c, d, a, b, input[11], 16, 0x6d9d6122); - MD5Transform_HH(b, c, d, a, input[14], 23, 0xfde5380c); - MD5Transform_HH(a, b, c, d, input[1], 4, 0xa4beea44); - MD5Transform_HH(d, a, b, c, input[4], 11, 0x4bdecfa9); - MD5Transform_HH(c, d, a, b, input[7], 16, 0xf6bb4b60); - MD5Transform_HH(b, c, d, a, input[10], 23, 0xbebfbc70); - MD5Transform_HH(a, b, c, d, input[13], 4, 0x289b7ec6); - MD5Transform_HH(d, a, b, c, input[0], 11, 0xeaa127fa); - MD5Transform_HH(c, d, a, b, input[3], 16, 0xd4ef3085); - MD5Transform_HH(b, c, d, a, input[6], 23, 0x04881d05); - MD5Transform_HH(a, b, c, d, input[9], 4, 0xd9d4d039); - MD5Transform_HH(d, a, b, c, input[12], 11, 0xe6db99e5); - MD5Transform_HH(c, d, a, b, input[15], 16, 0x1fa27cf8); - MD5Transform_HH(b, c, d, a, input[2], 23, 0xc4ac5665); - - MD5Transform_II(a, b, c, d, input[0], 6, 0xf4292244); - MD5Transform_II(d, a, b, c, input[7], 10, 0x432aff97); - MD5Transform_II(c, d, a, b, input[14], 15, 0xab9423a7); - MD5Transform_II(b, c, d, a, input[5], 21, 0xfc93a039); - MD5Transform_II(a, b, c, d, input[12], 6, 0x655b59c3); - MD5Transform_II(d, a, b, c, input[3], 10, 0x8f0ccc92); - MD5Transform_II(c, d, a, b, input[10], 15, 0xffeff47d); - MD5Transform_II(b, c, d, a, input[1], 21, 0x85845dd1); - MD5Transform_II(a, b, c, d, input[8], 6, 0x6fa87e4f); - MD5Transform_II(d, a, b, c, input[15], 10, 0xfe2ce6e0); - MD5Transform_II(c, d, a, b, input[6], 15, 0xa3014314); - MD5Transform_II(b, c, d, a, input[13], 21, 0x4e0811a1); - MD5Transform_II(a, b, c, d, input[4], 6, 0xf7537e82); - MD5Transform_II(d, a, b, c, input[11], 10, 0xbd3af235); - MD5Transform_II(c, d, a, b, input[2], 15, 0x2ad7d2bb); - MD5Transform_II(b, c, d, a, input[9], 21, 0xeb86d391); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -/********************************************************************************** - * - * RC4 Encoding Functions - * All Credits go to SirLamer and Raydan - * Taken from http://forums.alliedmods.net/showthread.php?t=101834 - * - ***********************************************************************************/ - -/* - * Encrypts a text string using RC4. - * Note: This function is NOT binary safe. - * Use Crypt_RC4EncodeBinary to encode binary data. - * - * @param input The source data to be encrypted. - * @param pwd The password/key used to encode and decode the data. - * @param output The encoded result. - * @param maxlen The maximum length of the output buffer. - */ -stock void Crypt_RC4Encode(const char[] input, const char[] pwd, char[] output, int maxlen) -{ - int pwd_len,str_len,i,j,a,k; - int key[256]; - int box[256]; - int tmp; - - pwd_len = strlen(pwd); - str_len = strlen(input); - - if (pwd_len > 0 && str_len > 0) { - - for (i=0; i < 256; i++) { - key[i] = pwd[i%pwd_len]; - box[i]=i; - } - - i=0; j=0; - - for (; i < 256; i++) { - j = (j + box[i] + key[i]) % 256; - tmp = box[i]; - box[i] = box[j]; - box[j] = tmp; - } - - i=0; j=0; a=0; - - for (; i < str_len; i++) { - a = (a + 1) % 256; - j = (j + box[a]) % 256; - tmp = box[a]; - box[a] = box[j]; - box[j] = tmp; - k = box[((box[a] + box[j]) % 256)]; - FormatEx(output[2*i], maxlen-2*i, "%02x", input[i] ^ k); - } - } -} - -/* - * Encrypts binary data using RC4. - * - * @param input The source data to be encrypted. - * @param str_len The length of the source data. - * @param pwd The password/key used to encode and decode the data. - * @param output The encoded result. - * @param maxlen The maximum length of the output buffer. - */ -stock int Crypt_RC4EncodeBinary(const char[] input, int str_len, const char[] pwd, char[] output, int maxlen) -{ - int pwd_len,i,j,a,k; - int key[256]; - int box[256]; - int tmp; - - pwd_len = strlen(pwd); - - if (pwd_len > 0 && str_len > 0) { - - for(i=0;i<256;i++) { - key[i] = pwd[i%pwd_len]; - box[i]=i; - } - - i=0; j=0; - - for (; i < 256; i++) { - j = (j + box[i] + key[i]) % 256; - tmp = box[i]; - box[i] = box[j]; - box[j] = tmp; - } - - i=0; j=0; a=0; - - if (str_len+1 > maxlen) { - str_len = maxlen - 1; - } - - for(; i < str_len; i++) { - a = (a + 1) % 256; - j = (j + box[a]) % 256; - tmp = box[a]; - box[a] = box[j]; - box[j] = tmp; - k = box[((box[a] + box[j]) % 256)]; - FormatEx(output[i], maxlen-i, "%c", input[i] ^ k); - } - - /* - * i = number of written bits (remember increment occurs at end of for loop, and THEN it fails the loop condition) - * Since we're working with binary data, the calling function should not depend on the escape - * character, but putting it here prevents crashes in case someone tries to read the data like a string - */ - output[i] = '\0'; - - return i; - } - else { - return -1; - } -} diff --git a/addons/sourcemod/scripting/include/smlib/debug.inc b/addons/sourcemod/scripting/include/smlib/debug.inc deleted file mode 100644 index a2cb7f9..0000000 --- a/addons/sourcemod/scripting/include/smlib/debug.inc +++ /dev/null @@ -1,28 +0,0 @@ -#if defined _smlib_debug_included - #endinput -#endif -#define _smlib_debug_included - -#include - -/** - * Prints the values of a static Float-Array to the server console. - * - * @param array Static Float-Array. - * @param size Size of the Array. - */ -stock void Debug_FloatArray(const float[] array, int size=3) -{ - char output[64] = ""; - - for (int i=0; i < size; ++i) { - - if (i > 0 && i < size) { - StrCat(output, sizeof(output), ", "); - } - - Format(output, sizeof(output), "%s%f", output, array[i]); - } - - PrintToServer("[DEBUG] Vector[%d] = { %s }", size, output); -} diff --git a/addons/sourcemod/scripting/include/smlib/dynarrays.inc b/addons/sourcemod/scripting/include/smlib/dynarrays.inc deleted file mode 100644 index fb85593..0000000 --- a/addons/sourcemod/scripting/include/smlib/dynarrays.inc +++ /dev/null @@ -1,24 +0,0 @@ -#if defined _smlib_dynarray_included - #endinput -#endif -#define _smlib_dynarray_included - -#include - -/** - * Retrieves a cell value from an array. - * This is a wrapper around the Sourcemod Function GetArrayCell, - * but it casts the result as bool - * - * @param array Array Handle. - * @param index Index in the array. - * @param block Optionally specify which block to read from - * (useful if the blocksize > 0). - * @param asChar Optionally read as a byte instead of a cell. - * @return Value read. - * @error Invalid Handle, invalid index, or invalid block. - */ -stock bool DynArray_GetBool(ArrayList array, int index, int block=0, bool asChar=false) -{ - return array.Get(index, block, asChar) != 0; -} diff --git a/addons/sourcemod/scripting/include/smlib/effects.inc b/addons/sourcemod/scripting/include/smlib/effects.inc deleted file mode 100644 index 4e13578..0000000 --- a/addons/sourcemod/scripting/include/smlib/effects.inc +++ /dev/null @@ -1,722 +0,0 @@ -#if defined _smlib_effects_included - #endinput -#endif -#define _smlib_effects_included - -#include -#include -#include -#include -#include -#include -#include -#include - - - -// Entity Dissolve types -enum DissolveType -{ - DISSOLVE_NORMAL = 0, - DISSOLVE_ELECTRICAL, - DISSOLVE_ELECTRICAL_LIGHT, - DISSOLVE_CORE -}; - -/** - * Dissolves a player - * - * @param client Client Index. - * @param dissolveType Dissolve Type, use the DissolveType enum. - * @param magnitude How strongly to push away from the center. - * @return True on success, otherwise false. - */ -stock bool Effect_DissolveEntity(int entity, DissolveType dissolveType=DISSOLVE_NORMAL, int magnitude=1) -{ - int env_entity_dissolver = CreateEntityByName("env_entity_dissolver"); - - if (env_entity_dissolver == -1) { - return false; - } - - Entity_PointAtTarget(env_entity_dissolver, entity); - SetEntProp(env_entity_dissolver, Prop_Send, "m_nDissolveType", dissolveType); - SetEntProp(env_entity_dissolver, Prop_Send, "m_nMagnitude", magnitude); - AcceptEntityInput(env_entity_dissolver, "Dissolve"); - Entity_Kill(env_entity_dissolver); - - return true; -} - -/** - * Dissolves a player's Ragdoll - * - * @param client Client Index. - * @param dissolveType Dissolve Type, use the DissolveType enum. - * @return True on success, otherwise false. - */ -stock bool Effect_DissolvePlayerRagDoll(int client, DissolveType dissolveType=DISSOLVE_NORMAL) -{ - int m_hRagdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll"); - - if (m_hRagdoll == -1) { - return false; - } - - return Effect_DissolveEntity(m_hRagdoll, dissolveType); -} - -typedef EffectCallback = function void(int entity, any data); - -/** - * Fades an entity in our out. - * You can specifiy a callback function which will get called - * when the fade is finished. - * Important: The callback will be called if it is passed, - * no matter if the entity is still valid or not. That means you - * have to check if the entity is valid yourself. - * - * @param entity Entity Index. - * @param fadeOut Optional: Fade the entity out (true) or in (false). - * @param kill Optional: If to kill the entity when the fade is finished. - * @param fast Optional: Fade the entity fast (~0.7 secs) or slow (~3 secs) - * @param callback Optional: You can specify a callback Function that will get called when the fade is finished. - * @param data Optional: You can pass any data to the callback. - */ -stock void Effect_Fade(int entity, bool fadeOut=true, bool kill=false, bool fast=true, EffectCallback callback=INVALID_FUNCTION, any data=0) -{ - float timerTime = 0.0; - - if (fast) { - timerTime = 0.6; - - if (fadeOut) { - SetEntityRenderFx(entity, RENDERFX_FADE_FAST); - } - else { - SetEntityRenderFx(entity, RENDERFX_SOLID_FAST); - } - } - else { - timerTime = 3.0; - - if (fadeOut) { - SetEntityRenderFx(entity, RENDERFX_FADE_SLOW); - } - else { - SetEntityRenderFx(entity, RENDERFX_SOLID_SLOW); - } - } - - ChangeEdictState(entity, GetEntSendPropOffs(entity, "m_nRenderFX", true)); - - if (kill || callback != INVALID_FUNCTION) { - DataPack dataPack = null; - CreateDataTimer(timerTime, _smlib_Timer_Effect_Fade, dataPack, TIMER_FLAG_NO_MAPCHANGE | TIMER_DATA_HNDL_CLOSE); - - WritePackCell(dataPack, EntIndexToEntRef(entity)); - WritePackCell(dataPack, kill); - WritePackFunction(dataPack, callback); - WritePackCell(dataPack, data); - ResetPack(dataPack); - } -} - -/** - * Fades the entity in. - * A wrapper function around Effect_Fade(). - * - * @param entity Entity Index. - * @param fast Optional: Fade the entity fast (~0.7 secs) or slow (~3 secs) - * @param callback Optional: You can specify a callback Function that will get called when the fade is finished. - * @param data Optional: You can pass any data to the callback. - */ -stock void Effect_FadeIn(int entity, bool fast=true, EffectCallback callback=INVALID_FUNCTION, any data=0) -{ - Effect_Fade(entity, false, false, fast, callback, data); -} - -/** - * Fades the entity out. - * A wrapper function around Effect_Fade(). - * - * @param entity Entity Index. - * @param fadeOut Optional: Fade the entity out (true) or in (false). - * @param kill Optional: If to kill the entity when the fade is finished. - * @param fast Optional: Fade the entity fast (~0.7 secs) or slow (~3 secs) - * @param callback Optional: You can specify a callback Function that will get called when the fade is finished. - * @param data Optional: You can pass any data to the callback. - */ -stock void Effect_FadeOut(int entity, bool kill=false, bool fast=true, EffectCallback callback=INVALID_FUNCTION, any data=0) -{ - Effect_Fade(entity, true, kill, fast, callback, data); -} - -public Action _smlib_Timer_Effect_Fade(Handle Timer, DataPack dataPack) -{ - int entity = ReadPackCell(dataPack); - int kill = ReadPackCell(dataPack); - Function callback = ReadPackFunction(dataPack); - any data = ReadPackCell(dataPack); - - if (callback != INVALID_FUNCTION) { - Call_StartFunction(INVALID_HANDLE, callback); - Call_PushCell(entity); - Call_PushCell(data); - Call_Finish(); - } - - if (kill && IsValidEntity(entity)) { - Entity_Kill(entity); - } - - return Plugin_Stop; -} - -/** - * Sends a boxed beam effect to one player. - * - * Ported from eventscripts vecmath library. - * - * @param client The client to show the box to. - * @param bottomCorner One bottom corner of the box. - * @param upperCorner One upper corner of the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBoxToClient( - int client, - const float bottomCorner[3], - const float upperCorner[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) { - int clients[1]; - clients[0] = client; - Effect_DrawBeamBox(clients, 1, bottomCorner, upperCorner, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); -} - -/** - * Sends a boxed beam effect to all players. - * - * Ported from eventscripts vecmath library. - * - * @param bottomCorner One bottom corner of the box. - * @param upperCorner One upper corner of the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBoxToAll( - const float bottomCorner[3], - const float upperCorner[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) -{ - int[] clients = new int[MaxClients]; - int numClients = Client_Get(clients, CLIENTFILTER_INGAME); - - Effect_DrawBeamBox(clients, numClients, bottomCorner, upperCorner, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); -} - -/** - * Sends a boxed beam effect to a list of players. - * - * Ported from eventscripts vecmath library. - * - * @param clients An array of clients to show the box to. - * @param numClients Number of players in the array. - * @param bottomCorner One bottom corner of the box. - * @param upperCorner One upper corner of the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBox( - int[] clients, - int numClients, - const float bottomCorner[3], - const float upperCorner[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) { - // Create the additional corners of the box - float corners[8][3]; - - for (int i=0; i < 4; i++) { - Array_Copy(bottomCorner, corners[i], 3); - Array_Copy(upperCorner, corners[i+4], 3); - } - - corners[1][0] = upperCorner[0]; - corners[2][0] = upperCorner[0]; - corners[2][1] = upperCorner[1]; - corners[3][1] = upperCorner[1]; - corners[4][0] = bottomCorner[0]; - corners[4][1] = bottomCorner[1]; - corners[5][1] = bottomCorner[1]; - corners[7][0] = bottomCorner[0]; - - // Draw all the edges - - // Horizontal Lines - // Bottom - for (int i=0; i < 4; i++) { - int j = ( i == 3 ? 0 : i+1 ); - TE_SetupBeamPoints(corners[i], corners[j], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } - - // Top - for (int i=4; i < 8; i++) { - int j = ( i == 7 ? 4 : i+1 ); - TE_SetupBeamPoints(corners[i], corners[j], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } - - // All Vertical Lines - for (int i=0; i < 4; i++) { - TE_SetupBeamPoints(corners[i], corners[i+4], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } -} - - -/** - * Sends a boxed beam effect to one player. - * - * Ported from eventscripts vecmath library. - * - * @param client The client to show the box to. - * @param origin Origin/center of the box. - * @param mins Min size Vector - * @param maxs Max size Vector - * @param angles Angles used to rotate the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBoxRotatableToClient( - int client, - const float origin[3], - const float mins[3], - const float maxs[3], - const float angles[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) { - int clients[1]; - clients[0] = client; - Effect_DrawBeamBoxRotatable(clients, 1, origin, mins, maxs, angles, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); -} - - - -/** - * Sends a boxed beam effect to all players. - * - * Ported from eventscripts vecmath library. - * - * @param origin Origin/center of the box. - * @param mins Min size Vector - * @param maxs Max size Vector - * @param angles Angles used to rotate the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBoxRotatableToAll( - const float origin[3], - const float mins[3], - const float maxs[3], - const float angles[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) -{ - int[] clients = new int[MaxClients]; - int numClients = Client_Get(clients, CLIENTFILTER_INGAME); - - Effect_DrawBeamBoxRotatable(clients, numClients, origin, mins, maxs, angles, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); -} - -/** - * Sends a boxed beam effect to a list of players. - * - * Ported from eventscripts vecmath library. - * - * @param clients An array of clients to show the box to. - * @param numClients Number of players in the array. - * @param origin Origin/center of the box. - * @param mins Min size Vector - * @param maxs Max size Vector - * @param angles Angles used to rotate the box. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawBeamBoxRotatable( - int[] clients, - int numClients, - const float origin[3], - const float mins[3], - const float maxs[3], - const float angles[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - const int color[4]={ 255, 0, 0, 255 }, - int speed=0 -) { - // Create the additional corners of the box - float corners[8][3]; - Array_Copy(mins, corners[0], 3); - Math_MakeVector(maxs[0], mins[1], mins[2], corners[1]); - Math_MakeVector(maxs[0], maxs[1], mins[2], corners[2]); - Math_MakeVector(mins[0], maxs[1], mins[2], corners[3]); - Math_MakeVector(mins[0], mins[1], maxs[2], corners[4]); - Math_MakeVector(maxs[0], mins[1], maxs[2], corners[5]); - Array_Copy(maxs, corners[6], 3); - Math_MakeVector(mins[0], maxs[1], maxs[2], corners[7]); - - // Rotate all edges - for (int i=0; i < sizeof(corners); i++) { - Math_RotateVector(corners[i], angles, corners[i]); - } - - // Apply world offset (after rotation) - for (int i=0; i < sizeof(corners); i++) { - AddVectors(origin, corners[i], corners[i]); - } - - // Draw all the edges - // Horizontal Lines - // Bottom - for (int i=0; i < 4; i++) { - int j = ( i == 3 ? 0 : i+1 ); - TE_SetupBeamPoints(corners[i], corners[j], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } - - // Top - for (int i=4; i < 8; i++) { - int j = ( i == 7 ? 4 : i+1 ); - TE_SetupBeamPoints(corners[i], corners[j], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } - - // All Vertical Lines - for (int i=0; i < 4; i++) { - TE_SetupBeamPoints(corners[i], corners[i+4], modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, color, speed); - TE_Send(clients, numClients); - } -} - -/** - * Displays the given axis of rotation as beam effect to one player. - * - * @param client The client to show the box to. - * @param origin Origin/center of the box. - * @param angles Angles used to rotate the box. - * @param length The length in each direction. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawAxisOfRotationToClient( - int client, - const float origin[3], - const float angles[3], - const float length[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - int speed=0 -) { - int clients[1]; - clients[0] = client; - Effect_DrawAxisOfRotation(clients, 1, origin, angles, length, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, speed); -} - -/** - * Displays the given axis of rotation as beam effect to all players. - * - * @param origin Origin/center of the box. - * @param angles Angles used to rotate the box. - * @param length The length in each direction. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawAxisOfRotationToAll( - const float origin[3], - const float angles[3], - const float length[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - int speed=0 -) -{ - int[] clients = new int[MaxClients]; - int numClients = Client_Get(clients, CLIENTFILTER_INGAME); - - Effect_DrawAxisOfRotation(clients, numClients, origin, angles, length, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, speed); -} - -/** - * Displays the given axis of rotation as beam effect to a list of players. - * - * @param clients An array of clients to show the box to. - * @param numClients Number of players in the array. - * @param origin Origin/center of the box. - * @param angles Angles used to rotate the box. - * @param length The length in each direction. - * @param modelIndex Precached model index. - * @param haloIndex Precached model index. - * @param startFrame Initital frame to render. - * @param frameRate Beam frame rate. - * @param life Time duration of the beam. - * @param width Initial beam width. - * @param endWidth Final beam width. - * @param fadeLength Beam fade time duration. - * @param amplitude Beam amplitude. - * @param color Color array (r, g, b, a). - * @param speed Speed of the beam. - */ -stock void Effect_DrawAxisOfRotation( - int[] clients, - int numClients, - const float origin[3], - const float angles[3], - const float length[3], - int modelIndex, - int haloIndex, - int startFrame=0, - int frameRate=30, - float life=5.0, - float width=5.0, - float endWidth=5.0, - int fadeLength=2, - float amplitude=1.0, - int speed=0 -) { - // Create the additional corners of the box - float xAxis[3], yAxis[3], zAxis[3]; - xAxis[0] = length[0]; - yAxis[1] = length[1]; - zAxis[2] = length[2]; - - // Rotate all edges - Math_RotateVector(xAxis, angles, xAxis); - Math_RotateVector(yAxis, angles, yAxis); - Math_RotateVector(zAxis, angles, zAxis); - - // Apply world offset (after rotation) - AddVectors(origin, xAxis, xAxis); - AddVectors(origin, yAxis, yAxis); - AddVectors(origin, zAxis, zAxis); - - // Draw all - TE_SetupBeamPoints(origin, xAxis, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, {255, 0, 0, 255}, speed); - TE_Send(clients, numClients); - - TE_SetupBeamPoints(origin, yAxis, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, {0, 255, 0, 255}, speed); - TE_Send(clients, numClients); - - TE_SetupBeamPoints(origin, zAxis, modelIndex, haloIndex, startFrame, frameRate, life, width, endWidth, fadeLength, amplitude, {0, 0, 255, 255}, speed); - TE_Send(clients, numClients); -} - - -/** - * Creates an env_sprite. - * - * @param origin Origin of the Sprite. - * @param modelIndex Precached model index. - * @param color Color array (r, g, b, a). - * @param scale Scale (Note: many materials ignore a lower value than 0.25). - * @param targetName Targetname of the sprite. - * @param parent Entity Index of this sprite's parent in the movement hierarchy. - * @param renderMode Render mode (use the enum). - * @param renderFx Render fx (use the enum). - * @param glowProxySize Radius size of the glow when to be rendered, if inside a geometry. Ex: a block 2x2x2 units big, if the glowProxySize is between 0.0 and 2.0 the sprite will not be rendered, even if the actual size of the sprite is bigger, everything above 2.0 will render the sprite. Using an abnormal high value will render Sprites trough walls. - * @param frameRate Sprite frame rate. - * @param hdrColorScale Float value to multiply sprite color by when running with HDR. - * @param receiveShadows When false then this prevents the sprite from receiving shadows. - * @return Entity Index of the created Sprite. - */ -stock int Effect_EnvSprite( - const float origin[3], - int modelIndex, - const int color[4]={255, 255, 255, 255}, - float scale=0.25, - const char targetName[MAX_NAME_LENGTH]="", - int parent=-1, - RenderMode renderMode=RENDER_WORLDGLOW, - RenderFx renderFx=RENDERFX_NONE, - float glowProxySize=2.0, - float framerate=10.0, - float hdrColorScale=1.0, - bool receiveShadows = true -) { - int entity = Entity_Create("env_sprite"); - - if (entity == INVALID_ENT_REFERENCE) { - return INVALID_ENT_REFERENCE; - } - - DispatchKeyValue (entity, "disablereceiveshadows", (receiveShadows) ? "0" : "1"); - DispatchKeyValueFloat (entity, "framerate", framerate); - DispatchKeyValueFloat (entity, "GlowProxySize", glowProxySize); - DispatchKeyValue (entity, "spawnflags", "1"); - DispatchKeyValueFloat (entity, "HDRColorScale", hdrColorScale); - DispatchKeyValue (entity, "maxdxlevel", "0"); - DispatchKeyValue (entity, "mindxlevel", "0"); - DispatchKeyValueFloat (entity, "scale", scale); - - DispatchSpawn(entity); - - SetEntityRenderMode(entity, renderMode); - SetEntityRenderColor(entity, color[0], color[1], color[2], color[3]); - SetEntityRenderFx(entity, renderFx); - - Entity_SetName(entity, targetName); - Entity_SetModelIndex(entity, modelIndex); - Entity_SetAbsOrigin(entity, origin); - - if (parent != -1) { - Entity_SetParent(entity, parent); - } - - return entity; -} diff --git a/addons/sourcemod/scripting/include/smlib/files.inc b/addons/sourcemod/scripting/include/smlib/files.inc deleted file mode 100644 index e11fad4..0000000 --- a/addons/sourcemod/scripting/include/smlib/files.inc +++ /dev/null @@ -1,451 +0,0 @@ -#if defined _smlib_files_included - #endinput -#endif -#define _smlib_files_included - -#include -#include -#include - -/** - * Gets the Base name of a path. - * Examples: - * blub.txt -> "blub.txt" - * /sourcemod/extensions/example.ext.so -> "example.ext.so" - * - * @param path File path - * @param buffer String buffer array - * @param size Size of string buffer - */ -stock void File_GetBaseName(const char[] path, char[] buffer, int size) -{ - if (path[0] == '\0') { - buffer[0] = '\0'; - return; - } - - int pos_start = FindCharInString(path, '/', true); - - if (pos_start == -1) { - pos_start = FindCharInString(path, '\\', true); - } - - pos_start++; - - strcopy(buffer, size, path[pos_start]); -} - -/** - * Gets the Directory of a path (without the file name). - * Does not work with "." as the path. - * Examples: - * blub.txt -> "blub.txt" - * /sourcemod/extensions/example.ext.so -> "example.ext.so" - * - * @param path File path - * @param buffer String buffer array - * @param size Size of string buffer - */ -stock void File_GetDirName(const char[] path, char[] buffer, int size) -{ - if (path[0] == '\0') { - buffer[0] = '\0'; - return; - } - - int pos_start = FindCharInString(path, '/', true); - - if (pos_start == -1) { - pos_start = FindCharInString(path, '\\', true); - - if (pos_start == -1) { - buffer[0] = '\0'; - return; - } - } - - strcopy(buffer, size, path); - buffer[pos_start] = '\0'; -} - -/** - * Gets the File name of a path. - * blub.txt -> "blub" - * /sourcemod/extensions/example.ext.so -> "example.ext" - * - * @param path File path - * @param buffer String buffer array - * @param size Size of string buffer - */ -stock void File_GetFileName(const char[] path, char[] buffer, int size) -{ - if (path[0] == '\0') { - buffer[0] = '\0'; - return; - } - - File_GetBaseName(path, buffer, size); - - int pos_ext = FindCharInString(buffer, '.', true); - - if (pos_ext != -1) { - buffer[pos_ext] = '\0'; - } -} - -/** - * Gets the Extension of a file. - * Examples: - * blub.inc.txt -> "txt" - * /sourcemod/extensions/example.ext.so -> "so" - * - * @param path Path String - * @param buffer String buffer array - * @param size Max length of string buffer - */ -stock void File_GetExtension(const char[] path, char[] buffer, int size) -{ - int extpos = FindCharInString(path, '.', true); - - if (extpos == -1) { - buffer[0] = '\0'; - return; - } - - strcopy(buffer, size, path[++extpos]); -} - -/** - * Adds a path to the downloadables network string table. - * This can be a file or directory and also works recursed. - * You can optionally specify file extensions that should be ignored. - * Bz2 and ztmp are automatically ignored. - * It only adds files that actually exist. - * You can also specify a wildcard * after the ., very useful for models. - * This forces a client to download the file if they do not already have it. - * - * @param path Path String - * @param recursive Whether to do recursion or not. - * @param ignoreExts Optional: 2 dimensional String array.You can define it like this: new String:ignore[][] = { ".ext1", ".ext2" }; - * @param size This should be set to the number of file extensions in the ignoreExts array (sizeof(ignore) for the example above) - */ - -// Damn you SourcePawn :( I didn't want to -char _smlib_empty_twodimstring_array[][] = { { '\0' } }; -stock void File_AddToDownloadsTable(const char[] path, bool recursive=true, const char[][] ignoreExts=_smlib_empty_twodimstring_array, int size=0) -{ - if (path[0] == '\0') { - return; - } - - if (FileExists(path)) { - - char fileExtension[5]; - File_GetExtension(path, fileExtension, sizeof(fileExtension)); - - if (StrEqual(fileExtension, "bz2", false) || StrEqual(fileExtension, "ztmp", false)) { - return; - } - - if (Array_FindString(ignoreExts, size, fileExtension) != -1) { - return; - } - - char path_new[PLATFORM_MAX_PATH]; - strcopy(path_new, sizeof(path_new), path); - ReplaceString(path_new, sizeof(path_new), "//", "/"); - - AddFileToDownloadsTable(path_new); - } - else if (recursive && DirExists(path)) { - - char dirEntry[PLATFORM_MAX_PATH]; - DirectoryListing __dir = OpenDirectory(path); - - while (ReadDirEntry(__dir, dirEntry, sizeof(dirEntry))) { - - if (StrEqual(dirEntry, ".") || StrEqual(dirEntry, "..")) { - continue; - } - - Format(dirEntry, sizeof(dirEntry), "%s/%s", path, dirEntry); - File_AddToDownloadsTable(dirEntry, recursive, ignoreExts, size); - } - - delete __dir; - } - else if (FindCharInString(path, '*', true)) { - - char fileExtension[4]; - File_GetExtension(path, fileExtension, sizeof(fileExtension)); - - if (StrEqual(fileExtension, "*")) { - - char dirName[PLATFORM_MAX_PATH], - fileName[PLATFORM_MAX_PATH], - dirEntry[PLATFORM_MAX_PATH]; - - File_GetDirName(path, dirName, sizeof(dirName)); - File_GetFileName(path, fileName, sizeof(fileName)); - StrCat(fileName, sizeof(fileName), "."); - - DirectoryListing __dir = OpenDirectory(dirName); - while (ReadDirEntry(__dir, dirEntry, sizeof(dirEntry))) { - - if (StrEqual(dirEntry, ".") || StrEqual(dirEntry, "..")) { - continue; - } - - if (strncmp(dirEntry, fileName, strlen(fileName)) == 0) { - Format(dirEntry, sizeof(dirEntry), "%s/%s", dirName, dirEntry); - File_AddToDownloadsTable(dirEntry, recursive, ignoreExts, size); - } - } - - delete __dir; - } - } -} - - -/* - * Adds all files/paths in the given text file to the download table. - * Recursive mode enabled, see File_AddToDownloadsTable() - * Comments are allowed ! Supported comment types are ; // # - * - * @param path Path to the .txt file. - */ -stock void File_ReadDownloadList(const char[] path) -{ - File file = OpenFile(path, "r"); - - if (file == INVALID_HANDLE) { - return; - } - - char buffer[PLATFORM_MAX_PATH]; - while (!IsEndOfFile(file)) { - ReadFileLine(file, buffer, sizeof(buffer)); - - int pos; - pos = StrContains(buffer, "//"); - if (pos != -1) { - buffer[pos] = '\0'; - } - - pos = StrContains(buffer, "#"); - if (pos != -1) { - buffer[pos] = '\0'; - } - - pos = StrContains(buffer, ";"); - if (pos != -1) { - buffer[pos] = '\0'; - } - - TrimString(buffer); - - if (buffer[0] == '\0') { - continue; - } - - File_AddToDownloadsTable(buffer); - } - - delete file; -} - -/* - * Attempts to load a translation file and optionally unloads the plugin if the file - * doesn't exist (also prints an error message). - * - * @param file Filename of the translations file (eg. .phrases). - * @param setFailState If true, it sets the failstate if the translations file doesn't exist - * @return True on success, false otherwise (only if setFailState is set to false) - */ -stock bool File_LoadTranslations(const char[] file, bool setFailState=true) -{ - char path[PLATFORM_MAX_PATH]; - - BuildPath(Path_SM, path, sizeof(path), "translations/%s", file); - - if (FileExists(path)) { - LoadTranslations(file); - return true; - } - - Format(path,sizeof(path), "%s.txt", path); - - if (!FileExists(path)) { - - if (setFailState) { - SetFailState("Unable to locate translation file (%s).", path); - } - - return false; - } - - LoadTranslations(file); - - return true; -} - -/* - * Reads the contents of a given file into a string buffer in binary mode. - * - * @param path Path to the file - * @param buffer String buffer - * @param size If -1, reads until a null terminator is encountered in the file. Otherwise, read_count bytes are read into the buffer provided. In this case the buffer is not explicitly null terminated, and the buffer will contain any null terminators read from the file. - * @return Number of characters written to the buffer, or -1 if an error was encountered. - */ -stock int File_ToString(const char[] path, char[] buffer, int size) -{ - File file = OpenFile(path, "rb"); - - if (file == INVALID_HANDLE) { - buffer[0] = '\0'; - return -1; - } - - int num_bytes_written = ReadFileString(file, buffer, size); - delete file; - - return num_bytes_written; -} - -/* - * Writes a string into a file in binary mode. - * - * @param file Path to the file - * @param str String to write - * @return True on success, false otherwise - */ -stock bool File_StringToFile(const char[] path, char[] str) -{ - File file = OpenFile(path, "wb"); - - if (file == INVALID_HANDLE) { - return false; - } - - bool success = WriteFileString(file, str, false); - delete file; - - return success; -} - -/* - * Copies file source to destination - * Based on code of javalia: - * http://forums.alliedmods.net/showthread.php?t=159895 - * - * @param source Input file - * @param destination Output file - * @return True on success, false otherwise - */ -stock bool File_Copy(const char[] source, const char[] destination) -{ - File file_source = OpenFile(source, "rb"); - - if (file_source == INVALID_HANDLE) { - return false; - } - - File file_destination = OpenFile(destination, "wb"); - - if (file_destination == INVALID_HANDLE) { - delete file_source; - return false; - } - - int buffer[32]; - int cache; - - while (!IsEndOfFile(file_source)) { - cache = ReadFile(file_source, buffer, sizeof(buffer), 1); - WriteFile(file_destination, buffer, cache, 1); - } - - delete file_source; - delete file_destination; - - return true; -} - -/* - * Recursively copies (the content) of a directory or file specified - * by "path" to "destination". - * Note that because of Sourcemod API limitations this currently does not - * takeover the file permissions (it leaves them default). - * Links will be resolved. - * - * @param path Source path - * @param destination Destination directory (This can only be a directory) - * @param stop_on_error Optional: Set to true to stop on error (ie can't read a file) - * @param dirMode Optional: File mode for directories that will be created (Default = 0755), don't forget to convert FROM octal - * @return True on success, false otherwise - */ -stock bool File_CopyRecursive(const char[] path, const char[] destination, bool stop_on_error=false, int dirMode=493) -{ - if (FileExists(path)) { - return File_Copy(path, destination); - } - else if (DirExists(path)) { - return Sub_File_CopyRecursive(path, destination, stop_on_error, FileType_Directory, dirMode); - } - else { - return false; - } -} - -static stock bool Sub_File_CopyRecursive(const char[] path, const char[] destination, bool stop_on_error=false, FileType fileType, int dirMode) -{ - if (fileType == FileType_File) { - return File_Copy(path, destination); - } - else if (fileType == FileType_Directory) { - - if (!CreateDirectory(destination, dirMode) && stop_on_error) { - return false; - } - - DirectoryListing directory = OpenDirectory(path); - - if (directory == INVALID_HANDLE) { - return false; - } - - char - source_buffer[PLATFORM_MAX_PATH], - destination_buffer[PLATFORM_MAX_PATH]; - FileType type; - - while (ReadDirEntry(directory, source_buffer, sizeof(source_buffer), type)) { - - if (StrEqual(source_buffer, "..") || StrEqual(source_buffer, ".")) { - continue; - } - - Format(destination_buffer, sizeof(destination_buffer), "%s/%s", destination, source_buffer); - Format(source_buffer, sizeof(source_buffer), "%s/%s", path, source_buffer); - - if (type == FileType_File) { - File_Copy(source_buffer, destination_buffer); - } - else if (type == FileType_Directory) { - - if (!File_CopyRecursive(source_buffer, destination_buffer, stop_on_error, dirMode) && stop_on_error) { - delete directory; - return false; - } - } - } - - delete directory; - } - else if (fileType == FileType_Unknown) { - return false; - } - - return true; -} diff --git a/addons/sourcemod/scripting/include/smlib/game.inc b/addons/sourcemod/scripting/include/smlib/game.inc deleted file mode 100644 index 1c0550d..0000000 --- a/addons/sourcemod/scripting/include/smlib/game.inc +++ /dev/null @@ -1,57 +0,0 @@ -#if defined _smlib_game_included - #endinput -#endif -#define _smlib_game_included - -#include -#include -#include - -/* - * End's the game and displays the scoreboard with intermission time. - * - * @return True on success, false otherwise - */ -stock bool Game_End() -{ - int game_end = FindEntityByClassname(-1, "game_end"); - - if (game_end == -1) { - game_end = CreateEntityByName("game_end"); - - if (game_end == -1) { - ThrowError("Unable to find or create entity \"game_end\""); - } - } - - return AcceptEntityInput(game_end, "EndGame"); -} - -/* - * End's the current round, allows specifying the winning - * team and more. - * This function currently works in TF2 only (it uses the game_round_win entity). - * - * @param team The winning Team, pass 0 for Sudden Death mode (no winning team) - * @param forceMapReset If to force the map to reset during the force respawn after the round is over. - * @param switchTeams If to switch the teams when the game is going to be reset. - * @return True on success, false otherwise - */ -stock bool Game_EndRound(int team=0, bool forceMapReset=false, bool switchTeams=false) -{ - int game_round_win = FindEntityByClassname(-1, "game_round_win"); - - if (game_round_win == -1) { - game_round_win = CreateEntityByName("game_round_win"); - - if (game_round_win == -1) { - ThrowError("Unable to find or create entity \"game_round_win\""); - } - } - - DispatchKeyValue(game_round_win, "TeamNum" , (team ? "true" : "false")); - DispatchKeyValue(game_round_win, "force_map_reset" , (forceMapReset? "true" : "false")); - DispatchKeyValue(game_round_win, "switch_teams" , (switchTeams ? "true" : "false")); - - return AcceptEntityInput(game_round_win, "RoundWin"); -} diff --git a/addons/sourcemod/scripting/include/smlib/menus.inc b/addons/sourcemod/scripting/include/smlib/menus.inc deleted file mode 100644 index 87f253e..0000000 --- a/addons/sourcemod/scripting/include/smlib/menus.inc +++ /dev/null @@ -1,37 +0,0 @@ -#if defined _smlib_menus_included - #endinput -#endif -#define _smlib_menus_included - -#include -#include - -/** - * Adds an option to a menu with a String display but an integer - * identifying the option. - * - * @param menu Handle to the menu - * @param value Integer value for the option - * @param display Display text for the menu - */ -stock void Menu_AddIntItem(Menu menu, any value, char[] display) -{ - char buffer[INT_MAX_DIGITS + 1]; - IntToString(value, buffer, sizeof(buffer)); - menu.AddItem(buffer, display); -} - -/** - * Retrieves an integer-value choice from a menu, where the - * menu's information strings were created as integers. - * - * @param menu Handle to the menu - * @param param2 The item position selected from the menu. - * @return Integer choice from the menu, or 0 if the integer could not be parsed. - */ -stock any Menu_GetIntItem(Menu menu, any param2) -{ - char buffer[INT_MAX_DIGITS + 1]; - menu.GetItem(param2, buffer, sizeof(buffer)); - return StringToInt(buffer); -} diff --git a/addons/sourcemod/scripting/include/smlib/server.inc b/addons/sourcemod/scripting/include/smlib/server.inc deleted file mode 100644 index af95038..0000000 --- a/addons/sourcemod/scripting/include/smlib/server.inc +++ /dev/null @@ -1,135 +0,0 @@ -#if defined _smlib_server_included - #endinput -#endif -#define _smlib_server_included - -#include -#include - -/* - * Gets the server's public/external (default) or - * private/local (usually server's behind a NAT) IP. - * If your server is behind a NAT Router, you need the SteamTools - * extension available at http://forums.alliedmods.net/showthread.php?t=129763 - * to get the public IP. has to be included BEFORE . - * If the server is not behind NAT, the public IP is the same as the private IP. - * - * @param public Set to true to retrieve the server's public/external IP, false otherwise. - * @return Long IP or 0 if the IP couldn't be retrieved. - */ -stock int Server_GetIP(bool public_=true) -{ - int ip = 0; - - static ConVar cvHostip = null; - - if (cvHostip == INVALID_HANDLE) { - cvHostip = FindConVar("hostip"); - MarkNativeAsOptional("Steam_GetPublicIP"); - } - - if (cvHostip != INVALID_HANDLE) { - ip = cvHostip.IntValue; - } - - if (ip != 0 && IsIPLocal(ip) == public_) { - ip = 0; - } - -#if defined _steamtools_included - if (ip == 0) { - if (CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "Steam_GetPublicIP") == FeatureStatus_Available) { - int octets[4]; - Steam_GetPublicIP(octets); - - ip = - octets[0] << 24 | - octets[1] << 16 | - octets[2] << 8 | - octets[3]; - - if (IsIPLocal(ip) == public_) { - ip = 0; - } - } - } -#endif - - return ip; -} - -/* - * Gets the server's public/external (default) or - * private/local (usually server's behind a NAT) as IP String in dotted format. - * If your server is behind a NAT Router, you need the SteamTools - * extension available at http://forums.alliedmods.net/showthread.php?t=129763 - * to get the public IP. has to be included BEFORE . - * If the public IP couldn't be found, an empty String is returned. - * If the server is not behind NAT, the public IP is the same as the private IP. - * - * @param buffer String buffer (size=16) - * @param size String buffer size. - * @param public Set to true to retrieve the server's public/external IP, false otherwise. - * @return True on success, false otherwise. - */ -stock bool Server_GetIPString(char[] buffer, int size, bool public_=true) -{ - int ip; - - if ((ip = Server_GetIP(public_)) == 0) { - buffer[0] = '\0'; - return false; - } - - LongToIP(ip, buffer, size); - - return true; -} - -/* - * Gets the server's local port. - * - * @noparam - * @return The server's port, 0 if there is no port. - */ -stock int Server_GetPort() -{ - static ConVar cvHostport = null; - - if (cvHostport == INVALID_HANDLE) { - cvHostport = FindConVar("hostport"); - } - - if (cvHostport == INVALID_HANDLE) { - return 0; - } - - int port = cvHostport.IntValue; - - return port; -} - -/* - * Gets the server's hostname - * - * @param hostname String buffer - * @param size String buffer size - * @return True on success, false otherwise. - */ -stock bool Server_GetHostName(char[] buffer, int size) -{ - static ConVar cvHostname = null; - - if (cvHostname == INVALID_HANDLE) { - cvHostname = FindConVar("hostname"); - } - - if (cvHostname == INVALID_HANDLE) { - buffer[0] = '\0'; - return false; - } - - cvHostname.GetString(buffer, size); - - return true; -} diff --git a/addons/sourcemod/scripting/include/smlib/sql.inc b/addons/sourcemod/scripting/include/smlib/sql.inc deleted file mode 100644 index e02470f..0000000 --- a/addons/sourcemod/scripting/include/smlib/sql.inc +++ /dev/null @@ -1,107 +0,0 @@ -#if defined _smlib_sql_included - #endinput -#endif -#define _smlib_sql_included - -#include -#include - -/** - * Executes a threaded SQL Query (See: SQL_TQuery) - * This function supports the printf Syntax. - * - * - * @param database A database Handle. - * @param callback Callback; database is in "owner" and the query Handle is passed in "hndl". - * @param data Extra data value to pass to the callback. - * @param format Query string, printf syntax supported - * @param priority Priority queue to use - * @param ... Variable number of format parameters. - */ -stock void SQL_TQueryF(Database database, SQLTCallback callback, any data, DBPriority priority=DBPrio_Normal, const char[] format, any ...) { - - if (!database) { - ThrowError("[SMLIB] Error: Invalid database handle."); - return; - } - - char query[16384]; - VFormat(query, sizeof(query), format, 6); - - SQL_TQuery(database, callback, query, data, priority); -} - -/** - * Fetches an integer from a field in the current row of a result set (See: SQL_FetchInt) - * - * @param query A query (or statement) Handle. - * @param field The field index (starting from 0). - * @param result Optional variable to store the status of the return value. - * @return An integer value. - * @error Invalid query Handle or field index, invalid - * type conversion requested from the database, - * or no current result set. - */ -stock int SQL_FetchIntByName(DBResultSet query, const char[] fieldName, DBResult &result=DBVal_Error) { - - int fieldNum; - SQL_FieldNameToNum(query, fieldName, fieldNum); - - return SQL_FetchInt(query, fieldNum, result); -} - -/** - * Fetches a bool from a field in the current row of a result set (See: SQL_FetchInt) - * - * @param query A query (or statement) Handle. - * @param field The field index (starting from 0). - * @param result Optional variable to store the status of the return value. - * @return A bool value. - * @error Invalid query Handle or field index, invalid - * type conversion requested from the database, - * or no current result set. - */ -stock bool SQL_FetchBoolByName(DBResultSet query, const char[] fieldName, DBResult &result=DBVal_Error) { - - return SQL_FetchIntByName(query, fieldName, result) != 0; -} - -/** - * Fetches a float from a field in the current row of a result set. (See: SQL_FetchFloat) - * - * @param query A query (or statement) Handle. - * @param field The field index (starting from 0). - * @param result Optional variable to store the status of the return value. - * @return A float value. - * @error Invalid query Handle or field index, invalid - * type conversion requested from the database, - * or no current result set. - */ -stock float SQL_FetchFloatByName(DBResultSet query, const char[] fieldName, DBResult &result=DBVal_Error) { - - int fieldNum; - SQL_FieldNameToNum(query, fieldName, fieldNum); - - return SQL_FetchFloat(query, fieldNum, result); -} - -/** - * Fetches a string from a field in the current row of a result set. (See: SQL_FetchString) - * - * @param query A query (or statement) Handle. - * @param field The field index (starting from 0). - * @param buffer String buffer. - * @param maxlength Maximum size of the string buffer. - * @param result Optional variable to store the status of the return value. - * @return Number of bytes written. - * @error Invalid query Handle or field index, invalid - * type conversion requested from the database, - * or no current result set. - */ -stock int SQL_FetchStringByName(DBResultSet query, const char[] fieldName, char[] buffer, int maxlength, DBResult &result=DBVal_Error) { - - int fieldNum; - SQL_FieldNameToNum(query, fieldName, fieldNum); - - return SQL_FetchString(query, fieldNum, buffer, maxlength, result); -} diff --git a/addons/sourcemod/scripting/include/smlib/strings.inc b/addons/sourcemod/scripting/include/smlib/strings.inc deleted file mode 100644 index 7f568c0..0000000 --- a/addons/sourcemod/scripting/include/smlib/strings.inc +++ /dev/null @@ -1,228 +0,0 @@ -#if defined _smlib_strings_included - #endinput -#endif -#define _smlib_strings_included - -#include -#include - -/** - * Checks if the string is numeric. - * This correctly handles + - . in the String. - * - * @param str String to check. - * @return True if the String is numeric, false otherwise.. - */ -stock bool String_IsNumeric(const char[] str) -{ - int x=0; - int dotsFound=0; - int numbersFound=0; - - if (str[x] == '+' || str[x] == '-') { - x++; - } - - while (str[x] != '\0') { - - if (IsCharNumeric(str[x])) { - numbersFound++; - } - else if (str[x] == '.') { - dotsFound++; - - if (dotsFound > 1) { - return false; - } - } - else { - return false; - } - - x++; - } - - if (!numbersFound) { - return false; - } - - return true; -} - -/** - * Trims a string by removing the specified chars from beginning and ending. - * Removes all ' ', '\t', '\r', '\n' characters by default. - * The Output String can be the same as the Input String. - * - * @param str Input String. - * @param output Output String (Can be the as the input). - * @param size Size of the output String. - * @param chars Characters to remove. - */ -stock void String_Trim(const char[] str, char[] output, int size, const char[] chrs=" \t\r\n") -{ - int x=0; - while (str[x] != '\0' && FindCharInString(chrs, str[x]) != -1) { - x++; - } - - x = strcopy(output, size, str[x]); - x--; - - while (x >= 0 && FindCharInString(chrs, output[x]) != -1) { - x--; - } - - output[++x] = '\0'; -} - -/** - * Removes a list of strings from a string. - * - * @param buffer Input/Output buffer. - * @param removeList A list of strings which should be removed from buffer. - * @param size Number of Strings in the List. - * @param caseSensitive If true, comparison is case sensitive. If false (default), comparison is case insensitive. - */ -stock void String_RemoveList(char[] buffer, const char[][] removeList, int size, bool caseSensitive=false) -{ - for (int i=0; i < size; i++) { - ReplaceString(buffer, SIZE_OF_INT, removeList[i], "", caseSensitive); - } -} - -/** - * Converts the whole String to lower case. - * Only works with alphabetical characters (not ÖÄÜ) because Sourcemod suxx ! - * The Output String can be the same as the Input String. - * - * @param input Input String. - * @param output Output String. - * @param size Max Size of the Output string - */ -stock void String_ToLower(const char[] input, char[] output, int size) -{ - size--; - - int x=0; - while (input[x] != '\0' && x < size) { - - output[x] = CharToLower(input[x]); - - x++; - } - - output[x] = '\0'; -} - -/** - * Converts the whole String to upper case. - * Only works with alphabetical characters (not öäü) because Sourcemod suxx ! - * The Output String can be the same as the Input String. - * - * @param input Input String. - * @param output Output String. - * @param size Max Size of the Output string - */ -stock void String_ToUpper(const char[] input, char[] output, int size) -{ - size--; - - int x=0; - while (input[x] != '\0' && x < size) { - - output[x] = CharToUpper(input[x]); - - x++; - } - - output[x] = '\0'; -} - -/** - * Generates a random string. - * - * - * @param buffer String Buffer. - * @param size String Buffer size (must be length+1) - * @param length Number of characters being generated. - * @param chrs String for specifying the characters used for random character generation. - * By default it will use all letters of the alphabet (upper and lower) and all numbers. - * If you pass an empty String, it will use all readable ASCII characters (33 - 126) - */ -stock void String_GetRandom(char[] buffer, int size, int length=32, const char[] chrs="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234556789") -{ - int random, len; - size--; - - if (chrs[0] != '\0') { - len = strlen(chrs) - 1; - } - - int n = 0; - while (n < length && n < size) { - - if (chrs[0] == '\0') { - random = Math_GetRandomInt(33, 126); - buffer[n] = random; - } - else { - random = Math_GetRandomInt(0, len); - buffer[n] = chrs[random]; - } - - n++; - } - - buffer[length] = '\0'; -} - -/** - * Checks if string str starts with subString. - * - * - * @param str String to check - * @param subString Sub-String to check in str - * @return True if str starts with subString, false otherwise. - */ -stock bool String_StartsWith(const char[] str, const char[] subString) -{ - int n = 0; - while (subString[n] != '\0') { - - if (str[n] == '\0' || str[n] != subString[n]) { - return false; - } - - n++; - } - - return true; -} - -/** - * Checks if string str ends with subString. - * - * - * @param str String to check - * @param subString Sub-String to check in str - * @return True if str ends with subString, false otherwise. - */ -stock bool String_EndsWith(const char[] str, const char[] subString) -{ - int n_str = strlen(str) - 1; - int n_subString = strlen(subString) - 1; - - if(n_str < n_subString) { - return false; - } - - while (n_str != 0 && n_subString != 0) { - - if (str[n_str--] != subString[n_subString--]) { - return false; - } - } - - return true; -} diff --git a/addons/sourcemod/scripting/include/smlib/vehicles.inc b/addons/sourcemod/scripting/include/smlib/vehicles.inc deleted file mode 100644 index 232f5b4..0000000 --- a/addons/sourcemod/scripting/include/smlib/vehicles.inc +++ /dev/null @@ -1,137 +0,0 @@ -#if defined _smlib_vehicles_included - #endinput -#endif -#define _smlib_vehicles_included - -#include -#include -#include -#include - -/** - * Returns the vehicle's driver. - * If there is no driver in the vehicle, -1 is returned. - * - * @param vehicle Entity index. - * @return Client index, or -1 if there is no driver. - */ -stock int Vehicle_GetDriver(int vehicle) -{ - int m_hVehicle = GetEntPropEnt(vehicle, Prop_Send, "m_hPlayer"); - - return m_hVehicle; -} - -/** - * Returns whether there is a driver in the vehicle or not. - * - * @param vehicle Entity index. - * @return True if the vehicle has a driver, false otherwise - */ -stock bool Vehicle_HasDriver(int vehicle) -{ - return Vehicle_GetDriver(vehicle) != -1; -} - -/** - * Kicks the driver ouf of the vehicle - * - * @param vehicle Entity index. - * @return True on success, false otherwise. - */ -stock bool Vehicle_ExitDriver(int vehicle) -{ - if (!Vehicle_HasDriver(vehicle)) { - return false; - } - - return AcceptEntityInput(vehicle, "ExitVehicle"); -} - -/** - * Start's the vehicle's engine - * - * @param vehicle Entity index. - * @return True on success, false otherwise. - */ -stock bool Vehicle_TurnOn(int vehicle) -{ - return AcceptEntityInput(vehicle, "TurnOn"); -} - -/** - * Shuts down the vehicle's engine - * - * @param vehicle Entity index. - * @return True on success, false otherwise. - */ -stock bool Vehicle_TurnOff(int vehicle) -{ - return AcceptEntityInput(vehicle, "TurnOff"); -} - -/** - * Locks the vehicle. - * - * @param vehicle Entity index. - * @return True on success, false otherwise. - */ -stock bool Vehicle_Lock(int vehicle) -{ - return AcceptEntityInput(vehicle, "Lock"); -} - -/** - * Unlocks the vehicle. - * - * @param vehicle Entity index. - * @return True on success, false otherwise. - */ -stock bool Vehicle_Unlock(int vehicle) -{ - return AcceptEntityInput(vehicle, "Unlock"); -} - -/** - * Returns wether the entity is a valid vehicle or not. - * - * @param vehicle Entity index. - * @return True if it is a valid vehicle, false otherwise. - */ -stock bool Vehicle_IsValid(int vehicle) -{ - if (!Entity_IsValid(vehicle)) { - return false; - } - - return Entity_ClassNameMatches(vehicle, "prop_vehicle", true); -} - -/** - * Reads the vehicle script from a vehicle. - * This script contains all the vehicle settings like its speed - * and that stuff. - * - * @param vehicle Entity index. - * @param buffer String Buffer. - * @param size String Buffer size. - * @noreturn - */ -stock bool Vehicle_GetScript(int vehicle, char[] buffer, int size) -{ - GetEntPropString(vehicle, Prop_Data, "m_vehicleScript", buffer, size); -} - -/** - * Sets the script of a vehicle. - * This script contains all the vehicle settings like its speed - * and that stuff. - * - * @param vehicle Entity index. - * @param buffer Vehicle Script path. - * @noreturn - */ -stock bool Vehicle_SetScript(int vehicle, char[] script) -{ - DispatchKeyValue(vehicle, "vehiclescript", script); -} diff --git a/addons/sourcemod/scripting/include/smlib/world.inc b/addons/sourcemod/scripting/include/smlib/world.inc deleted file mode 100644 index 9cfdcba..0000000 --- a/addons/sourcemod/scripting/include/smlib/world.inc +++ /dev/null @@ -1,16 +0,0 @@ -#if defined _smlib_world_included - #endinput -#endif -#define _smlib_world_included - -#include - -/* - * Gets the world's max size - * - * @param vec Vector buffer - */ -stock void World_GetMaxs(float vec[3]) { - - GetEntPropVector(0, Prop_Data, "m_WorldMaxs", vec); -}