Advertisement
xaoc-here

drops discord

Dec 4th, 2022 (edited)
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 18.36 KB | None | 0 0
  1. #include <sdktools>
  2. #include <dhooks>
  3. #include <discord_extended>
  4. #include <ripext>
  5.  
  6. #undef REQUIRE_EXTENSIONS
  7. #tryinclude <SteamWorks>
  8. #define REQUIRE_EXTENSIONS
  9.  
  10. bool Debug = false;
  11.  
  12. public Plugin myinfo =
  13. {
  14.     name = "Призыватель дропа",
  15.     author = "Phoenix (˙·٠●Феникс●٠·˙) + Ganter1234",
  16.     version = "1.2.7"
  17. };
  18.  
  19. #pragma tabsize 0
  20.  
  21. KeyValues
  22.     g_hKvConfig;
  23. Handle
  24.     g_hTimer[MAXPLAYERS+1],
  25.     g_hRewardMatchEndDrops,
  26.     g_hTimerWaitDrops;
  27. char
  28.     g_sLogFile[256],
  29.     g_sApiKey[54];
  30. int
  31.     g_iOS = -1;
  32. Address
  33.     g_pDropForAllPlayersPatch = Address_Null;
  34. ConVar
  35.     g_hDSApiKey,
  36.     g_hDSKick,
  37.     g_hDSWaitTimer,
  38.     g_hDSInfo,
  39.     g_hDSPlaySound,
  40.     g_hDSCurrency,
  41.     g_hDSViewCase,
  42.     g_hDSPrime;
  43.  
  44. public void OnPluginStart()
  45. {
  46.     GameData hGameData = LoadGameConfigFile("DropsSummoner.games");
  47.     if(!hGameData)
  48.         SetFailState("Failed to load DropsSummoner gamedata.");
  49.  
  50.     if((g_iOS = hGameData.GetOffset("OS")) == -1)
  51.         SetFailState("Failed to get OS offset");
  52.  
  53.     StartPrepSDKCall(g_iOS == 1 ? SDKCall_Raw : SDKCall_Static);
  54.     PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CCSGameRules::RewardMatchEndDrops");
  55.     PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
  56.  
  57.     if(!(g_hRewardMatchEndDrops = EndPrepSDKCall()))
  58.         SetFailState("Failed to create SDKCall for CCSGameRules::RewardMatchEndDrops");
  59.  
  60.     DynamicDetour hCCSGameRules_RecordPlayerItemDrop = DynamicDetour.FromConf(hGameData, "CCSGameRules::RecordPlayerItemDrop");
  61.  
  62.     if(!hCCSGameRules_RecordPlayerItemDrop)
  63.         SetFailState("Failed to setup detour for CCSGameRules::RecordPlayerItemDrop");
  64.  
  65.     if(!hCCSGameRules_RecordPlayerItemDrop.Enable(Hook_Post, Detour_RecordPlayerItemDrop))
  66.         SetFailState("Failed to detour CCSGameRules::RecordPlayerItemDrop.");
  67.  
  68.     if((g_pDropForAllPlayersPatch = hGameData.GetAddress("DropForAllPlayersPatch")) != Address_Null)
  69.     {
  70.         // 83 F8 01 ?? [cmp eax, 1]
  71.         if((LoadFromAddress(g_pDropForAllPlayersPatch, NumberType_Int32) & 0xFFFFFF) == 0x1F883)
  72.         {
  73.             g_pDropForAllPlayersPatch += view_as<Address>(2);
  74.  
  75.             StoreToAddress(g_pDropForAllPlayersPatch, 0xFF, NumberType_Int8);
  76.         }
  77.         else
  78.         {
  79.             g_pDropForAllPlayersPatch = Address_Null;
  80.  
  81.             LogError("At address g_pDropForAllPlayersPatch received not what we expected, drop for all players will be unavailable.");
  82.         }
  83.     }
  84.     else LogError("Failed to get address DropForAllPlayersPatch, drop for all players will be unavailable.");
  85.  
  86.     delete hGameData;
  87.  
  88.     BuildPath(Path_SM, g_sLogFile, sizeof g_sLogFile, "logs/DropsSummoner.log");
  89.  
  90.     g_hDSApiKey = CreateConVar("sm_drops_apikey", "", "API ключ стима(https://steamcommunity.com/dev/apikey)");
  91.     g_hDSKick = CreateConVar("sm_drops_kick", "0", "Кикать игрока после получения кейса?(Для IDLE)", _, true, 0.0, true, 1.0);
  92.     g_hDSWaitTimer = CreateConVar("sm_drops_summoner_wait_timer", "182", "Длительность между попытками призвать дроп в секундах", _, true, 60.0);
  93.     g_hDSCurrency = CreateConVar("sm_drops_currency", "5", "Валюта которая будет выводиться в сообщении, https://partner.steamgames.com/doc/store/pricing/currencies");
  94.     g_hDSInfo = CreateConVar("sm_drops_summoner_info", "1", "Уведомлять в чате о попытках призыва дропа", _, true, 0.0, true, 1.0);
  95.     g_hDSViewCase = CreateConVar("sm_drops_viewcase", "1", "Показ картинки кейса [0 - нет | 1 - только получившему | 2 - всем]", _, true, 0.0, true, 2.0);
  96.     g_hDSPlaySound = CreateConVar("sm_drops_summoner_play_sound", "2", "Воспроизводить звук при получении дропа [0 - нет | 1 - только получившему | 2 - всем]", _, true, 0.0, true, 2.0);
  97.     g_hDSPrime = CreateConVar("sm_drops_prime", "1", "Не показывать инфу о получении кейса если игрок без прайма?", _, true, 0.0, true, 1.0);
  98.  
  99.     AutoExecConfig(true, "drops_summoner");
  100.  
  101.     RegAdminCmd("sm_drops_test", TestMessage, ADMFLAG_ROOT);
  102. }
  103.  
  104. public Action TestMessage(int client, int args)
  105. {
  106.     if(!client)
  107.     {
  108.         PrintToServer("Bro will not work, go to the server and write the command there)");
  109.         return Plugin_Handled;
  110.     }
  111.  
  112.     char sDefIndex[8];
  113.     if(args > 0) GetCmdArg(1, sDefIndex, sizeof(sDefIndex));
  114.     else FormatEx(sDefIndex, sizeof(sDefIndex), "4001");
  115.  
  116.     g_hKvConfig.Rewind();
  117.     if(g_hKvConfig.JumpToKey(sDefIndex))
  118.     {
  119.         char cPlayerID[82], sBuffer[128];
  120.         GetClientAuthId(client, AuthId_SteamID64, cPlayerID, sizeof(cPlayerID));
  121.         StripQuotes(cPlayerID);
  122.         g_hKvConfig.GetString("case_name_market", sBuffer, sizeof(sBuffer));
  123.        
  124.         char szPlayerName[50];
  125.         if(IsClientInGame(client)) FormatEx(szPlayerName, sizeof(szPlayerName), "%N", client);
  126.         else FormatEx(szPlayerName, sizeof(szPlayerName), "Неизвестный");
  127.  
  128.         DataPack hPack = new DataPack();
  129.         hPack.WriteCell(client);
  130.         hPack.WriteString(sDefIndex);
  131.         hPack.WriteString(sBuffer);
  132.         hPack.WriteString(szPlayerName);
  133.        
  134.         char sRequest[1024];
  135.         FormatEx(sRequest, sizeof(sRequest), "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002?key=%s&steamids=%s", g_sApiKey, cPlayerID);
  136.         HTTPRequest httpClient = new HTTPRequest(sRequest);
  137.         httpClient.Get(OnTodoReceived, hPack);
  138.  
  139.         PrintToChat(client, "[DS] Тестовое оповещение отправлено!");
  140.     }
  141.     else
  142.     {
  143.         PrintToChat(client, "[DS] Тестовое оповещение не удалось отправить, не удалось найти кейс с айди %s в конфиге :(", sDefIndex);
  144.         LogError("There is no case in the config :O (Case index: %s)", sDefIndex);
  145.     }
  146.  
  147.     return Plugin_Handled;
  148. }
  149.  
  150. public void OnPluginEnd()
  151. {
  152.     if(g_pDropForAllPlayersPatch != Address_Null) StoreToAddress(g_pDropForAllPlayersPatch, 0x01, NumberType_Int8);
  153. }
  154.  
  155. public void OnConfigsExecuted()
  156. {
  157.     GetConVarString(g_hDSApiKey, g_sApiKey, sizeof(g_sApiKey));
  158.     if(!g_sApiKey[0])
  159.         SetFailState("Введите Steam Web API ключ! https://steamcommunity.com/dev/apikey (\"sm_drops_apikey\")");
  160.     StripQuotes(g_sApiKey);
  161. }
  162.  
  163. public void OnMapStart()
  164. {
  165.     PrecacheSound("ui/panorama/case_awarded_1_uncommon_01.wav");
  166.     CreateTimer(g_hDSWaitTimer.FloatValue, Timer_SendRewardMatchEndDrops, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  167.     LoadConfig();
  168. }
  169.  
  170. public void OnClientDisconnect(int client)
  171. {
  172.     if(g_hTimer[client] != null)
  173.     {
  174.         KillTimer(g_hTimer[client]);
  175.         g_hTimer[client] = null;
  176.     }
  177. }
  178.  
  179. public void OnMapEnd()
  180. {
  181.     for(int i = 1; i < MaxClients; i++) OnClientDisconnect(i);
  182. }
  183.  
  184. void LoadConfig()
  185. {
  186.     char sBuffer[PLATFORM_MAX_PATH];
  187.     g_hKvConfig = new KeyValues("Drops_Discord");
  188.     FormatEx(sBuffer, sizeof(sBuffer), "addons/sourcemod/configs/dropssummoner_discord.ini");
  189.     if(!g_hKvConfig.ImportFromFile(sBuffer)) SetFailState("Не найден конфиг: %s", sBuffer);
  190. }
  191.  
  192. MRESReturn Detour_RecordPlayerItemDrop(DHookParam hParams)
  193. {
  194.     if(g_hTimerWaitDrops)
  195.     {
  196.         KillTimer(g_hTimerWaitDrops);
  197.         g_hTimerWaitDrops = null;
  198.     }
  199.    
  200.     int iAccountID = hParams.GetObjectVar(1, 16, ObjectValueType_Int);
  201.     int iClient = GetClientFromAccountID(iAccountID);
  202.    
  203.     if(iClient != -1 && CF_CheckPrime(iClient) == 2)
  204.     {  
  205.         int iDefIndex = hParams.GetObjectVar(1, 20, ObjectValueType_Int);
  206.         int iPaintIndex = hParams.GetObjectVar(1, 24, ObjectValueType_Int);
  207.         int iRarity = hParams.GetObjectVar(1, 28, ObjectValueType_Int);
  208.         int iQuality = hParams.GetObjectVar(1, 32, ObjectValueType_Int);
  209.  
  210.         LogToFile(g_sLogFile, "Игроку %L выпало [%u-%u-%u-%u]", iClient, iDefIndex, iPaintIndex, iRarity, iQuality);
  211.            
  212.         Protobuf hSendPlayerItemFound = view_as<Protobuf>(StartMessageAll("SendPlayerItemFound", USERMSG_RELIABLE));
  213.         hSendPlayerItemFound.SetInt("entindex", iClient);
  214.            
  215.         Protobuf hIteminfo = hSendPlayerItemFound.ReadMessage("iteminfo");
  216.         hIteminfo.SetInt("defindex", iDefIndex);
  217.         hIteminfo.SetInt("paintindex", iPaintIndex);
  218.         hIteminfo.SetInt("rarity", iRarity);
  219.         hIteminfo.SetInt("quality", iQuality);
  220.         hIteminfo.SetInt("inventory", 6); //UNACK_ITEM_GIFTED
  221.            
  222.         EndMessage();
  223.            
  224.         SetHudTextParams(-1.0, 0.4, 3.0, 0, 255, 255, 255);
  225.         ShowHudText(iClient, -1, "Вам выпал дроп, смотрите свой инвентарь");
  226.            
  227.         int iPlaySound = g_hDSPlaySound.IntValue;
  228.            
  229.         if(iPlaySound == 2)
  230.         {
  231.             EmitSoundToAll("ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
  232.         }
  233.         else if(iPlaySound == 1)
  234.         {
  235.             EmitSoundToClient(iClient, "ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
  236.         }
  237.  
  238.         char sDefIndex[8]
  239.         FormatEx(sDefIndex, sizeof(sDefIndex), "%i", iDefIndex);
  240.         g_hKvConfig.Rewind();
  241.         if(g_hKvConfig.JumpToKey(sDefIndex))
  242.         {
  243.             if(Debug) LogToFile(g_sLogFile, "Первый запрос");
  244.             char cPlayerID[82], sBuffer[128];
  245.             GetClientAuthId(iClient, AuthId_SteamID64, cPlayerID, sizeof(cPlayerID));
  246.             StripQuotes(cPlayerID);
  247.             g_hKvConfig.GetString("case_name_market", sBuffer, sizeof(sBuffer));
  248.            
  249.             char szPlayerName[50];
  250.             if(IsClientInGame(iClient)) FormatEx(szPlayerName, sizeof(szPlayerName), "%N", iClient);
  251.             else FormatEx(szPlayerName, sizeof(szPlayerName), "Неизвестный");
  252.  
  253.             DataPack hPack = new DataPack();
  254.             hPack.WriteCell(iClient);
  255.             hPack.WriteString(sDefIndex);
  256.             hPack.WriteString(sBuffer);
  257.             hPack.WriteString(szPlayerName);
  258.  
  259.             char sRequest[1024];
  260.             FormatEx(sRequest, sizeof(sRequest), "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002?key=%s&steamids=%s", g_sApiKey, cPlayerID);
  261.             HTTPRequest httpClient = new HTTPRequest(sRequest);
  262.             httpClient.Get(OnTodoReceived, hPack);
  263.             if(Debug) LogToFile(g_sLogFile, "Первый запрос отправлен");
  264.         }
  265.         else LogError("There is no case in the config :O (INDEX: %i)", iDefIndex);
  266.     }
  267.    
  268.     return MRES_Ignored;
  269. }
  270.  
  271. public void OnTodoReceived(HTTPResponse response, DataPack hPack)
  272. {
  273.     hPack.Reset();
  274.     int iClient = hPack.ReadCell();
  275.     char sDefIndex[8];
  276.     hPack.ReadString(sDefIndex, sizeof(sDefIndex));
  277.     char sBuffer[128];
  278.     hPack.ReadString(sBuffer, sizeof(sBuffer));
  279.     StripQuotes(sBuffer);
  280.     ReplaceString(sBuffer, sizeof(sBuffer), "&", "%26");
  281.     ReplaceString(sBuffer, sizeof(sBuffer), " ", "%20");
  282.     char szPlayerName[64];
  283.     hPack.ReadString(szPlayerName, sizeof(szPlayerName));
  284.     //PrintToChatAll("%s", sBuffer);
  285.     delete hPack;
  286.  
  287.     if (response.Status != HTTPStatus_OK)
  288.     {
  289.         if(response.Status == HTTPStatus_Forbidden)
  290.             LogError("Avatar Error 403: looks like you entered the wrong API KEY :( [Your key: %s]", g_sApiKey);
  291.         else if(response.Status == HTTPStatus_BadRequest)
  292.             LogError("Avatar Error 400: Incorrectly entered request or problems on the server side :(");
  293.         else if(response.Status == HTTPStatus_ServiceUnavailable)
  294.             LogError("Avatar Error 503: Steam servers are currently unavailable :(");
  295.         else
  296.             LogError("Avatar Error %i: something went wrong :(", response.Status);
  297.         return;
  298.     }
  299.     if (response.Data == null)
  300.     {
  301.         LogError("Avatar JSON null :(");
  302.         return;
  303.     }
  304.  
  305.     if(Debug) LogToFile(g_sLogFile, "Первый запрос обрабатывается");
  306.  
  307.     JSONObject res = view_as<JSONObject>(response.Data);
  308.     JSONObject resp = view_as<JSONObject>(res.Get("response"));
  309.     JSONArray players = view_as<JSONArray>(resp.Get("players"));
  310.     JSONObject data = view_as<JSONObject>(players.Get(0));
  311.    
  312.     char szAvatar[256];
  313.     data.GetString("avatarmedium", szAvatar, sizeof(szAvatar));
  314.  
  315.     if(Debug) LogToFile(g_sLogFile, "Первый запрос получен");
  316.     if(Debug) LogToFile(g_sLogFile, "Второй запрос");
  317.  
  318.     DataPack hdPack = new DataPack();
  319.     hdPack.WriteCell(iClient);
  320.     hdPack.WriteString(sDefIndex);
  321.     hdPack.WriteString(szAvatar);
  322.     hdPack.WriteString(szPlayerName);
  323.  
  324.     char sRequest[1024];
  325.     FormatEx(sRequest, sizeof(sRequest), "https://steamcommunity.com/market/priceoverview/?appid=730&currency=%i&market_hash_name=%s", g_hDSCurrency.IntValue, sBuffer);
  326.     hdPack.WriteString(sRequest);
  327.     HTTPRequest httpPrice = new HTTPRequest(sRequest);
  328.     httpPrice.Get(OnPriceReceived, hdPack);
  329.     if(Debug) LogToFile(g_sLogFile, "Второй запрос отправлен");
  330.  
  331.     delete res;
  332.     delete resp;
  333.     delete players;
  334.     delete data;
  335. }
  336.  
  337. public void OnPriceReceived(HTTPResponse response, DataPack hdPack) // Thanks HenryTownshand
  338. {
  339.     hdPack.Reset();
  340.     int iClient = hdPack.ReadCell();
  341.     char sDefIndex[8];
  342.     hdPack.ReadString(sDefIndex, sizeof(sDefIndex));
  343.     char szAvatar[512];
  344.     hdPack.ReadString(szAvatar, sizeof(szAvatar));
  345.     char szPlayerName[50];
  346.     hdPack.ReadString(szPlayerName, sizeof(szPlayerName));
  347.     char sRequest[1024];
  348.     hdPack.ReadString(sRequest, sizeof(sRequest));
  349.     delete hdPack;
  350.  
  351.     if (response.Status != HTTPStatus_OK)
  352.     {
  353.         if(response.Status == HTTPStatus_Forbidden)
  354.             LogError("Price Error 403: looks like you entered the wrong API KEY :( [Your key: %s]", g_sApiKey);
  355.         else if(response.Status == HTTPStatus_BadRequest)
  356.             LogError("Price Error 400: Incorrectly entered request or problems on the server side :( [%s]", sRequest);
  357.         else if(response.Status == HTTPStatus_ServiceUnavailable)
  358.             LogError("Price Error 503: Steam servers are currently unavailable :(");
  359.         else
  360.             LogError("Price Error %i: something went wrong :( [Case index : %s]", response.Status, sDefIndex);
  361.         return;
  362.     }
  363.     if (response.Data == null)
  364.     {
  365.         LogError("Price JSON null :(");
  366.         return;
  367.     }
  368.  
  369.     if(Debug) LogToFile(g_sLogFile, "Второй запрос обрабатывается");
  370.  
  371.     JSONObject res = view_as<JSONObject>(response.Data);
  372.     char sPrice[256];
  373.     res.GetString("median_price", sPrice, sizeof(sPrice));
  374.     if(Debug) LogToFile(g_sLogFile, "Второй запрос получен, начинается отправка сообщения");
  375.     discord_send_message(sDefIndex, szAvatar, szPlayerName, iClient, sPrice);
  376.     delete res;
  377. }
  378.  
  379. public void discord_send_message(char[] sDefIndex, char[] szAvatar, char[] szPlayerName, int client, char[] sPrice)
  380. {
  381.     char sCase[512];
  382.     if(Discord_WebHookExists("Drops_Cases"))
  383.     {
  384.         int Color[10];
  385.         Color[0] = 0x000000;
  386.         Color[1] = 0x00FF00;
  387.         Color[2] = 0xFF0000;
  388.         Color[3] = 0xFF8000;
  389.         Color[4] = 0xFFFF00;
  390.         Color[5] = 0x0000FF;
  391.         Color[6] = 0xFF00FF;
  392.         Color[7] = 0x0080FF;
  393.         Color[8] = 0x00FFFF;
  394.         Color[9] = 0xFFFFFF;
  395.  
  396.         int random = GetRandomInt(0, 9);
  397.         Discord_StartMessage();
  398.         Discord_SetUsername("Drop Cases");
  399.         Discord_SetColor(Color[random]);
  400.         Discord_SetAuthorName(szPlayerName);
  401.         Discord_SetAuthorImage(szAvatar);
  402.  
  403.         if(Debug) LogToFile(g_sLogFile, "Webhook настроен");
  404.  
  405.         char sField[256], sBuffer[1024];
  406.         g_hKvConfig.Rewind();
  407.         g_hKvConfig.GetString("Field_Text", sField, sizeof(sField));
  408.  
  409.         if(g_hKvConfig.JumpToKey(sDefIndex))
  410.         {
  411.             g_hKvConfig.GetString("case_name", sBuffer, sizeof(sBuffer));
  412.             Discord_AddField(sField, sBuffer);
  413.             //PrintToChatAll("%s %s", sField, sBuffer);
  414.             Discord_AddField("Цена:", sPrice);
  415.             //PrintToChatAll("Цена: %s", sPrice);
  416.  
  417.             g_hKvConfig.GetString("image_url", sCase, sizeof(sCase));
  418.             Discord_SetThumbnail(sCase);
  419.             //PrintToChatAll("Image: %s", sCase);
  420.  
  421.             GetConVarString(FindConVar("hostname"), sBuffer, sizeof(sBuffer));
  422.             char time[24];
  423.             FormatTime(time, sizeof(time), "%T %m.%d.%Y"); // Thanks Grey83
  424.             Format(sBuffer, sizeof(sBuffer), "%s • %s", sBuffer, time);
  425.             Discord_SetFooterText(sBuffer);
  426.             //PrintToChatAll("Footer: %s", sBuffer);
  427.             if(Debug) LogToFile(g_sLogFile, "Сообщение построено");
  428.         }
  429.         else LogError("There is no case in the config :O (Case index: %s)", sDefIndex);
  430.  
  431.         Discord_EndMessage("Drops_Cases", true);
  432.         if(Debug) LogToFile(g_sLogFile, "Сообщение отправлено");
  433.     }
  434.     else LogError("Webhook not available :(");
  435.  
  436.     if(g_hDSKick.BoolValue && IsClientInGame(client)) KickClient(client);
  437.  
  438.     if(g_hDSViewCase.BoolValue && !g_hDSKick.BoolValue && IsClientInGame(client))
  439.     {
  440.         OnClientDisconnect(client);
  441.        
  442.         if(g_hTimer[client] == null)
  443.         {
  444.             DataPack hPack = new DataPack(); // хуйня костыльная, пока ничего лучше не придумали)
  445.             hPack.WriteCell(client);
  446.             hPack.WriteString(sCase);
  447.             CreateTimer(0.75, TimerCancel, hPack, TIMER_FLAG_NO_MAPCHANGE);
  448.             g_hTimer[client] = CreateTimer(0.11, TimerPrint, hPack, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
  449.         }
  450.     }
  451.  
  452.     if(Debug) LogToFile(g_sLogFile, "Конец отправки");
  453. }
  454.  
  455. public Action TimerCancel(Handle timer, any h)
  456. {
  457.     DataPack hPack = view_as<DataPack>(h);
  458.     if(!hPack) return Plugin_Stop;
  459.  
  460.     hPack.Reset();
  461.     int client = hPack.ReadCell();
  462.     if(g_hTimer[client]) // Thanks Palonez
  463.     {
  464.         KillTimer(g_hTimer[client]);
  465.         g_hTimer[client] = null;
  466.     }
  467.     delete hPack;
  468.     return Plugin_Stop;
  469. }
  470.  
  471. public Action TimerPrint(Handle timer, any h)
  472. {
  473.     DataPack hPack = view_as<DataPack>(h);
  474.     if(!hPack) return Plugin_Stop;
  475.  
  476.     hPack.Reset();
  477.     int client = hPack.ReadCell();
  478.     char sBuffer[512];
  479.     hPack.ReadString(sBuffer, sizeof(sBuffer));
  480.     if(IsClientInGame(client))
  481.     {
  482.         if(g_hDSViewCase.IntValue == 1) PrintHintText(client, "<pre><center>Вам выпал кейс:<br><font><img src='%s'></font></center></pre>", sBuffer); // Thanks Palonez
  483.         else if(g_hDSViewCase.IntValue == 2) PrintHintTextToAll("<pre><center>Игроку <font color=\"#FF0000\">%N</font> выпал кейс:<br><font><img src='%s'></font></center></pre>", client, sBuffer);
  484.     }
  485.  
  486.     return Plugin_Stop;
  487. }
  488.  
  489. int GetClientFromAccountID(int iAccountID)
  490. {
  491.     for(int i = 1; i <= MaxClients; i++)
  492.         if(IsClientConnected(i) && !IsFakeClient(i) && IsClientAuthorized(i) && GetSteamAccountID(i) == iAccountID)
  493.             return i;
  494.  
  495.     return -1;
  496. }
  497.  
  498. stock int CF_CheckPrime(int client) // Thanks CYBERC4T
  499. {
  500.     if(g_hDSPrime.BoolValue && CanTestFeatures()
  501.     && GetFeatureStatus(FeatureType_Native, "SteamWorks_HasLicenseForApp") == FeatureStatus_Available
  502.     && k_EUserHasLicenseResultDoesNotHaveLicense == SteamWorks_HasLicenseForApp(client, 624820))
  503.         return 1;
  504.  
  505.     return 2;
  506. }
  507.  
  508. Action Timer_SendRewardMatchEndDrops(Handle hTimer)
  509. {
  510.     if(g_hDSInfo.BoolValue)
  511.     {
  512.         g_hTimerWaitDrops = CreateTimer(1.2, Timer_WaitDrops);
  513.        
  514.         PrintToChatAll(" \x07Пытаемся призвать дроп");
  515.     }
  516.    
  517.     if(g_iOS == 1)
  518.     {
  519.         SDKCall(g_hRewardMatchEndDrops, 0xDEADC0DE, false);
  520.     }
  521.     else
  522.     {
  523.         SDKCall(g_hRewardMatchEndDrops, false);
  524.     }
  525.    
  526.     return Plugin_Continue;
  527. }
  528.  
  529. Action Timer_WaitDrops(Handle hTimer)
  530. {
  531.     g_hTimerWaitDrops = null;
  532.    
  533.     PrintToChatAll(" \x07Попытка провалилась :(");
  534. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement