Advertisement
Guest User

Untitled

a guest
Jun 29th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.09 KB | None | 0 0
  1. /*
  2. * =============================================================================
  3. * MOTDgd In-Game Advertisements
  4. * Displays MOTDgd Related In-Game Advertisements
  5. *
  6. * Copyright (C)2013-2015 MOTDgd Ltd. All rights reserved.
  7. * =============================================================================
  8. *
  9. * This program is free software; you can redistribute it and/or modify it under
  10. * the terms of the GNU General Public License, version 3.0, as published by the
  11. * Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21.  
  22. // ====[ INCLUDES | DEFINES ]============================================================
  23. #pragma semicolon 1
  24. #include <sourcemod>
  25.  
  26. #define STRING(%1) %1, sizeof(%1)
  27.  
  28. #include <EasyHTTP2>
  29. #include <json>
  30.  
  31. #define PLUGIN_VERSION "2.2.9"
  32.  
  33. // ====[ HANDLES | CVARS | VARIABLES ]===================================================
  34. new Handle:g_motdID;
  35. new Handle:g_OnConnect;
  36. new Handle:g_immunity;
  37. new Handle:g_OnOther;
  38. new Handle:g_Review;
  39. new Handle:g_Preload;
  40. new Handle:g_Chat;
  41.  
  42. new const String:g_GamesSupported[][] = {
  43. "tf",
  44. "csgo",
  45. "cstrike",
  46. "dod",
  47. "nucleardawn",
  48. "hl2mp",
  49. "left4dead",
  50. "left4dead2",
  51. "nmrih",
  52. "fof"
  53. };
  54. new const String:g_GamesPreloadSupported[][] = {
  55. "tf"
  56. };
  57. new String:gameDir[255];
  58. new String:g_serverIP[16];
  59.  
  60. new g_serverPort;
  61. new g_timepending[MAXPLAYERS+1];
  62. new g_preloadCheckTime[MAXPLAYERS+1] = { 0, ... };
  63. new g_shownTeamVGUI[MAXPLAYERS+1] = { false, ... };
  64. new g_lastView[MAXPLAYERS+1];
  65.  
  66. new bool:VGUICaught[MAXPLAYERS+1];
  67. new bool:CanReview;
  68. new bool:HTTPCommSupported;
  69. new bool:LateLoad;
  70.  
  71. // ====[ PLUGIN | FORWARDS ]========================================================================
  72. public Plugin:myinfo =
  73. {
  74. name = "MOTDgd Adverts",
  75. author = "Blackglade and Ixel",
  76. description = "Displays MOTDgd In-Game Advertisements",
  77. version = PLUGIN_VERSION,
  78. url = "http://motdgd.com"
  79. }
  80.  
  81. public OnPluginStart()
  82. {
  83. // Global Server Variables //
  84. new bool:exists = false;
  85. GetGameFolderName(gameDir, sizeof(gameDir));
  86. for (new i = 0; i < sizeof(g_GamesSupported); i++)
  87. {
  88. if (StrEqual(g_GamesSupported[i], gameDir))
  89. {
  90. exists = true;
  91. break;
  92. }
  93. }
  94. if (!exists)
  95. SetFailState("The game '%s' isn't currently supported by the MOTDgd plugin!", gameDir);
  96. exists = false;
  97.  
  98. new Handle:serverIP = FindConVar("hostip");
  99. new Handle:serverPort = FindConVar("hostport");
  100. if (serverIP == INVALID_HANDLE || serverPort == INVALID_HANDLE)
  101. SetFailState("Could not determine server ip and port.");
  102.  
  103. new IP = GetConVarInt(serverIP);
  104. g_serverPort = GetConVarInt(serverPort);
  105. Format(g_serverIP, sizeof(g_serverIP), "%d.%d.%d.%d", IP >>> 24 & 255, IP >>> 16 & 255, IP >>> 8 & 255, IP & 255);
  106.  
  107. // Plugin ConVars //
  108. CreateConVar("sm_motdgd_version", PLUGIN_VERSION, "[SM] MOTDgd Plugin Version", FCVAR_NOTIFY|FCVAR_DONTRECORD);
  109.  
  110. g_motdID = CreateConVar("sm_motdgd_userid", "0", "MOTDgd User ID. This number can be found at: http://motdgd.com/portal/", FCVAR_NOTIFY);
  111. g_immunity = CreateConVar("sm_motdgd_immunity", "0", "Enable/Disable advert immunity");
  112. g_OnConnect = CreateConVar("sm_motdgd_onconnect", "1", "Enable/Disable advert on connect");
  113. g_Preload = CreateConVar("sm_motdgd_preload", "0", "Maximum seconds allowed for preloading the advertisement (if supported), a setting of 0 disables preloading");
  114. g_Chat = CreateConVar("sm_motdgd_chat", "1", "Enable chat advertisements");
  115. // Global Server Variables //
  116.  
  117. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  118. {
  119. g_OnOther = CreateConVar("sm_motdgd_onother", "2", "Set 0 to disable, 1 to show on round end, 2 to show on player death, 4 to show on round start, 3=1+2, 5=1+4, 6=2+4, 7=1+2+4");
  120. g_Review = CreateConVar("sm_motdgd_review", "15.0", "Set time (in minutes) to re-display the ad. ConVar sm_motdgd_onother must be configured", _, true, 15.0);
  121. }
  122.  
  123. for (new i = 0; i < sizeof(g_GamesPreloadSupported); i++)
  124. {
  125. if (StrEqual(g_GamesPreloadSupported[i], gameDir))
  126. {
  127. exists = true;
  128. break;
  129. }
  130. }
  131. if (!exists)
  132. {
  133. HTTPCommSupported = false;
  134. }
  135. else
  136. {
  137. // Check connection can be made to motd.gd for ability to preload advertisement
  138. new String:requestURL[PLATFORM_MAX_PATH];
  139. Format(requestURL, sizeof(requestURL), "http://motd.gd", GetConVarInt(g_motdID), gameDir);
  140. if (EasyHTTP(requestURL, GetSteamData_Null_Completed, 0))
  141. HTTPCommSupported = true;
  142. else
  143. HTTPCommSupported = false;
  144. }
  145.  
  146. if (!HTTPCommSupported)
  147. {
  148. LogMessage("Advertisement preload isn't possible as either the cURL or Socket extension isn't installed or this server is running an unsupported game");
  149. }
  150. // Plugin ConVars //
  151.  
  152. // MOTDgd MOTD Stuff //
  153. new UserMsg:datVGUIMenu = GetUserMessageId("VGUIMenu");
  154. if (datVGUIMenu == INVALID_MESSAGE_ID)
  155. SetFailState("The game '%s' doesn't support VGUI menus.", gameDir);
  156. HookUserMessage(datVGUIMenu, OnVGUIMenu, true);
  157. AddCommandListener(ClosedMOTD, "closed_htmlpage");
  158.  
  159. HookEventEx("player_transitioned", Event_PlayerTransitioned);
  160. HookEventEx("player_death", Event_Death);
  161. HookEventEx("cs_win_panel_round", Event_End);
  162. HookEventEx("round_win", Event_End);
  163. HookEventEx("dod_round_win", Event_End);
  164. HookEventEx("teamplay_win_panel", Event_End);
  165. HookEventEx("arena_win_panel", Event_End);
  166. HookEventEx("round_start", Event_Start);
  167.  
  168. CreateTimer(90.0, ChatAdTimer);
  169. // MOTDgd MOTD Stuff //
  170.  
  171. AutoExecConfig(true);
  172.  
  173. if(LateLoad)
  174. {
  175. for(new i=1;i<=MaxClients;i++)
  176. {
  177. if(IsClientInGame(i))
  178. g_lastView[i] = GetTime();
  179. }
  180. }
  181. }
  182.  
  183. public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
  184. {
  185. // Set the expected defaults for the client
  186. VGUICaught[client] = false;
  187. g_preloadCheckTime[client] = 0;
  188. g_shownTeamVGUI[client] = false;
  189. g_lastView[client] = 0;
  190.  
  191. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  192. CanReview = true;
  193.  
  194. return true;
  195. }
  196.  
  197. public OnClientPutInServer(client)
  198. {
  199. // Load the advertisement via conventional means
  200. if (StrEqual(gameDir, "left4dead2") && GetConVarBool(g_OnConnect))
  201. {
  202. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  203. }
  204. }
  205.  
  206. // ====[ FUNCTIONS ]=====================================================================
  207. public Action:Event_End(Handle:event, const String:name[], bool:dontBroadcast)
  208. {
  209. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  210.  
  211. // Re-view minutes must be 15 or higher, re-view mode (onother) for this event
  212. if (GetConVarFloat(g_Review) < 15.0 || (GetConVarInt(g_OnOther) != 1 && GetConVarInt(g_OnOther) != 3 && GetConVarInt(g_OnOther) != 5 && GetConVarInt(g_OnOther) != 7))
  213. return Plugin_Continue;
  214.  
  215. // Only process the re-view event if the client is valid and is eligible to view another advertisement
  216. if (IsValidClient(client) && CanReview && GetTime() - g_lastView[client] >= GetConVarFloat(g_Review) * 60)
  217. {
  218. g_lastView[client] = GetTime();
  219. if (HTTPCommSupported && GetConVarInt(g_Preload) > 0)
  220. {
  221. // Preload the advertisement
  222. CreateTimer(0.1, PreloadMotdTimer, GetClientUserId(client));
  223.  
  224. CreateTimer(3.0, PreloadCheckTimer, GetClientUserId(client));
  225. }
  226. else
  227. {
  228. // Load the advertisement via conventional means
  229. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  230. {
  231. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  232. }
  233. }
  234. }
  235.  
  236. return Plugin_Continue;
  237. }
  238.  
  239. public Action:Event_Death(Handle:event, const String:name[], bool:dontBroadcast)
  240. {
  241. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  242. if(!client)
  243. return Plugin_Continue;
  244.  
  245. CreateTimer(0.5, CheckPlayerDeath, GetClientUserId(client));
  246.  
  247. return Plugin_Continue;
  248. }
  249.  
  250. public Action:Event_Start(Handle:event, const String:name[], bool:dontBroadcast)
  251. {
  252. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  253.  
  254. // Re-view minutes must be 15 or higher, re-view mode (onother) for this event
  255. if (GetConVarFloat(g_Review) < 15.0 || (GetConVarInt(g_OnOther) != 4 && GetConVarInt(g_OnOther) != 5 && GetConVarInt(g_OnOther) != 6 && GetConVarInt(g_OnOther) != 7))
  256. return Plugin_Continue;
  257.  
  258. // Only process the re-view event if the client is valid and is eligible to view another advertisement
  259. if (IsValidClient(client) && CanReview && GetTime() - g_lastView[client] >= GetConVarFloat(g_Review) * 60)
  260. {
  261. g_lastView[client] = GetTime();
  262. if (HTTPCommSupported && GetConVarInt(g_Preload) > 0)
  263. {
  264. // Preload the advertisement
  265. CreateTimer(0.1, PreloadMotdTimer, GetClientUserId(client));
  266.  
  267. CreateTimer(3.0, PreloadCheckTimer, GetClientUserId(client));
  268. }
  269. else
  270. {
  271. // Load the advertisement via conventional means
  272. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  273. {
  274. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  275. }
  276. }
  277. }
  278.  
  279. return Plugin_Continue;
  280. }
  281.  
  282. public Action:CheckPlayerDeath(Handle:timer, any:userid)
  283. {
  284. new client=GetClientOfUserId(userid);
  285. if(!client)
  286. return Plugin_Stop;
  287.  
  288. // Check if client is valid
  289. if (!IsValidClient(client))
  290. return Plugin_Stop;
  291.  
  292. // We don't want TF2's Dead Ringer triggering a false re-view event
  293. if (IsPlayerAlive(client))
  294. return Plugin_Stop;
  295.  
  296. // L4D1 and L4D2 are unsupported
  297. if (StrEqual(gameDir, "left4dead2") || StrEqual(gameDir, "left4dead"))
  298. return Plugin_Stop;
  299.  
  300. // Re-view minutes must be 15 or higher, re-view mode (onother) for this event
  301. if (GetConVarFloat(g_Review) < 15.0 || (GetConVarInt(g_OnOther) != 2 && GetConVarInt(g_OnOther) != 3 && GetConVarInt(g_OnOther) != 6 && GetConVarInt(g_OnOther) != 7))
  302. return Plugin_Stop;
  303.  
  304. // Only process the re-view event if the client is valid and is eligible to view another advertisement
  305. if (CanReview && GetTime() - g_lastView[client] >= GetConVarFloat(g_Review) * 60)
  306. {
  307. g_lastView[client] = GetTime();
  308. if (HTTPCommSupported && GetConVarInt(g_Preload) > 0)
  309. {
  310. CreateTimer(0.1, PreloadMotdTimer, GetClientUserId(client));
  311.  
  312. CreateTimer(3.0, PreloadCheckTimer, GetClientUserId(client));
  313. }
  314. else
  315. {
  316. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  317. {
  318. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  319. }
  320. }
  321. }
  322.  
  323. return Plugin_Stop;
  324. }
  325.  
  326. public Action:Event_PlayerTransitioned(Handle:event, const String:name[], bool:dontBroadcast)
  327. {
  328. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  329.  
  330. if (IsValidClient(client) && GetConVarBool(g_OnConnect))
  331. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  332.  
  333. return Plugin_Continue;
  334. }
  335.  
  336. public Action:OnVGUIMenu(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
  337. {
  338. new client = players[0];
  339.  
  340. if (playersNum > 1 || !IsValidClient(client) || VGUICaught[client] || !GetConVarBool(g_OnConnect))
  341. return Plugin_Continue;
  342.  
  343. VGUICaught[client] = true;
  344.  
  345. g_timepending[client] = 0;
  346.  
  347. if (HTTPCommSupported && GetConVarInt(g_Preload) > 0)
  348. {
  349. g_lastView[client] = GetTime();
  350.  
  351. CreateTimer(0.1, PreloadMotdTimer, GetClientUserId(client));
  352.  
  353. CreateTimer(2.0, PreloadCheckTimer, GetClientUserId(client));
  354. }
  355. else
  356. {
  357. if (!StrEqual(gameDir, "left4dead2") && !StrEqual(gameDir, "left4dead"))
  358. {
  359. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  360. }
  361. }
  362.  
  363. return Plugin_Handled;
  364. }
  365.  
  366. public Action:PreloadMotdTimer(Handle:timer, any:userid)
  367. {
  368. new client=GetClientOfUserId(userid);
  369. if(!client)
  370. return Plugin_Stop;
  371.  
  372. if (!IsValidClient(client))
  373. return Plugin_Stop;
  374.  
  375. // Preload the advertisement and only show it once it begins playing...
  376. new String:IP[16];
  377. GetClientIP(client, IP, sizeof(IP));
  378.  
  379. new String:requestURL[PLATFORM_MAX_PATH];
  380. Format(requestURL, sizeof(requestURL), "http://video.u%d.motd.gd/motd?ip=%s&action=reset", GetConVarInt(g_motdID), IP);
  381.  
  382. EasyHTTP(requestURL, GetSteamData_Null_Completed, 0);
  383.  
  384. g_preloadCheckTime[client] = GetTime();
  385.  
  386. decl String:steamid[255], String:url[255];
  387. if (GetClientAuthString(client, steamid, sizeof(steamid)))
  388. Format(url, sizeof(url), "http://motdgd.com/motd/?user=%d&ip=%s&pt=%d&v=%s&st=%s&gm=%s", GetConVarInt(g_motdID), g_serverIP, g_serverPort, PLUGIN_VERSION, steamid, gameDir);
  389. else
  390. Format(url, sizeof(url), "http://motdgd.com/motd/?user=%d&ip=%s&pt=%d&v=%s&st=NULL&gm=%s", GetConVarInt(g_motdID), g_serverIP, g_serverPort, PLUGIN_VERSION, gameDir);
  391.  
  392. ShowMOTDScreen(client, url, true);
  393.  
  394. if (!g_shownTeamVGUI[client] && GetClientTeam(client) < 1)
  395. {
  396. g_shownTeamVGUI[client] = true;
  397. ShowVGUIPanel(client, "team");
  398. }
  399.  
  400. return Plugin_Stop;
  401. }
  402.  
  403. public Action:PreloadCheckTimer(Handle:timer, any:userid)
  404. {
  405. new client=GetClientOfUserId(userid);
  406. if(!client)
  407. return Plugin_Stop;
  408.  
  409. if (!IsValidClient(client))
  410. return Plugin_Stop;
  411.  
  412. new String:IP[16];
  413. GetClientIP(client, IP, sizeof(IP));
  414.  
  415. new String:requestURL[PLATFORM_MAX_PATH];
  416. Format(requestURL, sizeof(requestURL), "http://video.u%d.motd.gd/motd?ip=%s", GetConVarInt(g_motdID), IP);
  417.  
  418. EasyHTTP(requestURL, GetSteamData_PreloadCheck_Completed, client);
  419.  
  420. return Plugin_Stop;
  421. }
  422.  
  423. public GetSteamData_PreloadCheck_Completed(any:client, const String:sQueryData[], bool:success, error)
  424. {
  425. if (!IsValidClient(client))
  426. return;
  427.  
  428. if (g_preloadCheckTime[client] == 0)
  429. return;
  430.  
  431. // Allow at least 'sm_motdgd_preload' seconds before discontinuing any further attempts
  432. if ((GetTime() - g_preloadCheckTime[client]) < GetConVarInt(g_Preload))
  433. {
  434. if (success)
  435. {
  436. new String:searchFor[1] = "Y";
  437.  
  438. if (StrEqual(sQueryData, searchFor))
  439. {
  440. g_preloadCheckTime[client] = 0;
  441.  
  442. CreateTimer(0.1, PreMotdTimer, GetClientUserId(client));
  443. }
  444. else
  445. {
  446. CreateTimer(2.0, PreloadCheckTimer, GetClientUserId(client));
  447. }
  448. }
  449. }
  450. else
  451. {
  452. g_preloadCheckTime[client] = 0;
  453.  
  454. new String:url[255];
  455. Format(url, sizeof(url), "http://");
  456.  
  457. ShowMOTDScreen(client, url, false);
  458. }
  459. }
  460.  
  461. public Action:ClosedMOTD(client, const String:command[], argc)
  462. {
  463. if (!IsValidClient(client))
  464. return Plugin_Handled;
  465.  
  466. if (GetConVarInt(g_Preload) == 0)
  467. {
  468. if (StrEqual(gameDir, "cstrike") || StrEqual(gameDir, "csgo"))
  469. FakeClientCommand(client, "joingame");
  470. else if (StrEqual(gameDir, "nucleardawn") || StrEqual(gameDir, "dod"))
  471. ClientCommand(client, "changeteam");
  472. }
  473.  
  474. return Plugin_Handled;
  475. }
  476.  
  477. public Action:PreMotdTimer(Handle:timer, any:userid)
  478. {
  479. new client=GetClientOfUserId(userid);
  480. if(!client)
  481. return Plugin_Stop;
  482.  
  483. if (!IsValidClient(client))
  484. return Plugin_Stop;
  485.  
  486. g_preloadCheckTime[client] = 0;
  487.  
  488. decl String:url[255];
  489.  
  490. if (HTTPCommSupported && GetConVarInt(g_Preload) > 0)
  491. Format(url, sizeof(url), "http://");
  492. else
  493. {
  494. decl String:steamid[255];
  495. if (GetClientAuthString(client, steamid, sizeof(steamid)))
  496. Format(url, sizeof(url), "http://motdgd.com/motd/?user=%d&ip=%s&pt=%d&v=%s&st=%s&gm=%s", GetConVarInt(g_motdID), g_serverIP, g_serverPort, PLUGIN_VERSION, steamid, gameDir);
  497. else
  498. Format(url, sizeof(url), "http://motdgd.com/motd/?user=%d&ip=%s&pt=%d&v=%s&st=NULL&gm=%s", GetConVarInt(g_motdID), g_serverIP, g_serverPort, PLUGIN_VERSION, gameDir);
  499. }
  500.  
  501. ShowMOTDScreen(client, url, false); // False means show, true means hide
  502. g_timepending[client] = 0;
  503.  
  504. return Plugin_Stop;
  505. }
  506.  
  507. public Action:ChatAdTimer(Handle:timer)
  508. {
  509. CreateTimer(600.0, ChatAdTimer);
  510.  
  511. new String:requestURL[PLATFORM_MAX_PATH];
  512.  
  513. if (GetConVarBool(g_Chat) && GetRealPlayerCount() > 0)
  514. {
  515. Format(requestURL, sizeof(requestURL), "http://chat.motd.gd/chat?uid=%d&gm=%s", GetConVarInt(g_motdID), gameDir);
  516.  
  517. EasyHTTP(requestURL, GetSteamData_Completed, 0);
  518. }
  519. }
  520.  
  521. public GetSteamData_Completed(any:unused, const String:sQueryData[], bool:success, error)
  522. {
  523. if (success)
  524. {
  525. new JSON:js = json_decode(sQueryData);
  526.  
  527. if (js == JSON_INVALID)
  528. {
  529. return;
  530. }
  531.  
  532. new String:message[255];
  533. json_get_string(js, "message", message, sizeof(message));
  534.  
  535. new String:impressionURL[PLATFORM_MAX_PATH];
  536. json_get_string(js, "impression", impressionURL, sizeof(impressionURL));
  537.  
  538. EasyHTTP(impressionURL, GetSteamData_Null_Completed, 0);
  539.  
  540. PrintToChatAll("\x01\x0B\x04[AD] %s", message);
  541. }
  542. }
  543.  
  544. public GetSteamData_Null_Completed(any:unused, const String:sQueryData[], bool:success, error)
  545. {
  546. return;
  547. }
  548.  
  549. stock ShowMOTDScreen(client, String:url[], bool:hidden)
  550. {
  551. if (!IsValidClient(client))
  552. return;
  553.  
  554. new Handle:kv = CreateKeyValues("data");
  555.  
  556. if (StrEqual(gameDir, "left4dead") || StrEqual(gameDir, "left4dead2"))
  557. KvSetString(kv, "cmd", "closed_htmlpage");
  558. else
  559. KvSetNum(kv, "cmd", 5);
  560.  
  561. KvSetString(kv, "msg", url);
  562. KvSetString(kv, "title", "MOTDgd AD");
  563. KvSetNum(kv, "type", MOTDPANEL_TYPE_URL);
  564. ShowVGUIPanel(client, "info", kv, !hidden);
  565. CloseHandle(kv);
  566. }
  567.  
  568. stock GetRealPlayerCount()
  569. {
  570. new players;
  571. for (new i = 1; i <= MaxClients; i++)
  572. {
  573. if (IsClientInGame(i) && !IsFakeClient(i))
  574. players++;
  575. }
  576. return players;
  577. }
  578.  
  579. stock bool:IsValidClient(i){
  580. if (!i || !IsClientInGame(i) || IsClientSourceTV(i) || IsClientReplay(i) || IsFakeClient(i) || !IsClientConnected(i))
  581. return false;
  582. if (!GetConVarBool(g_immunity))
  583. return true;
  584. if (CheckCommandAccess(i, "MOTDGD_Immunity", ADMFLAG_RESERVATION))
  585. return false;
  586.  
  587. return true;
  588. }
  589.  
  590. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  591. {
  592. LateLoad = late;
  593.  
  594. // Mark Socket natives as optional
  595. MarkNativeAsOptional("SocketIsConnected");
  596. MarkNativeAsOptional("SocketCreate");
  597. MarkNativeAsOptional("SocketBind");
  598. MarkNativeAsOptional("SocketConnect");
  599. MarkNativeAsOptional("SocketDisconnect");
  600. MarkNativeAsOptional("SocketListen");
  601. MarkNativeAsOptional("SocketSend");
  602. MarkNativeAsOptional("SocketSendTo");
  603. MarkNativeAsOptional("SocketSetOption");
  604. MarkNativeAsOptional("SocketSetReceiveCallback");
  605. MarkNativeAsOptional("SocketSetSendqueueEmptyCallback");
  606. MarkNativeAsOptional("SocketSetDisconnectCallback");
  607. MarkNativeAsOptional("SocketSetErrorCallback");
  608. MarkNativeAsOptional("SocketSetArg");
  609. MarkNativeAsOptional("SocketGetHostName");
  610.  
  611. // Mark cURL natives as optional
  612. MarkNativeAsOptional("curl_easy_init");
  613. MarkNativeAsOptional("curl_easy_setopt_string");
  614. MarkNativeAsOptional("curl_easy_setopt_int");
  615. MarkNativeAsOptional("curl_easy_setopt_int_array");
  616. MarkNativeAsOptional("curl_easy_setopt_int64");
  617. MarkNativeAsOptional("curl_OpenFile");
  618. MarkNativeAsOptional("curl_httppost");
  619. MarkNativeAsOptional("curl_slist");
  620. MarkNativeAsOptional("curl_easy_setopt_handle");
  621. MarkNativeAsOptional("curl_easy_setopt_function");
  622. MarkNativeAsOptional("curl_load_opt");
  623. MarkNativeAsOptional("curl_easy_perform");
  624. MarkNativeAsOptional("curl_easy_perform_thread");
  625. MarkNativeAsOptional("curl_easy_send_recv");
  626. MarkNativeAsOptional("curl_send_recv_Signal");
  627. MarkNativeAsOptional("curl_send_recv_IsWaiting");
  628. MarkNativeAsOptional("curl_set_send_buffer");
  629. MarkNativeAsOptional("curl_set_receive_size");
  630. MarkNativeAsOptional("curl_set_send_timeout");
  631. MarkNativeAsOptional("curl_set_recv_timeout");
  632. MarkNativeAsOptional("curl_get_error_buffer");
  633. MarkNativeAsOptional("curl_easy_getinfo_string");
  634. MarkNativeAsOptional("curl_easy_getinfo_int");
  635. MarkNativeAsOptional("curl_easy_escape");
  636. MarkNativeAsOptional("curl_easy_unescape");
  637. MarkNativeAsOptional("curl_easy_strerror");
  638. MarkNativeAsOptional("curl_version");
  639. MarkNativeAsOptional("curl_protocols");
  640. MarkNativeAsOptional("curl_features");
  641. MarkNativeAsOptional("curl_OpenFile");
  642. MarkNativeAsOptional("curl_httppost");
  643. MarkNativeAsOptional("curl_formadd");
  644. MarkNativeAsOptional("curl_slist");
  645. MarkNativeAsOptional("curl_slist_append");
  646. MarkNativeAsOptional("curl_hash_file");
  647. MarkNativeAsOptional("curl_hash_string");
  648. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement