├── addons └── sourcemod │ ├── configs │ └── server_redirect.cfg │ ├── scripting │ ├── include │ │ ├── glib │ │ │ ├── addressutils.inc │ │ │ ├── assertutils.inc │ │ │ ├── commandutils.inc │ │ │ ├── colorutils.inc │ │ │ └── convarutils.inc │ │ └── server_redirect.inc │ ├── server_redirect │ │ ├── redirect.sp │ │ └── net.sp │ └── server_redirect.sp │ ├── gamedata │ └── server_redirect.games.txt │ └── translations │ ├── chi │ └── server_redirect.phrases.txt │ ├── server_redirect.phrases.txt │ ├── pt │ └── server_redirect.phrases.txt │ ├── ru │ └── server_redirect.phrases.txt │ ├── de │ └── server_redirect.phrases.txt │ ├── es │ └── server_redirect.phrases.txt │ └── fr │ └── server_redirect.phrases.txt ├── README.md └── LICENSE /addons/sourcemod/configs/server_redirect.cfg: -------------------------------------------------------------------------------- 1 | "Servers" 2 | { 3 | //Server entry key, each server should be under it's own key 4 | //"server1" 5 | //{ 6 | // //Server ip address to add to menu 7 | // "ip" "127.0.0.1:27015" 8 | // 9 | // //IP that will be shown instead of an actual IP, 10 | // //also will be used as a redirect ip, so be aware. 11 | // //If this entry is missing or empty default ip 12 | // //would be used for everything 13 | // "alias_ip" "123.321.123.321:27016" 14 | // 15 | // //Server display name to show in menu 16 | // //This will be used if there's no connection 17 | // //to server, or if you have no socket.ext installed 18 | // "display_name" "Server #1" 19 | //} 20 | // 21 | //"server2" 22 | //{ 23 | // "ip" "127.0.0.1:27016" 24 | // "display_name" "Server #2" 25 | //} 26 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/glib/addressutils.inc: -------------------------------------------------------------------------------- 1 | #if defined _addressutils_included 2 | #endinput 3 | #endif 4 | #define _addressutils_included 5 | 6 | methodmap AddressBase 7 | { 8 | property Address Address 9 | { 10 | public get() { return view_as
(this); } 11 | } 12 | } 13 | 14 | //-==Operator overloadings 15 | stock Address operator+(Address l, int r) 16 | { 17 | return l + view_as
(r); 18 | } 19 | 20 | stock Address operator+(int l, Address r) 21 | { 22 | return view_as
(l) + r; 23 | } 24 | 25 | stock Address operator-(Address l, int r) 26 | { 27 | return l - view_as
(r); 28 | } 29 | 30 | stock Address operator-(int l, Address r) 31 | { 32 | return view_as
(l) - r; 33 | } 34 | 35 | stock Address operator*(Address l, int r) 36 | { 37 | return l * view_as
(r); 38 | } 39 | 40 | stock Address operator*(int l, Address r) 41 | { 42 | return view_as
(l) * r; 43 | } 44 | 45 | stock Address operator/(Address l, int r) 46 | { 47 | return l / view_as
(r); 48 | } 49 | 50 | stock Address operator/(int l, Address r) 51 | { 52 | return view_as
(l) / r; 53 | } 54 | //Operator overloadings==- -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/server_redirect.inc: -------------------------------------------------------------------------------- 1 | #if defined _server_redirect_included 2 | #endinput 3 | #endif 4 | #define _server_redirect_included 5 | 6 | /** 7 | * Redirects client to a specific ip address. 8 | * 9 | * Note: Client will be disconnected during redirecting process, so all 10 | * disconnect forwards/events will be called too. 11 | * 12 | * @param client Client index. 13 | * @param ip Full ip address, can also be a format string. 14 | * Server ip will not be validated, you should validate it 15 | * yourself, or else player connection will be dropped 16 | * due to invalid ip address. (Expected format: XXX.XXX.XXX.XXX:XXXXX) 17 | * @param ... Variable number of format parameters. 18 | * @error Invalid client. 19 | */ 20 | native void RedirectClient(int client, char[] ip, any ...); 21 | 22 | 23 | //Plugin dependency 24 | 25 | public SharedPlugin __pl_server_redirect = 26 | { 27 | name = "server_redirect", 28 | file = "server_redirect.smx", 29 | #if defined REQUIRE_PLUGIN 30 | required = 1, 31 | #else 32 | required = 0, 33 | #endif 34 | }; 35 | 36 | #if !defined REQUIRE_PLUGIN 37 | public void __pl_server_redirect_SetNTVOptional() 38 | { 39 | MarkNativeAsOptional("RedirectClient"); 40 | } 41 | #endif -------------------------------------------------------------------------------- /addons/sourcemod/gamedata/server_redirect.games.txt: -------------------------------------------------------------------------------- 1 | "Games" 2 | { 3 | "csgo" 4 | { 5 | "Keys" 6 | { 7 | //netadr_s 8 | "netadr_s::type" "0" 9 | "netadr_s::ip" "4" 10 | "netadr_s::port" "8" 11 | 12 | //netpacket_t 13 | "netpacket_t::from" "0" 14 | //... 15 | } 16 | 17 | "Signatures" 18 | { 19 | // Search string "RejectConnection: %s - %s\n" 20 | "CBaseServer::RejectConnection" 21 | { 22 | "library" "engine" 23 | "windows" "\x55\x8B\xEC\x83\xE4\xF8\x81\xEC\x2A\x2A\x2A\x2A\x8D\x45\x14" 24 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x8B\x5D\x08\x65\xA1\x2A\x2A\x2A\x2A\x89\x45\xE4\x31\xC0\x8B\x75\x0C\x8D\x45\x14\x50\x8D\x85\x2A\x2A\x2A\x2A\xFF\x75\x10" 25 | } 26 | 27 | "CBaseServer::ProcessConnectionlessPacket" 28 | { 29 | "library" "engine" 30 | "windows" "\x55\x8B\xEC\xB8\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x53\x56\x57\x8B\xF9\xC7\x45\x2A\x2A\x2A\x2A\x2A\x8B\x5D\x08" 31 | "linux" "\x55\x89\xE5\x57\x56\x53\x81\xEC\x2A\x2A\x2A\x2A\x8B\x45\x08\x89\x85\x2A\x2A\x2A\x2A\x8B\x45\x0C\x89\xC7" 32 | } 33 | } 34 | 35 | "Offsets" 36 | { 37 | //netpacket_t 38 | "netpacket_t::data" 39 | { 40 | "windows" "48" 41 | "linux" "44" 42 | } 43 | 44 | //... 45 | 46 | "netpacket_t::size" 47 | { 48 | "windows" "88" 49 | "linux" "84" 50 | } 51 | 52 | //... 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/glib/assertutils.inc: -------------------------------------------------------------------------------- 1 | #if defined _assertutils_included 2 | #endinput 3 | #endif 4 | #define _assertutils_included 5 | 6 | /* Compile time settings for this include. Should be defined before including this file. 7 | * #define ASSERTUTILS_DISABLE //Disables all assertions 8 | * #define ASSERTUTILS_FAILSTATE_FUNC //Define the name of the function that should be called when assertion is hit 9 | */ 10 | 11 | #if !defined SNAME 12 | #define __SNAME "" 13 | #else 14 | #define __SNAME SNAME 15 | #endif 16 | 17 | #define ASSERT_FMT_STRING_LEN 512 18 | 19 | #if defined ASSERTUTILS_DISABLE 20 | 21 | #define ASSERT(%1)%2; 22 | #define ASSERT_MSG(%1,%2)%3; 23 | #define ASSERT_FINAL(%1)%2; 24 | #define ASSERT_FINAL_MSG(%1,%2)%3; 25 | 26 | #elseif defined ASSERTUTILS_FAILSTATE_FUNC 27 | 28 | #define ASSERT(%1) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME..."Assertion failed: \""...#%1..."\"") 29 | #define ASSERT_MSG(%1,%2) if(!(%1)) ASSERTUTILS_FAILSTATE_FUNC(__SNAME...%2) 30 | #define ASSERT_FINAL(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"") 31 | #define ASSERT_FINAL_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2) 32 | 33 | #else 34 | 35 | #define ASSERT(%1) if(!(%1)) SetFailState(__SNAME..."Assertion failed: \""...#%1..."\"") 36 | #define ASSERT_MSG(%1,%2) if(!(%1)) SetFailState(__SNAME...%2) 37 | #define ASSERT_FINAL(%1) ASSERT(%1) 38 | #define ASSERT_FINAL_MSG(%1,%2) ASSERT_MSG(%1,%2) 39 | 40 | #endif 41 | 42 | // Might be redundant as default ASSERT_MSG accept format arguments just fine. 43 | #if 0 44 | stock void ASSERT_FMT(bool result, char[] fmt, any ...) 45 | { 46 | #if !defined ASSERTUTILS_DISABLE 47 | if(!result) 48 | { 49 | char buff[ASSERT_FMT_STRING_LEN]; 50 | VFormat(buff, sizeof(buff), fmt, 3); 51 | 52 | SetFailState(__SNAME..."%s", buff); 53 | } 54 | #endif 55 | } 56 | #endif 57 | 58 | #undef ASSERT_FMT_STRING_LEN -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/glib/commandutils.inc: -------------------------------------------------------------------------------- 1 | #if defined _commandutils_included 2 | #endinput 3 | #endif 4 | #define _commandutils_included 5 | 6 | #define MAX_CMD_LENGTH 128 7 | 8 | static ArrayList gRegisteredCommands; 9 | 10 | //Accepts string of commands separated by a semicolon 11 | stock void RegConsoleCmds(const char[] commands, ConCmd callback, const char[] description = "", int flags = 0) 12 | { 13 | if(!gRegisteredCommands) 14 | gRegisteredCommands = new ArrayList(ByteCountToCells(MAX_CMD_LENGTH)); 15 | 16 | ArrayList arr = new ArrayList(ByteCountToCells(MAX_CMD_LENGTH)); 17 | 18 | char buff[MAX_CMD_LENGTH]; 19 | int start_pos, len; 20 | bool shouldskip; 21 | for(int i = 0; commands[i] != '\0'; start_pos = i++) 22 | { 23 | buff[0] = '\0'; 24 | 25 | do 26 | { 27 | if((!IsCharAlpha(commands[i]) && !IsCharNumeric(commands[i]) && commands[i] != '_') || i - start_pos + 1 >= MAX_CMD_LENGTH) 28 | { 29 | len = FindCharInString(commands[i], ';'); 30 | if(len == -1) 31 | i = start_pos + strlen(commands[start_pos]); 32 | else 33 | i += len; 34 | 35 | len = i++ - start_pos + 1; 36 | char[] tempbuff = new char[len + 1]; 37 | strcopy(tempbuff, len, commands[start_pos]); 38 | LogError("Failed to create command \"%s\".", tempbuff); 39 | 40 | shouldskip = true; 41 | break; 42 | } 43 | } 44 | while(commands[++i] != ';' && commands[i] != '\0'); 45 | 46 | if(shouldskip) 47 | continue; 48 | 49 | len = i++ - start_pos + 1; 50 | strcopy(buff, (len > MAX_CMD_LENGTH ? MAX_CMD_LENGTH : len), commands[start_pos]); 51 | 52 | if(gRegisteredCommands.FindString(buff) == -1) 53 | RegConsoleCmd(buff, callback, description, flags); 54 | 55 | arr.PushString(buff); 56 | } 57 | 58 | delete gRegisteredCommands; 59 | gRegisteredCommands = arr.Clone(); 60 | 61 | delete arr; 62 | } 63 | 64 | stock bool IsValidCmd() 65 | { 66 | char buff[MAX_CMD_LENGTH]; 67 | GetCmdArg(0, buff, sizeof(buff)); 68 | 69 | return gRegisteredCommands.FindString(buff) != -1; 70 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Counter-Strike 2 support 2 | Since the release of CS2, this project would no longer be maintained and is archived. 3 | 4 | # ServerRedirect 5 | SourceMod plugin that allows players to see and connect to other servers. 6 | 7 | # About 8 | This plugin provides servers list menu, where you can add your servers, so players can be redirected to them while being on server. You can redirect to **any** server you'd like, servers you redirect to **doesn't require any fixes installed** or anything like that. Also this plugin comes with A2S queries, but to actually use it you would need an optional requirement (see **Requirements**), after that you'll see real time statistics for every server you added. This plugin also provides some api (``addons/sourcemod/scripting/include/server_redirect.inc``) that you can use for your needs. 9 | 10 | # Configuration 11 | To add servers to servers menu use ``addons/sourcemod/configs/server_redirect.cfg`` file and add servers you'd like by following the description. After that take a look at convar file created after first plugin launch (``cfg/sourcemod/plugin.server_redirect.cfg``) and configure it to your liking by following provided description. 12 | 13 | Note: If you don't see your servers in servers menu, make sure that config file in the right place under right name (``addons/sourcemod/configs/server_redirect.cfg``) and is configured properly. 14 | 15 | # Requirements 16 | * [Sourcemod 1.10;](https://www.sourcemod.net/downloads.php?branch=1.10-dev&all=1) 17 | * [Dhooks with detour support;](https://forums.alliedmods.net/showpost.php?p=2588686&postcount=589) 18 | * [Socket (Optional).](https://github.com/JoinedSenses/sm-ext-socket) 19 | 20 | # Special thanks 21 | * To everyone in [SourceMod discord](https://discord.gg/HUc67zN) who was somehow related to csgo redirect method; 22 | 23 | # Screenshots 24 | Note: All servers were taken from server browser and selection was totaly random. 25 | 26 | Servers list menu: 27 | 28 | ![screen1](https://i.imgur.com/lYSPQRK.png) 29 | 30 | Server info menu (Shown when you chose server): 31 | 32 | ![screen2](https://i.imgur.com/MwrmeRM.png) 33 | 34 | Server ad: 35 | 36 | ![screen3](https://imgur.com/EKCkk2W.png) 37 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/server_redirect/redirect.sp: -------------------------------------------------------------------------------- 1 | StringMap gShouldReconnect; 2 | Handle gRejectConnection; 3 | 4 | void SetupSDKCalls(GameData gd) 5 | { 6 | //CBaseServer::RejectConnection 7 | StartPrepSDKCall(SDKCall_Static); 8 | 9 | ASSERT_MSG(PrepSDKCall_SetFromConf(gd, SDKConf_Signature, "CBaseServer::RejectConnection"), "Can't get offset for \"CBaseServer::RejectConnection\"."); 10 | 11 | PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain); 12 | PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain); 13 | PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer); 14 | 15 | gRejectConnection = EndPrepSDKCall(); 16 | ASSERT_MSG(gRejectConnection, "Failed to create SDKCall to \"CBaseServer::RejectConnection\"."); 17 | } 18 | 19 | void SetupDhooks(GameData gd) 20 | { 21 | //CBaseServer::ProcessConnectionlessPacket 22 | Handle dhook = DHookCreateDetour(Address_Null, CallConv_THISCALL, ReturnType_Bool, ThisPointer_Address); 23 | 24 | ASSERT_MSG(DHookSetFromConf(dhook, gd, SDKConf_Signature, "CBaseServer::ProcessConnectionlessPacket"), "Can't find \"CBaseServer::ProcessConnectionlessPacket\" signature."); 25 | DHookAddParam(dhook, HookParamType_Int); 26 | 27 | ASSERT_MSG(DHookEnableDetour(dhook, false, ProcessConnectionlessPacket_Dhook), "Can't enable detour for \"CBaseServer::ProcessConnectionlessPacket\"."); 28 | } 29 | 30 | public MRESReturn ProcessConnectionlessPacket_Dhook(Address pThis, Handle hReturn, Handle hParams) 31 | { 32 | if(gShouldReconnect.Size == 0) 33 | return MRES_Ignored; 34 | 35 | Netpacket_t packet = DHookGetParam(hParams, 1); 36 | 37 | if(packet.size < 5) 38 | return MRES_Ignored; 39 | 40 | if(LoadFromAddress(packet.data + 4, NumberType_Int8) != A2S_GETCHALLENGE) 41 | return MRES_Ignored; 42 | 43 | Netadr_s from = packet.from; 44 | 45 | if(from.type != NA_IP) 46 | return MRES_Ignored; 47 | 48 | char buff[32], buff2[64]; 49 | from.ToString(buff, sizeof(buff)); 50 | 51 | if(gShouldReconnect.GetString(buff, buff2, sizeof(buff2))) 52 | { 53 | gShouldReconnect.Remove(buff); 54 | 55 | RejectConnection(pThis, packet, "ConnectRedirectAddress:%s", buff2); 56 | 57 | DHookSetReturn(hReturn, 1); 58 | return MRES_Supercede; 59 | } 60 | 61 | return MRES_Ignored; 62 | } 63 | 64 | stock void RejectConnection(Address pThis, Netpacket_t packet, const char[] reject_msg, any ...) 65 | { 66 | char buff[64]; 67 | VFormat(buff, sizeof(buff), reject_msg, 4); 68 | SDKCall(gRejectConnection, pThis, packet, buff); 69 | } 70 | 71 | public any RedirectClient_Native(Handle plugin, int numParams) 72 | { 73 | char buff[32]; 74 | FormatNativeString(0, 2, 3, sizeof(buff), .out_string = buff); 75 | RedirectClient(GetNativeCell(1), buff); 76 | } 77 | 78 | stock void RedirectClient(int client, const char[] ip) 79 | { 80 | char buff[32]; 81 | GetClientIP(client, buff, sizeof(buff)); 82 | gShouldReconnect.SetString(buff, ip); 83 | ClientCommand(client, "retry"); 84 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/server_redirect/net.sp: -------------------------------------------------------------------------------- 1 | #define A2S_GETCHALLENGE 'q' 2 | 3 | enum netadrtype_t 4 | { 5 | NA_NULL = 0, 6 | NA_LOOPBACK, 7 | NA_BROADCAST, 8 | NA_IP, 9 | } 10 | 11 | enum struct netadr_s_offsets 12 | { 13 | int type; 14 | int ip; 15 | int port; 16 | } 17 | 18 | enum struct netpacket_t_offsets 19 | { 20 | int from; 21 | //... 22 | int data; 23 | //... 24 | int size; 25 | //... 26 | } 27 | 28 | enum struct NetOffsets 29 | { 30 | netadr_s_offsets nao; 31 | netpacket_t_offsets npo; 32 | } 33 | static NetOffsets offsets; 34 | 35 | methodmap Netadr_s < AddressBase 36 | { 37 | property netadrtype_t type 38 | { 39 | public get() { return view_as(LoadFromAddress(this.Address + offsets.nao.type, NumberType_Int32)); } 40 | } 41 | 42 | property int ip 43 | { 44 | public get() { return LoadFromAddress(this.Address + offsets.nao.ip, NumberType_Int32); } 45 | } 46 | 47 | property int port 48 | { 49 | public get() { return LoadFromAddress(this.Address + offsets.nao.port, NumberType_Int16); } 50 | } 51 | 52 | public void ToString(char[] buff, int size) 53 | { 54 | int ip = this.ip; 55 | Format(buff, size, "%i.%i.%i.%i", ip & 0xFF, ip >> 8 & 0xFF, ip >> 16 & 0xFF, ip >>> 24); 56 | } 57 | } 58 | 59 | methodmap Netpacket_t < AddressBase 60 | { 61 | property Netadr_s from 62 | { 63 | public get() { return view_as(this.Address + offsets.npo.from); } 64 | } 65 | 66 | //... 67 | 68 | property Address data 69 | { 70 | public get() { return view_as
(LoadFromAddress(this.Address + offsets.npo.data, NumberType_Int32)); } 71 | } 72 | 73 | //... 74 | 75 | property int size 76 | { 77 | public get() { return LoadFromAddress(this.Address + offsets.npo.size, NumberType_Int32); } 78 | } 79 | 80 | //... 81 | } 82 | 83 | stock void InitNet(GameData gd) 84 | { 85 | char buff[128]; 86 | 87 | //netadr_s 88 | ASSERT_MSG(gd.GetKeyValue("netadr_s::type", buff, sizeof(buff)), "Can't get \"netadr_s::type\" offset from gamedata."); 89 | offsets.nao.type = StringToInt(buff); 90 | ASSERT_MSG(gd.GetKeyValue("netadr_s::ip", buff, sizeof(buff)), "Can't get \"netadr_s::ip\" offset from gamedata."); 91 | offsets.nao.ip = StringToInt(buff); 92 | ASSERT_MSG(gd.GetKeyValue("netadr_s::port", buff, sizeof(buff)), "Can't get \"netadr_s::port\" offset from gamedata."); 93 | offsets.nao.port = StringToInt(buff); 94 | 95 | //netpacket_t 96 | ASSERT_MSG(gd.GetKeyValue("netpacket_t::from", buff, sizeof(buff)), "Can't get \"netpacket_t::from\" offset from gamedata."); 97 | offsets.npo.from = StringToInt(buff); 98 | offsets.npo.data = gd.GetOffset("netpacket_t::data"); 99 | ASSERT_MSG(offsets.npo.data != -1, "Can't get \"netpacket_t::data\" offset from gamedata"); 100 | offsets.npo.size = gd.GetOffset("netpacket_t::size"); 101 | ASSERT_MSG(offsets.npo.size != -1, "Can't get \"netpacket_t::size\" offset from gamedata"); 102 | } -------------------------------------------------------------------------------- /addons/sourcemod/translations/chi/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "chi" "[Server Redirect] 请稍等几秒钟再使用此命令" 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "chi" "服务器列表:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "chi" "没有服务器可用" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "chi" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "chi" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "chi" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "chi" "[N/A]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "chi" "地图: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "chi" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "chi" "{1}\nIP: {2}\n地图: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "chi" "{1}\nIP: {2}\n地图: {3}\n在线: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "chi" "N/A" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "chi" "连接" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "chi" "[你已在这]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "chi" "[受密码保护]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "chi" "[不可用]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "chi" "输出服务器信息" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "chi" "在线玩家 {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "chi" "玩家数据不可用" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "chi" "这个服没有玩家在线" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "chi" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "chi" "[Server Redirect] {1}\n[Server Redirect] 连接指令: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "chi" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "chi" "[Server Redirect] 玩家: {lg}{1}{d} | 服务器ip: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "chi" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "chi" "[Server Redirect] 服务器ip: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "chi" "你将要连接至:\n{1}\n \n继续?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "chi" "继续" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "chi" "等会" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "chi" "[Server Redirect] {lo}{1}{d}已加入{lg}{2}{d}. 输入{lg}!servers{d}跟随!" 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "en" "[Server Redirect] Please wait a few seconds before you can use this command again." 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "en" "Servers list:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "en" "No servers available" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "en" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "en" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "en" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "en" "[N/A]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "en" "Map: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "en" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "en" "{1}\nIP: {2}\nMap: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "en" "{1}\nIP: {2}\nMap: {3}\nOnline: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "en" "N/A" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "en" "Connect" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "en" "[You are on it]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "en" "[Password protected]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "en" "[Unavailable]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "en" "Print info to console" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "en" "Active players {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "en" "Player data unavailable" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "en" "No players currently on this server" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "en" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "en" "[Server Redirect] {1}\n[Server Redirect] Connect command: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "en" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "en" "[Server Redirect] Players: {lg}{1}{d} | Server ip: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "en" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "en" "[Server Redirect] Server ip: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "en" "You are about to connect to:\n{1}\n \nContinue?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "en" "Continue" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "en" "Not now" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "en" "[Server Redirect] {lo}{1}{d} is joining {lg}{2}{d}. Type {lg}!servers{d} to follow them!" 186 | } 187 | } -------------------------------------------------------------------------------- /addons/sourcemod/translations/pt/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "pt" "[Server Redirect] Favor esperar alguns segundos antes de utilizar esse comando novamente." 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "pt" "Lista de servidores:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "pt" "Sem servidores disponíveis." 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "pt" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "pt" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "pt" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "pt" "[N/A]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "pt" "Mapa: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "pt" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "pt" "{1}\nIP: {2}\nMapa: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "pt" "{1}\nIP: {2}\nMapa: {3}\nOnline: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "pt" "N/A" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "pt" "Conectar" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "pt" "[Você esta nele]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "pt" "[Protegido por senha]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "pt" "[Indisponível]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "pt" "Imprimir info no console" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "pt" "Jogadores {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "pt" "Info de jogadores indisponível" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "pt" "Sem jogadores nesse servidor" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "pt" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "pt" "[Server Redirect] {1}\n[Server Redirect] Comando: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "pt" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "pt" "[Server Redirect] Jogadores: {lg}{1}{d} | Server IP: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "pt" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "pt" "[Server Redirect] Server IP: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "pt" "Você esta prestes a se conectar em:\n{1}\n \nContinuar?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "pt" "Continuar" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "pt" "Agora não" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "pt" "[Server Redirect] {lo}{1}{d} esta indo para o servidor {lg}{2}{d}. Escreva {lg}!servers{d} para seguir!" 186 | } 187 | } -------------------------------------------------------------------------------- /addons/sourcemod/translations/ru/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "ru" "[Server Redirect] Пожалуйста, подождите несколько секунд, прежде чем вы сможете снова использовать эту команду." 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "ru" "Список серверов:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "ru" "Нет доступных серверов" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "ru" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "ru" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "ru" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "ru" "[Н/Д]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "ru" "Карта: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "ru" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "ru" "{1}\nIP: {2}\nКарта: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "ru" "{1}\nIP: {2}\nКарта: {3}\nОнлайн: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "ru" "Н/Д" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "ru" "Подключиться" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "ru" "[Вы на нём]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "ru" "[Защищён паролем]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "ru" "[Недоступен]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "ru" "Распечатать информацию в консоль" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "ru" "Активные игроки {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "ru" "Данные об игроках недоступны" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "ru" "На этом сервере нет игроков" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "ru" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "ru" "[Server Redirect] {1}\n[Server Redirect] Команда для подключения: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "ru" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "ru" "[Server Redirect] Игроков: {lg}{1}{d} | Ip сервера: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "ru" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "ru" "[Server Redirect] Ip сервера: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "ru" "Вы собираетесь подключиться к:\n{1}\n \nПродолжить?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "ru" "Продолжить" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "ru" "Не сейчас" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "ru" "[Server Redirect] Игрок {lo}{1}{d} подключается к {lg}{2}{d}. Напишите в чат {lg}!servers{d} чтобы следовать за ним!" 186 | } 187 | } -------------------------------------------------------------------------------- /addons/sourcemod/translations/de/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "de" "[Server Redirect] Bitte warte ein paar Sekunden bevor du das Kommando erneut benutzen kannst." 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "de" "Servers Liste:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "de" "Keine Server verfügbar" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "de" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "de" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "de" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "de" "[N/A]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "de" "Karte: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "de" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "de" "{1}\nIP: {2}\nKarte: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "de" "{1}\nIP: {2}\nKarte: {3}\nOnline: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "de" "N/A" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "de" "Beitreten" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "de" "[Du bist bereits auf diesem Server]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "de" "[Passwort geschützt]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "de" "[Nicht Verfügbar]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "de" "In der Konsole ausgeben" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "de" "Aktive Spieler {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "de" "Spieler Daten nicht verfügbar" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "de" "Aktuell sind keine Spieler auf diesem Server" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "de" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "de" "[Server Redirect] {1}\n[Server Redirect] Kommando zum beitreten: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "de" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "de" "[Server Redirect] Spieler: {lg}{1}{d} | Server ip: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "de" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "de" "[Server Redirect] Server ip: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "de" "Du bist auf dem Weg dem folgenden Server beizutreten:\n{1}\n \nWeiter?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "de" "Weiter" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "de" "Nicht jetzt" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "de" "[Server Redirect] {lo}{1}{d} tritt gerade {lg}{2}{d} bei. Schreibe {lg}!servers{d} um ihm zu folgen!" 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/es/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "es" "[Server Redirect] Por favor, aguarde unos segundos antes de utilizar este comando de nuevo." 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "es" "Lista de servidores:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "es" "No hay servidores disponibles" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "es" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "es" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "es" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "es" "[N/A]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "es" "Mapa: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "es" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "es" "{1}\nIP: {2}\nMapa: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "es" "{1}\nIP: {2}\nMapa: {3}\nEn línea: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "es" "N/A" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "es" "Conectar" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "es" "[Estás conectado a este servidor]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "es" "[Protegido por contraseña]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "es" "[No disponible]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "es" "Mostrar información en consola" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "es" "Jugadores activos {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "es" "Información sobre jugadores no disponible" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "es" "No hay jugadores actualmente en este servidor" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "es" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "es" "[Server Redirect] {1}\n[Server Redirect] Comando para conectar: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "es" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "es" "[Server Redirect] Jugadores: {lg}{1}{d} | IP del servidor: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "es" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "es" "[Server Redirect] IP del servidor: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "es" "Estás por conectarte a:\n{1}\n \nContinuar?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "es" "Continuar" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "es" "Ahora no" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "es" "[Server Redirect] {lo}{1}{d} está ingresando a {lg}{2}{d}. ¡Escribe {lg}!servers{d} para seguirle!" 186 | } 187 | } -------------------------------------------------------------------------------- /addons/sourcemod/translations/fr/server_redirect.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | //All available colors (can also be lowercase): 4 | //Full name | Short name 5 | //{DEFAULT} | {D} 6 | //{RED} | {R} 7 | //{LIGHTPURPLE} | {LP} 8 | //{GREEN} | {GRN} 9 | //{LIME} | {L} 10 | //{LIGHTGREEN} | {LG} 11 | //{LIGHTRED} | {LR} 12 | //{GRAY} | {GRY} 13 | //{LIGHTOLIVE} | {LO} 14 | //{METAL} | {M} 15 | //{LIGHTBLUE} | {LB} 16 | //{BLUE} | {B} 17 | //{PURPLE} | {P} 18 | //{VIOLET} | {V} 19 | //{RED2} | {R2} 20 | //{GOLD} | {G} 21 | 22 | "command_spam_attempt" 23 | { 24 | "fr" "[Server Redirect] Merci d'attendre quelques secondes avant de réutiliser la commande" 25 | } 26 | 27 | "servers_menu_title" 28 | { 29 | "fr" "Liste des serveurs:" 30 | } 31 | 32 | "servers_menu_no_servers" 33 | { 34 | "fr" "Aucun serveur disponible" 35 | } 36 | 37 | "servers_menu_server_entry" 38 | { 39 | "#format" "{1:s},{2:s}" 40 | "fr" "{1} {2}" 41 | } 42 | 43 | "servers_menu_server_entry_no_socket" 44 | { 45 | "#format" "{1:s}" 46 | "fr" "{1}" 47 | } 48 | 49 | "servers_menu_server_entry_slots_count" 50 | { 51 | "#format" "{1:i},{2:i}" 52 | "fr" "[{1}/{2}]" 53 | } 54 | 55 | "servers_menu_server_entry_not_available" 56 | { 57 | "fr" "[Indisponible]" 58 | } 59 | 60 | "servinfo_menu_server_entry_mapname" 61 | { 62 | "#format" "{1:s}" 63 | "fr" "Carte: {1}" 64 | } 65 | 66 | "servinfo_menu_title_no_socket" 67 | { 68 | "#format" "{1:s},{2:s}" 69 | "fr" "{1}\nIP: {2}" 70 | } 71 | 72 | "servinfo_menu_title" 73 | { 74 | "#format" "{1:s},{2:s},{3:s}" 75 | "fr" "{1}\nIP: {2}\nCarte: {3}" 76 | } 77 | 78 | "servinfo_menu_title_no_player_info" 79 | { 80 | "#format" "{1:s},{2:s},{3:s},{4:s}" 81 | "fr" "{1}\nIP: {2}\nCarte: {3}\nEn ligne: {4}" 82 | } 83 | 84 | "servinfo_menu_map_not_available" 85 | { 86 | "fr" "Indisponible" 87 | } 88 | 89 | "servinfo_menu_connect" 90 | { 91 | "fr" "Connecter" 92 | } 93 | 94 | "servinfo_menu_connect_current" 95 | { 96 | "fr" "[Vous êtes dessus]" 97 | } 98 | 99 | "servinfo_menu_connect_password_protected" 100 | { 101 | "fr" "[Protégé par mot de passe]" 102 | } 103 | 104 | "servinfo_menu_connect_unavailable" 105 | { 106 | "fr" "[indisponible]" 107 | } 108 | 109 | "servinfo_menu_print" 110 | { 111 | "fr" "Envoyer les infos dans la console" 112 | } 113 | 114 | "servinfo_menu_players" 115 | { 116 | "#format" "{1:s}" 117 | "fr" "Joueurs actifs {1}:" 118 | } 119 | 120 | "servinfo_menu_players_data_unavailable" 121 | { 122 | "fr" "Données joueurs indisponibles" 123 | } 124 | 125 | "servinfo_menu_players_no_players" 126 | { 127 | "fr" "Aucun joueurs sur ce serveur" 128 | } 129 | 130 | "servinfo_menu_player_entry" 131 | { 132 | "#format" "{1:i},{2:s},{3:s}" 133 | "fr" "{1}# {2} | {3}" 134 | } 135 | 136 | "server_info" 137 | { 138 | "#format" "{1:s},{2:s}" 139 | "fr" "[Server Redirect] {1}\n[Server Redirect] Commande de connexion: connect {2}" 140 | } 141 | 142 | "server_advertisement_server_name" 143 | { 144 | "#format" "{1:s}" 145 | "fr" "[Server Redirect] {g}{1}" 146 | } 147 | 148 | "server_advertisement_server_stats" 149 | { 150 | "#format" "{1:s},{2:s}" 151 | "fr" "[Server Redirect] Joueurs: {lg}{1}{d} | IP du serveur: {lg}{2}" 152 | } 153 | 154 | "server_advertisement_no_socket_server_name" 155 | { 156 | "#format" "{1:s}" 157 | "fr" "[Server Redirect] {g}{1}" 158 | } 159 | 160 | "server_advertisement_no_socket_server_stats" 161 | { 162 | "#format" "{1:s}" 163 | "fr" "[Server Redirect] IP du serveur: {lg}{1}" 164 | } 165 | 166 | "confirmation_menu_title" 167 | { 168 | "#format" "{1:s}" 169 | "fr" "Vous souhaitez vous connecter à:\n{1}\n \nContinuer?" 170 | } 171 | 172 | "confirmation_menu_continue" 173 | { 174 | "fr" "Continuer" 175 | } 176 | 177 | "confirmation_menu_notnow" 178 | { 179 | "fr" "Pas maintenant" 180 | } 181 | 182 | "server_advertisement_leave" 183 | { 184 | "#format" "{1:N},{2:s}" 185 | "fr" "[Server Redirect] {lo}{1}{d} est en train de rejoindre {lg}{2}{d}. Type {lg}!servers{d} pour le suivre!" 186 | } 187 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/glib/colorutils.inc: -------------------------------------------------------------------------------- 1 | #if defined _colorutils_included 2 | #endinput 3 | #endif 4 | #define _colorutils_included 5 | 6 | /* Compile time settings for this include. Should be defined before including this file. 7 | * #define OVERRIDE_DEFAULT //Overrides default print function to color ones 8 | */ 9 | 10 | #define CLR_D "\1" //COLOR_DEFAULT 11 | #define CLR_R "\2" //COLOR_RED 12 | #define CLR_LP "\3" //COLOR_LIGHTPURPLE 13 | #define CLR_GRN "\4" //COLOR_GREEN 14 | #define CLR_L "\5" //COLOR_LIME 15 | #define CLR_LG "\6" //COLOR_LIGHTGREEN 16 | #define CLR_LR "\7" //COLOR_LIGHTRED 17 | #define CLR_GRY "\8" //COLOR_GRAY 18 | #define CLR_LO "\9" //COLOR_LIGHTOLIVE 19 | #define CLR_M "\10" //COLOR_METAL 20 | #define CLR_LB "\11" //COLOR_LIGHTBLUE 21 | #define CLR_B "\12" //COLOR_BLUE 22 | #define CLR_P "\13" //COLOR_PURPLE 23 | #define CLR_V "\14" //COLOR_VIOLET 24 | #define CLR_R2 "\15" //COLOR_RED2 25 | #define CLR_G "\16" //COLOR_GOLD 26 | 27 | static char gColorNames[][] = {"{DEFAULT}", "{RED}", "{LIGHTPURPLE}", "{GREEN}", "{LIME}", "{LIGHTGREEN}", "{LIGHTRED}", "{GRAY}", "{LIGHTOLIVE}", "{METAL}", "{LIGHTBLUE}", "{BLUE}", "{PURPLE}", "{VIOLET}", "{RED2}", "{GOLD}"}, 28 | gShortColorNames[][] = {"{D}", "{R}", "{LP}", "{GRN}", "{L}", "{LG}", "{LR}", "{GRY}", "{LO}", "{M}", "{LB}", "{B}", "{P}", "{V}", "{R2}", "{G}"}, 29 | gColorCodes[][] = {CLR_D, CLR_R, CLR_LP, CLR_GRN, CLR_L, CLR_LG, CLR_LR, CLR_GRY, CLR_LO, CLR_M, CLR_LB, CLR_B, CLR_P, CLR_V, CLR_R2, CLR_G}; 30 | 31 | enum 32 | { 33 | COLOR_START = 1, 34 | COLOR_DEFAULT = 1, 35 | COLOR_RED = 2, 36 | COLOR_LIGHTPURPLE, 37 | COLOR_GREEN, 38 | COLOR_LIME, 39 | COLOR_LIGHTGREEN, 40 | COLOR_LIGHTRED, 41 | COLOR_GRAY, 42 | COLOR_LIGHTOLIVE, 43 | COLOR_U1, 44 | COLOR_LIGHTBLUE, 45 | COLOR_BLUE, 46 | COLOR_U2, 47 | COLOR_PURPLE, 48 | COLOR_DARKORANGE, 49 | COLOR_GOLD, 50 | COLOR_END = COLOR_GOLD 51 | } 52 | 53 | #define MAX_MESSAGE_LENGTH 512 54 | 55 | #if defined _msgutils_included 56 | 57 | // Does produce clicky sound when printed 58 | stock void PrintToChatLongColored(int client, const char[] format, any ...) 59 | { 60 | char buff[MAX_MSG_SIZE]; 61 | SetGlobalTransTarget(client); 62 | VFormat(buff, sizeof(buff), format, 3); 63 | 64 | ReformatMessage(buff, sizeof(buff)); 65 | CheckForSpace(buff, sizeof(buff)); 66 | 67 | PrintToChatLong(client, buff); 68 | } 69 | 70 | // Does produce clicky sound when printed 71 | stock void PrintToChatAllLongColored(const char[] format, any ...) 72 | { 73 | char buff[MAX_MSG_SIZE]; 74 | int prev_lang = -1, lang; 75 | 76 | for(int i = 1; i <= MaxClients; i++) 77 | { 78 | if(!IsClientInGame(i)) 79 | continue; 80 | 81 | lang = GetClientLanguage(i); 82 | 83 | if(prev_lang != lang) 84 | { 85 | SetGlobalTransTarget(i); 86 | VFormat(buff, sizeof(buff), format, 2); 87 | 88 | ReformatMessage(buff, sizeof(buff)); 89 | CheckForSpace(buff, sizeof(buff)); 90 | } 91 | 92 | PrintToChatLong(i, buff); 93 | 94 | prev_lang = lang; 95 | } 96 | } 97 | 98 | #endif 99 | 100 | stock void PrintToChatColored(int client, const char[] format, any ...) 101 | { 102 | char buff[MAX_MESSAGE_LENGTH]; 103 | SetGlobalTransTarget(client); 104 | VFormat(buff, sizeof(buff), format, 3); 105 | 106 | ReformatMessage(buff, sizeof(buff)); 107 | CheckForSpace(buff, sizeof(buff)); 108 | 109 | PrintToChat(client, buff); 110 | } 111 | 112 | stock void PrintToChatAllColored(const char[] format, any ...) 113 | { 114 | char buff[MAX_MESSAGE_LENGTH]; 115 | int prev_lang = -1, lang; 116 | 117 | for(int i = 1; i <= MaxClients; i++) 118 | { 119 | if(!IsClientInGame(i)) 120 | continue; 121 | 122 | lang = GetClientLanguage(i); 123 | 124 | if(prev_lang != lang) 125 | { 126 | SetGlobalTransTarget(i); 127 | VFormat(buff, sizeof(buff), format, 2); 128 | 129 | ReformatMessage(buff, sizeof(buff)); 130 | CheckForSpace(buff, sizeof(buff)); 131 | } 132 | 133 | PrintToChat(i, buff); 134 | 135 | prev_lang = lang; 136 | } 137 | } 138 | 139 | static stock void ReformatMessage(char[] buff, int len) 140 | { 141 | for(int i = 0; i < COLOR_END; i++) 142 | { 143 | ReplaceString(buff, len, gColorNames[i], gColorCodes[i], false); 144 | ReplaceString(buff, len, gShortColorNames[i], gColorCodes[i], false); 145 | } 146 | } 147 | 148 | static stock void CheckForSpace(char[] buff, int len) 149 | { 150 | if(COLOR_START < buff[0] < COLOR_END) 151 | Format(buff, len, " %s", buff); 152 | } 153 | 154 | #if defined OVERRIDE_DEFAULT 155 | #define PrintToChat PrintToChatColored 156 | #define PrintToChatAll PrintToChatAllColored 157 | #endif -------------------------------------------------------------------------------- /addons/sourcemod/scripting/include/glib/convarutils.inc: -------------------------------------------------------------------------------- 1 | #if defined _convarutils_included 2 | #endinput 3 | #endif 4 | #define _convarutils_included 5 | 6 | static ArrayList gRegisteredConVars; 7 | static ArrayList gRegisteredConVarsDescriptions; 8 | 9 | stock ConVar CreateConVarCustom(const char[] name, const char[] defaultValue, const char[] description="", int flags=0, bool hasMin=false, float min=0.0, bool hasMax=false, float max=0.0) 10 | { 11 | if(!gRegisteredConVars) 12 | gRegisteredConVars = new ArrayList(); 13 | 14 | if(!gRegisteredConVarsDescriptions) 15 | gRegisteredConVarsDescriptions = new ArrayList(ByteCountToCells(1024)); 16 | 17 | ConVar cv = CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max); 18 | 19 | gRegisteredConVars.Push(cv); 20 | gRegisteredConVarsDescriptions.PushString(description); 21 | 22 | return cv; 23 | } 24 | 25 | stock void AutoExecConfigCustom(bool autoCreate=true, const char[] name="", const char[] folder="sourcemod") 26 | { 27 | if(gRegisteredConVars.Length == 0) 28 | return; 29 | 30 | if(autoCreate) 31 | { 32 | char path[PLATFORM_MAX_PATH], plname[PLATFORM_MAX_PATH]; 33 | 34 | Format(path, sizeof(path), "cfg/%s", folder); 35 | if(!DirExists(path) && !CreateDirectory(path, 0o755)) 36 | ThrowError("Failed to create directory \"%s\"!", path); 37 | 38 | GetPluginFilename(INVALID_HANDLE, plname, sizeof(plname)); 39 | plname[FindCharInString(plname, '.', true)] = '\0'; 40 | 41 | if(name[0] != '\0') 42 | Format(path, sizeof(path), "cfg/%s/%s.cfg", folder, name); 43 | else 44 | Format(path, sizeof(path), "cfg/%s/plugin.%s.cfg", folder, plname[FindCharInString(plname, '/', true) + 1]); 45 | 46 | ParseConVarFile(path); 47 | FillConVarFile(path, plname); 48 | } 49 | 50 | AutoExecConfig(false, name, folder); 51 | 52 | delete gRegisteredConVars; 53 | delete gRegisteredConVarsDescriptions; 54 | } 55 | 56 | static stock void FillConVarFile(const char path[PLATFORM_MAX_PATH], const char plname[PLATFORM_MAX_PATH]) 57 | { 58 | File file = OpenFile(path, "w"); 59 | 60 | if(!file) 61 | ThrowError("Failed to auto generate config \"%s\", make sure the directory has write permission", path); 62 | 63 | file.WriteLine("// This file was auto-generated by glib/convarutils.inc"); 64 | file.WriteLine("// ConVars for plugin \"%s.smx\"\n\n", plname); 65 | 66 | ConVar cv; 67 | char buff[1024], buff2[1024]; 68 | float bound; 69 | for(int i = 0; i < gRegisteredConVars.Length; i++) 70 | { 71 | cv = gRegisteredConVars.Get(i); 72 | 73 | if(cv.Flags & FCVAR_DONTRECORD) 74 | continue; 75 | 76 | gRegisteredConVarsDescriptions.GetString(i, buff, sizeof(buff)); 77 | 78 | ReplaceString(buff, sizeof(buff), "\n", "\n// "); 79 | Format(buff, sizeof(buff), "// %s", buff); 80 | 81 | file.WriteLine(buff); 82 | file.WriteLine("// -"); 83 | 84 | cv.GetDefault(buff, sizeof(buff)); 85 | Format(buff, sizeof(buff), "// Default: \"%s\"", buff); 86 | file.WriteLine(buff); 87 | 88 | if(cv.GetBounds(ConVarBound_Lower, bound)) 89 | { 90 | Format(buff, sizeof(buff), "// Minimum: \"%f\"", bound); 91 | file.WriteLine(buff); 92 | } 93 | 94 | if(cv.GetBounds(ConVarBound_Upper, bound)) 95 | { 96 | Format(buff, sizeof(buff), "// Maximum: \"%f\"", bound); 97 | file.WriteLine(buff); 98 | } 99 | 100 | cv.GetName(buff, sizeof(buff)); 101 | cv.GetString(buff2, sizeof(buff2)); 102 | Format(buff, sizeof(buff), "%s \"%s\"\n", buff, buff2); 103 | file.WriteLine(buff); 104 | } 105 | 106 | delete file; 107 | } 108 | 109 | static stock void ParseConVarFile(const char path[PLATFORM_MAX_PATH]) 110 | { 111 | File file = OpenFile(path, "r", true); 112 | 113 | if(!FileExists(path)) 114 | return; 115 | 116 | ConVar cv; 117 | int buff_pos; 118 | bool name_parsed; 119 | char line[4096], cvar_name[512], cvar_val[512], buff2[512]; 120 | while(file.ReadLine(line, sizeof(line))) 121 | { 122 | name_parsed = false; 123 | cvar_name[0] = '\0'; 124 | cvar_val[0] = '\0'; 125 | 126 | for(int i = 0; line[i] != '\0' && line[i] != '\n'; i++) 127 | { 128 | if(line[i] == '/' && line[i + 1] == '/') 129 | break; 130 | 131 | if(line[i] <= ' ') 132 | continue; 133 | 134 | buff_pos = 0; 135 | 136 | if(!name_parsed) 137 | { 138 | if(line[i] == '"') 139 | { 140 | i++; 141 | while(line[i] != '"' && line[i] != '\0' && line[i] != '\n') 142 | cvar_name[buff_pos++] = line[i++]; 143 | } 144 | else 145 | { 146 | while(line[i] > ' ' && line[i] != '"') 147 | cvar_name[buff_pos++] = line[i++]; 148 | 149 | if(line[i] == '"') 150 | i--; 151 | } 152 | 153 | cvar_name[buff_pos] = '\0'; 154 | name_parsed = true; 155 | } 156 | else 157 | { 158 | //need empty buffer each time, can't actualy fake it 159 | char buff[sizeof(cvar_val)]; 160 | 161 | if(line[i] == '"') 162 | { 163 | i++; 164 | while(line[i] != '\0' && line[i] != '\n') 165 | buff[buff_pos++] = line[i++]; 166 | 167 | 168 | while(buff_pos >= 0 && buff[buff_pos] <= ' ') 169 | buff_pos--; 170 | 171 | if(buff[buff_pos] == '"') 172 | buff_pos--; 173 | } 174 | else 175 | { 176 | while(line[i] != '\0' && line[i] != '\n') 177 | buff[buff_pos++] = line[i++]; 178 | 179 | while(buff_pos >= 0 && buff[buff_pos] <= ' ') 180 | buff_pos--; 181 | } 182 | 183 | buff[++buff_pos] = '\0'; 184 | strcopy(cvar_val, sizeof(cvar_val), buff); 185 | break; 186 | } 187 | } 188 | 189 | for(int i = 0; i < gRegisteredConVars.Length; i++) 190 | { 191 | cv = gRegisteredConVars.Get(i); 192 | cv.GetName(buff2, sizeof(buff2)); 193 | 194 | if(StrEqual(buff2, cvar_name, false)) 195 | cv.SetString(cvar_val); 196 | } 197 | } 198 | 199 | delete file; 200 | } 201 | 202 | #if defined OVERRIDE_DEFAULT 203 | #define CreateConVar CreateConVarCustom 204 | #define AutoExecConfig AutoExecConfigCustom 205 | #endif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/server_redirect.sp: -------------------------------------------------------------------------------- 1 | #include "sourcemod" 2 | #include "sdktools" 3 | #include "dhooks" 4 | #include "regex" 5 | 6 | #undef REQUIRE_EXTENSIONS 7 | #include "socket" 8 | #define REQUIRE_EXTENSIONS 9 | 10 | #include "glib/assertutils" 11 | #include "glib/addressutils" 12 | #include "glib/commandutils" 13 | 14 | #define OVERRIDE_DEFAULT 15 | #include "glib/colorutils" 16 | #include "glib/convarutils" 17 | #undef OVERRIDE_DEFAULT 18 | 19 | #define SNAME "[Server Redirect] " 20 | #define SERVER_REDIRECT_CFG "configs/server_redirect.cfg" 21 | 22 | #include "server_redirect/net.sp" 23 | #include "server_redirect/redirect.sp" 24 | 25 | public Plugin myinfo = 26 | { 27 | name = "Server redirect", 28 | author = "GAMMA CASE", 29 | description = "Allows to connect to other servers.", 30 | version = "1.3.2", 31 | url = "https://steamcommunity.com/id/_GAMMACASE_/" 32 | }; 33 | 34 | enum struct ServerEntry 35 | { 36 | char ip[32]; 37 | char alias_ip[32]; 38 | ArrayList players; 39 | Menu menu; 40 | Handle socket; 41 | char display_name[128]; 42 | char map[PLATFORM_MAX_PATH]; 43 | int maxplayers; 44 | int curr_players_info; 45 | int curr_players; 46 | bool password_protected; 47 | int challenge; 48 | 49 | void Delete() 50 | { 51 | delete this.players; 52 | delete this.menu; 53 | delete this.socket; 54 | } 55 | 56 | void Clear() 57 | { 58 | //display_name skipped intentionally 59 | this.map[0] = '\0'; 60 | this.maxplayers = 0; 61 | this.curr_players = 0; 62 | this.password_protected = false; 63 | this.challenge = 0; 64 | } 65 | 66 | char GetDisplayIP() 67 | { 68 | if(this.alias_ip[0] == '\0') 69 | return this.ip; 70 | else 71 | return this.alias_ip; 72 | } 73 | 74 | char CutIp() 75 | { 76 | int idx = FindCharInString(this.ip, ':', true); 77 | 78 | if(idx == -1) 79 | return this.ip; 80 | 81 | char _ip[32]; 82 | _ip = this.ip; 83 | _ip[idx] = '\0'; 84 | return _ip; 85 | } 86 | 87 | int CutPort() 88 | { 89 | int idx = FindCharInString(this.ip, ':', true); 90 | 91 | if(idx == -1) 92 | return 27015; 93 | 94 | return StringToInt(this.ip[idx + 1]); 95 | } 96 | } 97 | 98 | enum struct PlayerData 99 | { 100 | char name[MAX_NAME_LENGTH]; 101 | float time; 102 | } 103 | 104 | enum struct SocketData 105 | { 106 | char ip[32]; 107 | int num_of_recv; 108 | bool got_answer; 109 | bool got_player_data; 110 | int challenge_retries; 111 | Handle timeout; 112 | } 113 | 114 | methodmap ServerList < ArrayList 115 | { 116 | public ServerList() 117 | { 118 | return view_as(new ArrayList(sizeof(ServerEntry))); 119 | } 120 | 121 | public void DeleteServers() 122 | { 123 | ServerEntry se; 124 | for(int i = 0; i < this.Length; i++) 125 | { 126 | this.GetArray(i, se); 127 | se.Delete(); 128 | } 129 | } 130 | 131 | public int GetServer(const char[] ip, ServerEntry se) 132 | { 133 | int idx = this.FindString(ip); 134 | 135 | if(idx == -1) 136 | ThrowError(SNAME..."Unknown server ip (%s) is found in ServerList.", ip); 137 | else 138 | this.GetArray(idx, se); 139 | 140 | return idx; 141 | } 142 | 143 | public int GetServerByMenu(Menu menu, ServerEntry se) 144 | { 145 | for(int i = 0; i < this.Length; i++) 146 | { 147 | this.GetArray(i, se); 148 | if(menu == se.menu) 149 | return i; 150 | } 151 | 152 | return -1; 153 | } 154 | } 155 | 156 | ConVar gServerCommands, 157 | gSocketTimeoutTime, 158 | gShowPlayerInfo, 159 | gLogIfServerIsUnavailable, 160 | gDisableConnect, 161 | gCommandSpamTimeout, 162 | gAdvertisementTime, 163 | gAdvertisementMinPlayers, 164 | gAdvertisementOrder, 165 | gAdvertiseThis, 166 | gRemoveThis, 167 | gShowConfirmationMenu, 168 | gAnnounceLeave, 169 | gServersMenuPagination, 170 | gServersMenuServerNameLength; 171 | 172 | Menu gServersMenu, 173 | gActiveMenu[MAXPLAYERS]; 174 | 175 | int gMenuLastPos[MAXPLAYERS], 176 | gMenuServersLastItem[MAXPLAYERS]; 177 | 178 | ServerList gServers; 179 | ArrayList gUpdateQueue, 180 | gAdvertisementList; 181 | 182 | Handle gAdvertisementTimer; 183 | 184 | char gThisServerIp[32]; 185 | bool gSocketAvaliable; 186 | float gServersCooldown[MAXPLAYERS]; 187 | 188 | public void OnPluginStart() 189 | { 190 | gServerCommands = CreateConVar("server_redirect_commands", "sm_servers;sm_serv;sm_project;sm_list;", "Commands that invoke servers redirect menu.\n(Note: Map change required for changes to take effect! There's also a 128 character limit per command.)"); 191 | gSocketTimeoutTime = CreateConVar("server_redirect_socket_timeout", "10.0", "Socket timeout time.\n(Note: Unused if you don't use socket extension)", .hasMin = true, .min = 2.0); 192 | gShowPlayerInfo = CreateConVar("server_redirect_show_player_info", "1", "Show players info when you select server in servers redirect menu.\n(Note: Unused if you don't use socket extension)", .hasMin = true, .hasMax = true, .max = 1.0); 193 | gLogIfServerIsUnavailable = CreateConVar("server_redirect_log_if_server_is_unavailable", "0", "If communication with other servers is timed out, should this be logged?\n(Note: Unused if you don't use socket extension)", .hasMin = true, .hasMax = true, .max = 1.0); 194 | gDisableConnect = CreateConVar("server_redirect_disable_connect_button", "3", "Server connect button state:\n(Note: Unused if you don't use socket extension)\n0 - Always enabled;\n1 - Disabled if server is password protected, enabled otherwise;\n2 - Disabled if server is unavailable, enabled otherwise;\n3 - Enabled only if server is not password protected and avaliable.", .hasMin = true, .hasMax = true, .max = 3.0); 195 | gCommandSpamTimeout = CreateConVar("server_redirect_command_spam_timeout", "1.0", "Will prevent execution of a command if previous execution was less then this seconds before.", .hasMin = true); 196 | gAdvertisementTime = CreateConVar("server_redirect_advertisement_time", "60.0", "Server advertisement time in seconds (Map change required for this to take effect).\n(Note: set to 0 to disable)\n(Note2: this value should be bigger than server_redirect_socket_timeout by one second or more (Only if you have socket extension installed))", .hasMin = true); 197 | gAdvertisementMinPlayers = CreateConVar("server_redirect_advertisement_min_players", "0", "Minimum players required to advertise server in chat.\n(Note: Unused if you don't use socket extension)", .hasMin = true); 198 | gAdvertisementOrder = CreateConVar("server_redirect_advertisement_order", "0", "Order at which servers gonna be advertised.\n0 - Order at which servers are defined in config file;\n1 - Random order.", .hasMin = true, .hasMax = true, .max = 1.0); 199 | gAdvertiseThis = CreateConVar("server_redirect_advertise_this", "0", "If set, this current server will also be advertised in chat.\n(Note: Unused if server_redirect_remove_this set to 1!)", .hasMin = true, .hasMax = true, .max = 1.0); 200 | gRemoveThis = CreateConVar("server_redirect_remove_this", "0", "If set, this current server will be removed from servers menu.", .hasMin = true, .hasMax = true, .max = 1.0); 201 | gShowConfirmationMenu = CreateConVar("server_redirect_show_confirmation_menu", "0", "If set, will show confirmation menu when players will try to connect to some server via servers menu.", .hasMin = true, .hasMax = true, .max = 1.0); 202 | gAnnounceLeave = CreateConVar("server_redirect_show_advertisement_leave", "0", "If set, will show message to alert players a player has connected to another server.", .hasMin = true, .hasMax = true, .max = 1.0); 203 | gServersMenuPagination = CreateConVar("server_redirect_menu_pagination", "5", "The amount of items to show in servers list menu, if set to 0 default would be used (6 items per page).\n(Note: Lower this value if you have problems with server list menu not displaying everything)", .hasMin = true, .min = 2.0, .hasMax = true, .max = 6.0); 204 | gServersMenuServerNameLength = CreateConVar("server_redirect_menu_servername_length", "0", "The amount of symbols per server name to show in servers list menu, if set to 0 possible maximum would be used.\n(Note: Lower this value if you have problems with server list menu not displaying everything)", .hasMin = true, .hasMax = true, .max = 128.0); 205 | AutoExecConfig(); 206 | 207 | LoadTranslations("server_redirect.phrases"); 208 | 209 | RegAdminCmd("sm_refresh_servers", SM_RefreshServers, ADMFLAG_ROOT, "Reloads server_redirect.cfg file."); 210 | 211 | int hostip = FindConVar("hostip").IntValue; 212 | Format(gThisServerIp, sizeof(gThisServerIp), "%i.%i.%i.%i:%i", hostip >>> 24, hostip >> 16 & 0xFF, hostip >> 8 & 0xFF, hostip & 0xFF, FindConVar("hostport").IntValue); 213 | 214 | gUpdateQueue = new ArrayList(); 215 | gShouldReconnect = new StringMap(); 216 | gServers = new ServerList(); 217 | 218 | GameData gd = new GameData("server_redirect.games"); 219 | ASSERT_MSG(gd, "Can't open \"server_redirect.games.txt\" gamedata file."); 220 | 221 | InitNet(gd); 222 | SetupSDKCalls(gd); 223 | SetupDhooks(gd); 224 | 225 | delete gd; 226 | } 227 | 228 | public void OnAllPluginsLoaded() 229 | { 230 | gSocketAvaliable = GetExtensionFileStatus("socket.ext") == 1; 231 | } 232 | 233 | public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) 234 | { 235 | CreateNative("RedirectClient", RedirectClient_Native); 236 | RegPluginLibrary("server_redirect"); 237 | } 238 | 239 | public void OnClientDisconnect(int client) 240 | { 241 | gActiveMenu[client] = null; 242 | gMenuLastPos[client] = 0; 243 | gMenuServersLastItem[client] = 0; 244 | gServersCooldown[client] = 0.0; 245 | int idx = gUpdateQueue.FindValue(GetClientUserId(client)); 246 | if(idx != -1) 247 | gUpdateQueue.Erase(idx); 248 | } 249 | 250 | public void OnConfigsExecuted() 251 | { 252 | char buff[1024]; 253 | gServerCommands.GetString(buff, sizeof(buff)); 254 | RegConsoleCmds(buff, SM_Servers, "Displays servers list."); 255 | 256 | BuildPath(Path_SM, buff, sizeof(buff), SERVER_REDIRECT_CFG); 257 | 258 | gServers.DeleteServers(); 259 | gServers.Clear(); 260 | if(gServersMenu) 261 | gServersMenu.RemoveAllItems(); 262 | else 263 | gServersMenu = new Menu(Servers_Menu, MENU_ACTIONS_DEFAULT | MenuAction_DisplayItem | MenuAction_Display); 264 | 265 | if(!FileExists(buff)) 266 | { 267 | gServersMenu.AddItem("no_servers", "", ITEMDRAW_DISABLED); 268 | return; 269 | } 270 | 271 | KeyValues kv = new KeyValues("Servers"); 272 | kv.ImportFromFile(buff); 273 | 274 | if(!kv.GotoFirstSubKey()) 275 | { 276 | gServersMenu.AddItem("no_servers", "", ITEMDRAW_DISABLED); 277 | delete kv; 278 | return; 279 | } 280 | 281 | ServerEntry se; 282 | Regex re = new Regex("\\b[\\d{1,3}\\.]+\\:\\d{1,5}\\b"); 283 | 284 | do 285 | { 286 | kv.GetSectionName(buff, sizeof(buff)); 287 | 288 | kv.GetString("alias_ip", se.alias_ip, sizeof(ServerEntry::alias_ip)); 289 | 290 | kv.GetString("ip", se.ip, sizeof(ServerEntry::ip)); 291 | if(se.ip[0] == '\0') 292 | { 293 | LogError(SNAME..."Failed to get ip for section \"%s\" skipping.", buff); 294 | continue; 295 | } 296 | 297 | if(gRemoveThis.BoolValue && StrEqual(gThisServerIp, se.ip)) 298 | continue; 299 | 300 | if(gServers.FindString(se.ip) != -1) 301 | { 302 | LogError(SNAME..."Found duplicate ip address in section \"%s\" skipping.", buff); 303 | continue; 304 | } 305 | 306 | kv.GetString("display_name", se.display_name, sizeof(ServerEntry::display_name)); 307 | 308 | gServersMenu.AddItem(se.ip, se.display_name); 309 | 310 | se.menu = BuildServerInfoMenu(); 311 | 312 | gServers.PushArray(se); 313 | 314 | } while(kv.GotoNextKey()); 315 | 316 | delete re; 317 | delete kv; 318 | 319 | if(gSocketAvaliable) 320 | UpdateServersData(); 321 | 322 | if(gServersMenuPagination.IntValue != 0) 323 | gServersMenu.Pagination = gServersMenuPagination.IntValue; 324 | 325 | if(gServersMenu.ItemCount == 0) 326 | gServersMenu.AddItem("no_servers", "", ITEMDRAW_DISABLED); 327 | else if(gAdvertisementTime.FloatValue != 0.0) 328 | { 329 | if(gSocketAvaliable) 330 | { 331 | if(gAdvertisementTime.FloatValue - gSocketTimeoutTime.FloatValue - 1.0 <= 0.0) 332 | LogError(SNAME..."server_redirect_advertisement_time cvar should be bigger than server_redirect_socket_timeout by one second or more, advertisements are disabled!") 333 | else 334 | { 335 | gAdvertisementList = new ArrayList(); 336 | gAdvertisementTimer = CreateTimer(gAdvertisementTime.FloatValue - gSocketTimeoutTime.FloatValue - 1.0, Advertisement_Timer, .flags = TIMER_FLAG_NO_MAPCHANGE); 337 | } 338 | } 339 | else 340 | { 341 | gAdvertisementList = new ArrayList(); 342 | gAdvertisementTimer = CreateTimer(gAdvertisementTime.FloatValue, Advertisement_NoSocket_Timer, .flags = TIMER_FLAG_NO_MAPCHANGE | TIMER_REPEAT); 343 | } 344 | } 345 | else 346 | delete gAdvertisementList; 347 | } 348 | 349 | Menu BuildServerInfoMenu() 350 | { 351 | Menu menu = new Menu(ServerInfo_Menu, MENU_ACTIONS_DEFAULT | MenuAction_DisplayItem | MenuAction_DrawItem | MenuAction_Display); 352 | 353 | menu.AddItem("connect", ""); 354 | menu.AddItem("print_info", ""); 355 | 356 | menu.ExitBackButton = true; 357 | 358 | return menu; 359 | } 360 | 361 | void UpdateServersData() 362 | { 363 | ServerEntry se; 364 | SocketData sd; 365 | ArrayList data; 366 | for(int i = 0; i < gServers.Length; i++) 367 | { 368 | gServers.GetArray(i, se); 369 | 370 | if(se.socket) 371 | continue; 372 | 373 | data = new ArrayList(sizeof(SocketData)); 374 | 375 | sd.ip = se.ip; 376 | sd.num_of_recv = 1; 377 | sd.timeout = CreateTimer(gSocketTimeoutTime.FloatValue, Socket_Timeout_Timer, data); 378 | data.PushArray(sd); 379 | 380 | se.socket = SocketCreate(SOCKET_UDP, SocketCreate_Error); 381 | 382 | SocketSetArg(se.socket, data); 383 | SocketConnect(se.socket, Socket_Connected, Socket_Recieved, Socket_Disconnect, se.CutIp(), se.CutPort()); 384 | 385 | gServers.SetArray(i, se); 386 | } 387 | } 388 | 389 | public Action Advertisement_NoSocket_Timer(Handle timer) 390 | { 391 | if(gAdvertisementList.Length == 0) 392 | FillServersToAdvert(); 393 | 394 | ServerEntry se; 395 | GetServerToAdvert(se); 396 | AdvertiseServer(se); 397 | } 398 | 399 | public Action Advertisement_Timer(Handle timer) 400 | { 401 | if(gAdvertisementList.Length == 0) 402 | FillServersToAdvert(); 403 | 404 | UpdateServersData(); 405 | gAdvertisementTimer = CreateTimer(gSocketTimeoutTime.FloatValue + 1.0, Advertisement2_Timer, .flags = TIMER_FLAG_NO_MAPCHANGE); 406 | } 407 | 408 | public Action Advertisement2_Timer(Handle timer) 409 | { 410 | ServerEntry se; 411 | if(!GetServerToAdvert(se)) 412 | { 413 | FillServersToAdvert(); 414 | if(GetServerToAdvert(se)) 415 | AdvertiseServer(se); 416 | } 417 | else 418 | AdvertiseServer(se); 419 | 420 | gAdvertisementTimer = CreateTimer(gAdvertisementTime.FloatValue - gSocketTimeoutTime.FloatValue - 1.0, Advertisement_Timer, .flags = TIMER_FLAG_NO_MAPCHANGE); 421 | } 422 | 423 | void FillServersToAdvert() 424 | { 425 | gAdvertisementList.Clear(); 426 | 427 | for(int i = 0; i < gServers.Length; i++) 428 | gAdvertisementList.Push(i); 429 | } 430 | 431 | bool GetServerToAdvert(ServerEntry se) 432 | { 433 | switch(gAdvertisementOrder.IntValue) 434 | { 435 | case 0: 436 | { 437 | while(gAdvertisementList.Length != 0) 438 | { 439 | if(!FilterServerToAdvert(se)) 440 | continue; 441 | 442 | return true; 443 | } 444 | } 445 | 446 | case 1: 447 | { 448 | int idx; 449 | while(gAdvertisementList.Length != 0) 450 | { 451 | idx = GetRandomInt(0, gAdvertisementList.Length - 1); 452 | if(!FilterServerToAdvert(se, idx)) 453 | continue; 454 | 455 | return true; 456 | } 457 | } 458 | } 459 | 460 | return false; 461 | } 462 | 463 | bool FilterServerToAdvert(ServerEntry se, int idx = 0) 464 | { 465 | gServers.GetArray(gAdvertisementList.Get(idx), se); 466 | if(gSocketAvaliable && (se.maxplayers == 0 467 | || (se.curr_players < gAdvertisementMinPlayers.IntValue && se.curr_players_info < gAdvertisementMinPlayers.IntValue) 468 | || (!gAdvertiseThis.BoolValue && StrEqual(gThisServerIp, se.ip)))) 469 | { 470 | gAdvertisementList.Erase(idx); 471 | return false; 472 | } 473 | 474 | gAdvertisementList.Erase(idx); 475 | return true; 476 | } 477 | 478 | void AdvertiseServer(ServerEntry se) 479 | { 480 | char buff[32]; 481 | for(int i = 1; i <= MaxClients; i++) 482 | { 483 | if(!IsClientConnected(i) || !IsClientInGame(i) || IsFakeClient(i)) 484 | continue; 485 | 486 | if(gSocketAvaliable) 487 | { 488 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_slots_count", i, (se.curr_players == 0 ? se.curr_players_info : se.curr_players), se.maxplayers); 489 | PrintToChatColored(i, "%t", "server_advertisement_server_name", se.display_name); 490 | PrintToChatColored(i, "%t", "server_advertisement_server_stats", buff, se.GetDisplayIP()); 491 | } 492 | else 493 | { 494 | PrintToChatColored(i, "%t", "server_advertisement_no_socket_server_name", se.display_name); 495 | PrintToChatColored(i, "%t", "server_advertisement_no_socket_server_stats", se.GetDisplayIP()); 496 | } 497 | } 498 | } 499 | 500 | public Action Socket_Timeout_Timer(Handle timer, ArrayList data) 501 | { 502 | SocketData sd; 503 | data.GetArray(0, sd); 504 | 505 | if(!sd.got_answer && gLogIfServerIsUnavailable.BoolValue) 506 | LogMessage(SNAME..."Can't get response from \"%s\", socket timed out.", sd.ip); 507 | 508 | ServerEntry se; 509 | int idx = gServers.GetServer(sd.ip, se); 510 | if(idx != -1) 511 | { 512 | if(!sd.got_answer) 513 | se.Clear(); 514 | 515 | if(!sd.got_player_data) 516 | if(se.players) 517 | delete se.players; 518 | 519 | delete se.socket; 520 | gServers.SetArray(idx, se); 521 | } 522 | 523 | for(int client = 0; gUpdateQueue.Length != 0;) 524 | { 525 | client = GetClientOfUserId(gUpdateQueue.Get(0)); 526 | if(client != 0 && gActiveMenu[client]) 527 | gActiveMenu[client].DisplayAt(client, gMenuLastPos[client], MENU_TIME_FOREVER); 528 | gUpdateQueue.Erase(0); 529 | } 530 | 531 | delete data; 532 | } 533 | 534 | public Action SM_RefreshServers(int client, int args) 535 | { 536 | if(gAdvertisementTimer) 537 | delete gAdvertisementTimer; 538 | OnConfigsExecuted(); 539 | ReplyToCommand(client, SNAME..."Servers list was updated."); 540 | 541 | return Plugin_Handled; 542 | } 543 | 544 | public Action SM_Servers(int client, int args) 545 | { 546 | if(!IsValidCmd()) 547 | return Plugin_Continue; 548 | 549 | if(client == 0) 550 | return Plugin_Handled; 551 | 552 | if(IsSpamming(gServersCooldown[client], gCommandSpamTimeout.FloatValue)) 553 | { 554 | ReplyToCommand(client, "%T", "command_spam_attempt", client); 555 | return Plugin_Handled; 556 | } 557 | 558 | if(gSocketAvaliable) 559 | { 560 | gUpdateQueue.Push(GetClientUserId(client)); 561 | UpdateServersData(); 562 | } 563 | 564 | gServersMenu.Display(client, MENU_TIME_FOREVER); 565 | 566 | return Plugin_Handled; 567 | } 568 | 569 | public int Servers_Menu(Menu menu, MenuAction action, int param1, int param2) 570 | { 571 | switch(action) 572 | { 573 | case MenuAction_Display: 574 | { 575 | menu.SetTitle("%T\n ", "servers_menu_title", param1); 576 | gActiveMenu[param1] = menu; 577 | if(gUpdateQueue.FindValue(GetClientUserId(param1)) == -1) 578 | gUpdateQueue.Push(GetClientUserId(param1)); 579 | } 580 | 581 | case MenuAction_DisplayItem: 582 | { 583 | if(param2 >= gMenuLastPos[param1] + gServersMenuPagination.IntValue || param2 <= gMenuLastPos[param1] - gServersMenuPagination.IntValue) 584 | gMenuLastPos[param1] = param2; 585 | 586 | char buff[128]; 587 | menu.GetItem(param2, buff, sizeof(buff)); 588 | 589 | if(StrEqual(buff, "no_servers")) 590 | { 591 | Format(buff, sizeof(buff), "%T", "servers_menu_no_servers", param1); 592 | return RedrawMenuItem(buff); 593 | } 594 | 595 | ServerEntry se; 596 | if(gServers.GetServer(buff, se) == -1) 597 | return 0; 598 | 599 | if(gSocketAvaliable) 600 | { 601 | char buff2[PLATFORM_MAX_PATH]; 602 | if(se.maxplayers == 0) 603 | { 604 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_not_available", param1); 605 | Format(buff2, sizeof(buff2), "%T", "servinfo_menu_map_not_available", param1); 606 | Format(buff2, sizeof(buff2), "%T", "servinfo_menu_server_entry_mapname", param1, buff2); 607 | } 608 | else 609 | { 610 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_slots_count", param1, (se.curr_players == 0 ? se.curr_players_info : se.curr_players), se.maxplayers); 611 | Format(buff2, sizeof(buff2), "%T", "servinfo_menu_server_entry_mapname", param1, GetTrueMapName(se.map)); 612 | } 613 | Format(buff, sizeof(buff), "%T\n%s", "servers_menu_server_entry", param1, buff, TrimServerName(se.display_name), buff2); 614 | } 615 | else 616 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_no_socket", param1, se.display_name); 617 | 618 | return RedrawMenuItem(buff); 619 | } 620 | 621 | case MenuAction_Select: 622 | { 623 | char buff[32]; 624 | menu.GetItem(param2, buff, sizeof(buff)); 625 | gMenuServersLastItem[param1] = menu.Selection; 626 | ShowServerInfoMenu(param1, buff); 627 | } 628 | 629 | case MenuAction_Cancel: 630 | { 631 | if(!IsClientInGame(param1)) 632 | return 0; 633 | 634 | gActiveMenu[param1] = null; 635 | gMenuLastPos[param1] = 0; 636 | 637 | int idx = gUpdateQueue.FindValue(GetClientUserId(param1)); 638 | if(idx != -1) 639 | gUpdateQueue.Erase(idx); 640 | } 641 | } 642 | 643 | return 0; 644 | } 645 | 646 | void ShowServerInfoMenu(int client, const char[] ip) 647 | { 648 | ServerEntry se; 649 | if(gServers.GetServer(ip, se) != -1) 650 | se.menu.Display(client, MENU_TIME_FOREVER); 651 | } 652 | 653 | public int ServerInfo_Menu(Menu menu, MenuAction action, int param1, int param2) 654 | { 655 | switch(action) 656 | { 657 | case MenuAction_DrawItem: 658 | { 659 | ServerEntry se; 660 | gServers.GetServerByMenu(menu, se); 661 | 662 | char buff[32]; 663 | int style; 664 | menu.GetItem(param2, buff, sizeof(buff), style); 665 | 666 | if(StrEqual(buff, "connect")) 667 | { 668 | if(!gSocketAvaliable) 669 | return ITEMDRAW_DEFAULT; 670 | 671 | if(StrEqual(gThisServerIp, se.ip)) 672 | return ITEMDRAW_DISABLED; 673 | 674 | switch(gDisableConnect.IntValue) 675 | { 676 | case 0: 677 | return ITEMDRAW_DEFAULT; 678 | 679 | case 1: 680 | if(se.password_protected) 681 | return ITEMDRAW_DISABLED; 682 | 683 | case 2: 684 | if(se.maxplayers == 0) 685 | return ITEMDRAW_DISABLED; 686 | 687 | case 3: 688 | if(se.maxplayers == 0 || se.password_protected) 689 | return ITEMDRAW_DISABLED; 690 | } 691 | } 692 | else if(!StrEqual(buff, "print_info")) 693 | { 694 | if(!se.players || StringToInt(buff) >= se.players.Length || se.maxplayers == 0 || !gShowPlayerInfo.BoolValue || !gSocketAvaliable) 695 | return ITEMDRAW_IGNORE; 696 | else 697 | return ITEMDRAW_DISABLED; 698 | } 699 | 700 | return style; 701 | } 702 | 703 | case MenuAction_Display: 704 | { 705 | ServerEntry se; 706 | gServers.GetServerByMenu(menu, se); 707 | 708 | char map[PLATFORM_MAX_PATH]; 709 | if(se.map[0] == '\0') 710 | Format(map, sizeof(map), "%T", "servinfo_menu_map_not_available", param1); 711 | else 712 | map = GetTrueMapName(se.map); 713 | 714 | if(!gSocketAvaliable) 715 | menu.SetTitle("%T\n ", "servinfo_menu_title_no_socket", param1, se.display_name, se.GetDisplayIP()); 716 | else if(gShowPlayerInfo.BoolValue) 717 | menu.SetTitle("%T\n ", "servinfo_menu_title", param1, se.display_name, se.GetDisplayIP(), map); 718 | else 719 | { 720 | char buff[32]; 721 | if(se.maxplayers != 0) 722 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_slots_count", param1, (se.curr_players == 0 ? se.curr_players_info : se.curr_players), se.maxplayers); 723 | else 724 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_not_available", param1); 725 | menu.SetTitle("%T\n ", "servinfo_menu_title_no_player_info", param1, se.display_name, se.GetDisplayIP(), map, buff); 726 | } 727 | 728 | gActiveMenu[param1] = menu; 729 | if(gUpdateQueue.FindValue(GetClientUserId(param1)) == -1) 730 | gUpdateQueue.Push(GetClientUserId(param1)); 731 | } 732 | 733 | case MenuAction_DisplayItem: 734 | { 735 | if(param2 >= gMenuLastPos[param1] + 6 || param2 <= gMenuLastPos[param1] - 6) 736 | gMenuLastPos[param1] = param2; 737 | 738 | char buff[256]; 739 | menu.GetItem(param2, buff, sizeof(buff)); 740 | 741 | ServerEntry se; 742 | gServers.GetServerByMenu(menu, se); 743 | 744 | if(StrEqual(buff, "connect")) 745 | { 746 | buff[0] = '\0'; 747 | 748 | if(StrEqual(gThisServerIp, se.ip)) 749 | Format(buff, sizeof(buff), "%T", "servinfo_menu_connect_current", param1); 750 | else if(gSocketAvaliable) 751 | { 752 | switch(gDisableConnect.IntValue) 753 | { 754 | case 1: 755 | if(se.password_protected) 756 | Format(buff, sizeof(buff), "%T", "servinfo_menu_connect_password_protected", param1); 757 | 758 | case 2: 759 | if(se.maxplayers == 0) 760 | Format(buff, sizeof(buff), "%T", "servinfo_menu_connect_unavailable", param1); 761 | 762 | case 3: 763 | { 764 | if(se.maxplayers == 0) 765 | Format(buff, sizeof(buff), "%T", "servinfo_menu_connect_unavailable", param1); 766 | else if(se.password_protected) 767 | Format(buff, sizeof(buff), "%T", "servinfo_menu_connect_password_protected", param1); 768 | } 769 | } 770 | } 771 | 772 | Format(buff, sizeof(buff), "%T %s", "servinfo_menu_connect", param1, buff); 773 | } 774 | else if(StrEqual(buff, "print_info")) 775 | { 776 | if(gShowPlayerInfo.BoolValue && gSocketAvaliable) 777 | { 778 | if(se.maxplayers != 0) 779 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_slots_count", param1, (se.curr_players == 0 ? se.curr_players_info : se.curr_players), se.maxplayers); 780 | else 781 | Format(buff, sizeof(buff), "%T", "servers_menu_server_entry_not_available", param1); 782 | Format(buff, sizeof(buff), "%T\n \n%T", "servinfo_menu_print", param1, "servinfo_menu_players", param1, buff); 783 | 784 | if(se.curr_players == 0 && se.curr_players_info == 0 && se.maxplayers != 0) 785 | Format(buff, sizeof(buff), "%s\n%T", buff, "servinfo_menu_players_no_players", param1); 786 | else if(!se.players || menu.ItemCount == 2 || se.maxplayers == 0) 787 | Format(buff, sizeof(buff), "%s\n%T", buff, "servinfo_menu_players_data_unavailable", param1); 788 | } 789 | else 790 | Format(buff, sizeof(buff), "%T", "servinfo_menu_print", param1); 791 | } 792 | else if(gSocketAvaliable && gShowPlayerInfo.BoolValue && se.players) 793 | { 794 | int idx = StringToInt(buff); 795 | 796 | if(idx >= se.players.Length) 797 | return 0; 798 | 799 | PlayerData pd; 800 | se.players.GetArray(idx, pd); 801 | 802 | FormatTimeCustom(pd.time, buff, sizeof(buff)); 803 | Format(buff, sizeof(buff), "%T", "servinfo_menu_player_entry", param1, idx + 1, pd.name, buff); 804 | } 805 | 806 | return RedrawMenuItem(buff); 807 | } 808 | 809 | case MenuAction_Select: 810 | { 811 | char buff[256]; 812 | menu.GetItem(param2, buff, sizeof(buff)); 813 | 814 | ServerEntry se; 815 | gServers.GetServerByMenu(menu, se); 816 | 817 | if(StrEqual(buff, "connect")) 818 | if(gShowConfirmationMenu.BoolValue) 819 | { 820 | int idx = gUpdateQueue.FindValue(GetClientUserId(param1)); 821 | if(idx != -1) 822 | gUpdateQueue.Erase(idx); 823 | 824 | Menu cmenu = new Menu(Confirmation_Menu); 825 | 826 | cmenu.SetTitle("%T\n ", "confirmation_menu_title", param1, se.ip); 827 | 828 | char buff2[32]; 829 | Format(buff, sizeof(buff), "%T", "confirmation_menu_continue", param1); 830 | Format(buff2, sizeof(buff2), "c%s", se.ip); 831 | cmenu.AddItem(buff2, buff); 832 | 833 | Format(buff, sizeof(buff), "%T", "confirmation_menu_notnow", param1); 834 | Format(buff2, sizeof(buff2), "b%s", se.ip); 835 | cmenu.AddItem(buff2, buff); 836 | 837 | cmenu.Display(param1, MENU_TIME_FOREVER); 838 | } 839 | else 840 | { 841 | if(gAnnounceLeave.BoolValue) 842 | { 843 | for(int i = 1; i <= MaxClients; i++) 844 | { 845 | if(!IsClientConnected(i) || !IsClientInGame(i) || IsFakeClient(i)) 846 | continue; 847 | 848 | PrintToChatColored(i, "%t", "server_advertisement_leave", param1, se.GetDisplayIP()); 849 | } 850 | } 851 | 852 | RedirectClient(param1, se.GetDisplayIP()); 853 | } 854 | else if(StrEqual(buff, "print_info")) 855 | { 856 | menu.Display(param1, MENU_TIME_FOREVER); 857 | PrintToConsole(param1, "%T", "server_info", param1, se.display_name, se.GetDisplayIP()); 858 | } 859 | } 860 | 861 | case MenuAction_Cancel: 862 | { 863 | if(!IsClientInGame(param1)) 864 | return 0; 865 | 866 | gActiveMenu[param1] = null; 867 | gMenuLastPos[param1] = 0; 868 | 869 | if(param2 == MenuCancel_ExitBack) 870 | gServersMenu.DisplayAt(param1, gMenuServersLastItem[param1], MENU_TIME_FOREVER); 871 | 872 | int idx = gUpdateQueue.FindValue(GetClientUserId(param1)); 873 | if(idx != -1) 874 | gUpdateQueue.Erase(idx); 875 | } 876 | } 877 | 878 | return 0; 879 | } 880 | 881 | public int Confirmation_Menu(Menu menu, MenuAction action, int param1, int param2) 882 | { 883 | switch(action) 884 | { 885 | case MenuAction_Select: 886 | { 887 | char buff[32]; 888 | menu.GetItem(param2, buff, sizeof(buff)); 889 | 890 | if(buff[0] == 'c') 891 | { 892 | if(gAnnounceLeave.BoolValue) 893 | { 894 | for(int i = 1; i <= MaxClients; i++) 895 | { 896 | if(!IsClientConnected(i) || !IsClientInGame(i) || IsFakeClient(i)) 897 | continue; 898 | 899 | PrintToChatColored(i, "%t", "server_advertisement_leave", param1, buff[1]); 900 | } 901 | } 902 | 903 | RedirectClient(param1, buff[1]); 904 | } 905 | else 906 | ShowServerInfoMenu(param1, buff[1]); 907 | } 908 | 909 | case MenuAction_End: 910 | delete menu; 911 | } 912 | 913 | return 0; 914 | } 915 | 916 | public int SortPlayerInfo(int index1, int index2, Handle array, Handle hndl) 917 | { 918 | ArrayList al = view_as(array); 919 | PlayerData pd; 920 | 921 | al.GetArray(index1, pd); 922 | float time1 = pd.time; 923 | al.GetArray(index2, pd); 924 | 925 | if(time1 < pd.time) 926 | return 1; 927 | else if(time1 == pd.time) 928 | return 0; 929 | else 930 | return -1; 931 | } 932 | 933 | public void Socket_Connected(Socket socket, ArrayList data) 934 | { 935 | char buff[32]; 936 | SocketData sd; 937 | data.GetArray(0, sd); 938 | 939 | ServerEntry se; 940 | int idx = gServers.GetServer(sd.ip, se); 941 | 942 | if(idx == -1) 943 | return; 944 | 945 | if(se.challenge == 0) 946 | SocketSend(socket, "\xFF\xFF\xFF\xFF\x54Source Engine Query\0", 25); 947 | else 948 | { 949 | Format(buff, sizeof(buff), "\xFF\xFF\xFF\xFF\x54Source Engine QueryA%c%c%c%c", se.challenge & 0xFF, se.challenge >> 8 & 0xFF, se.challenge >> 16 & 0xFF, se.challenge >>> 24); 950 | // Server expectes zero terminated string, so hacking around the Format() function here 951 | buff[24] = '\0'; 952 | SocketSend(socket, buff, 29); 953 | } 954 | 955 | if(gShowPlayerInfo.BoolValue) 956 | { 957 | if(se.challenge == 0) 958 | { 959 | sd.num_of_recv++; 960 | SocketSend(socket, "\xFF\xFF\xFF\xFF\x55\xFF\xFF\xFF\xFF", 9); 961 | } 962 | else 963 | { 964 | sd.num_of_recv++; 965 | Format(buff, sizeof(buff), "\xFF\xFF\xFF\xFF\x55%c%c%c%c", se.challenge & 0xFF, se.challenge >> 8 & 0xFF, se.challenge >> 16 & 0xFF, se.challenge >>> 24); 966 | SocketSend(socket, buff, 9); 967 | } 968 | 969 | data.SetArray(0, sd); 970 | } 971 | } 972 | 973 | public void Socket_Recieved(Socket socket, const char[] data, const int dataSize, ArrayList sock_data) 974 | { 975 | SocketData sd; 976 | sock_data.GetArray(0, sd); 977 | 978 | if(data[0] != 0xFF || data[1] != 0xFF || data[2] != 0xFF || data[3] != 0xFF) 979 | { 980 | LogError(SNAME..."Received invalid packet for server \"%s\".", sd.ip); 981 | return; 982 | } 983 | 984 | ServerEntry se; 985 | int offs = 5, idx = gServers.GetServer(sd.ip, se); 986 | if(idx == -1) 987 | return; 988 | 989 | switch(data[4]) 990 | { 991 | // 'I' 992 | case 0x49: 993 | { 994 | sd.got_answer = true; 995 | 996 | offs++; 997 | offs += ByteStream_ReadString(data[offs], se.display_name, sizeof(ServerEntry::display_name)); 998 | offs += ByteStream_ReadString(data[offs], se.map, sizeof(ServerEntry::map)); 999 | 1000 | offs += ByteStream_ReadUntilNull(data[offs]); 1001 | offs += ByteStream_ReadUntilNull(data[offs]) + 2; 1002 | 1003 | se.curr_players_info = data[offs++]; 1004 | se.maxplayers = data[offs]; 1005 | offs += 4; 1006 | se.password_protected = !!data[offs]; 1007 | } 1008 | 1009 | // 'A' 1010 | case 0x41: 1011 | { 1012 | if(++sd.challenge_retries > 3) 1013 | ThrowError(SNAME..."Something went wrong with receiving challenge token for server %s! Preventing infinite loop....", se.ip); 1014 | 1015 | ByteStream_Read32(data[offs], se.challenge); 1016 | sd.num_of_recv++; 1017 | 1018 | char buff[32]; 1019 | 1020 | if(!sd.got_player_data && gShowPlayerInfo.BoolValue) 1021 | { 1022 | Format(buff, sizeof(buff), "\xFF\xFF\xFF\xFF\x55%c%c%c%c", se.challenge & 0xFF, se.challenge >> 8 & 0xFF, se.challenge >> 16 & 0xFF, se.challenge >>> 24); 1023 | SocketSend(socket, buff, 9); 1024 | } 1025 | 1026 | if(!sd.got_answer) 1027 | { 1028 | Format(buff, sizeof(buff), "\xFF\xFF\xFF\xFF\x54Source Engine QueryA%c%c%c%c", se.challenge & 0xFF, se.challenge >> 8 & 0xFF, se.challenge >> 16 & 0xFF, se.challenge >>> 24); 1029 | // Server expectes zero terminated string, so hacking around the Format() function here 1030 | buff[24] = '\0'; 1031 | SocketSend(socket, buff, 29); 1032 | } 1033 | } 1034 | 1035 | // 'D' 1036 | case 0x44: 1037 | { 1038 | sd.challenge_retries = 0; 1039 | sd.got_player_data = true; 1040 | 1041 | se.curr_players = data[offs++]; 1042 | if(se.curr_players > 0) 1043 | { 1044 | if(se.players) 1045 | se.players.Clear(); 1046 | else 1047 | se.players = new ArrayList(sizeof(PlayerData)); 1048 | 1049 | PlayerData pd; 1050 | char buff[32]; 1051 | while(offs < dataSize) 1052 | { 1053 | offs++; 1054 | offs += ByteStream_ReadString(data[offs], pd.name, sizeof(PlayerData::name)); 1055 | 1056 | if(pd.name[0] == '\0') 1057 | strcopy(pd.name, sizeof(PlayerData::name), "???"); 1058 | 1059 | offs += 4; 1060 | 1061 | // Safe guard for malformed packets, not sure how else to catch such packets 1062 | if(offs + 4 > dataSize) 1063 | break; 1064 | 1065 | offs += ByteStream_Read32(data[offs], pd.time); 1066 | se.players.PushArray(pd); 1067 | } 1068 | 1069 | SortADTArrayCustom(se.players, SortPlayerInfo); 1070 | for(int i = se.menu.ItemCount; i < se.players.Length + 2; i++) 1071 | { 1072 | IntToString(i - 2, buff, sizeof(buff)); 1073 | se.menu.AddItem(buff, "", ITEMDRAW_DISABLED); 1074 | } 1075 | } 1076 | } 1077 | 1078 | default: 1079 | { 1080 | char c = data[4]; 1081 | LogError(SNAME..."Unknown response type (%02X) was received (%s).", c, sd.ip); 1082 | } 1083 | } 1084 | 1085 | sd.num_of_recv--; 1086 | 1087 | if(sd.num_of_recv == 0) 1088 | { 1089 | delete se.socket; 1090 | delete sd.timeout; 1091 | delete sock_data; 1092 | } 1093 | else 1094 | sock_data.SetArray(0, sd); 1095 | 1096 | gServers.SetArray(idx, se); 1097 | 1098 | for(int client = 0; gUpdateQueue.Length != 0;) 1099 | { 1100 | client = GetClientOfUserId(gUpdateQueue.Get(0)); 1101 | if(client != 0 && gActiveMenu[client] && (data[4] == 0x49 || sd.num_of_recv == 0)) 1102 | gActiveMenu[client].DisplayAt(client, gMenuLastPos[client], MENU_TIME_FOREVER); 1103 | gUpdateQueue.Erase(0); 1104 | } 1105 | } 1106 | 1107 | public void Socket_Disconnect(Socket socket, any arg) { } 1108 | 1109 | public void SocketCreate_Error(Socket socket, const int errorType, const int errorNum, ArrayList data) 1110 | { 1111 | //I guess this can be empty as timeout timer handles this pretty well. 1112 | } 1113 | 1114 | // For debugging purposes only 1115 | stock bool ByteStream_Dump(const char[] stream, int len, int columns = 10) 1116 | { 1117 | char chr, buff[128], buff2[128]; 1118 | buff = "[0]"; 1119 | for(int i = 0; i < len; i++) 1120 | { 1121 | chr = stream[i]; 1122 | Format(buff, sizeof(buff), "%s %02X", buff, chr); 1123 | Format(buff2, sizeof(buff2), "%s%c", buff2, (chr > ' ' && chr != 0x7F && chr != 0xFF ? chr : '.')); 1124 | if(i % columns == columns - 1) 1125 | { 1126 | PrintToServer(SNAME..."%s %s", buff, buff2); 1127 | Format(buff, sizeof(buff), "[%i]", i + 1); 1128 | buff2[0] = '\0'; 1129 | } 1130 | } 1131 | 1132 | if((len - 1) % columns != columns - 1) 1133 | PrintToServer(SNAME..."%s %s", buff, buff2); 1134 | } 1135 | 1136 | stock bool IsSpamming(float &time_of_use, float wait_time = 5.0) 1137 | { 1138 | if(time_of_use + wait_time > GetGameTime()) 1139 | return true; 1140 | else 1141 | { 1142 | time_of_use = GetGameTime(); 1143 | return false; 1144 | } 1145 | } 1146 | 1147 | stock int ByteStream_Read32(const char[] data, any &buff) 1148 | { 1149 | buff = view_as(data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24); 1150 | return 4; 1151 | } 1152 | 1153 | stock int ByteStream_ReadString(const char[] data, char[] buff, int size, bool full = true) 1154 | { 1155 | int i; 1156 | while(data[i] && i < size) 1157 | buff[i] = data[i++]; 1158 | buff[i] = '\0'; 1159 | if(full) 1160 | while(data[i++]) {} 1161 | return i; 1162 | } 1163 | 1164 | stock int ByteStream_ReadUntilNull(const char[] data) 1165 | { 1166 | int i; 1167 | while(data[i++]) {} 1168 | return i; 1169 | } 1170 | 1171 | stock void FormatTimeCustom(float time, char[] buff, int size) 1172 | { 1173 | int hours = RoundToFloor(time / 3600.0); 1174 | time -= float(hours * 3600); 1175 | int minutes = RoundToFloor(time / 60.0); 1176 | time -= float(minutes * 60); 1177 | 1178 | if(hours > 0) 1179 | Format(buff, size, "%d:%02d:%02.0f", hours, minutes, time); 1180 | else 1181 | Format(buff, size, "%d:%02.0f", minutes, time); 1182 | } 1183 | 1184 | stock char[] GetTrueMapName(const char fullmap[PLATFORM_MAX_PATH]) 1185 | { 1186 | char map[PLATFORM_MAX_PATH]; 1187 | map = fullmap; 1188 | 1189 | int idx = FindCharInString(map, '/', true); 1190 | if(idx != -1) 1191 | strcopy(map, sizeof(map), map[idx + 1]); 1192 | 1193 | idx = FindCharInString(map, '\\', true); 1194 | if(idx != -1) 1195 | strcopy(map, sizeof(map), map[idx + 1]); 1196 | 1197 | return map; 1198 | } 1199 | 1200 | stock char[] TrimServerName(const char servername[sizeof(ServerEntry::display_name)]) 1201 | { 1202 | if(gServersMenuServerNameLength.IntValue == 0) 1203 | return servername; 1204 | 1205 | char name[sizeof(ServerEntry::display_name)]; 1206 | 1207 | int count, finallen; 1208 | for(int i = 0; servername[i]; i++) 1209 | { 1210 | count += ((servername[i] & 0xc0) != 0x80) ? 1 : 0; 1211 | 1212 | if(count <= gServersMenuServerNameLength.IntValue) 1213 | { 1214 | name[i] = servername[i]; 1215 | finallen = i; 1216 | } 1217 | } 1218 | 1219 | name[finallen] = '\0'; 1220 | 1221 | if(count > gServersMenuServerNameLength.IntValue) 1222 | Format(name, sizeof(name), "%s...", name); 1223 | return name; 1224 | } --------------------------------------------------------------------------------