From b64abac26d986c7f120e4a60e7bab24c09e1f7d5 Mon Sep 17 00:00:00 2001 From: jenz Date: Tue, 29 Aug 2023 18:10:57 +0200 Subject: [PATCH] multiple syntax updates to adjust for 1.11.0.6946 SM build --- AutoRecorder/scripting/AutoRecorder.sp | 5 +- Discord_UNLOZE/scripting/Discord_UNLOZE.sp | 243 +++++++++--------- FakeClients/scripting/FakeClients.sp | 4 +- .../scripting/PlayerManager_Connect.sp | 11 +- includes/SteamWorks.inc | 6 +- includes/multicolors/colors.inc | 9 +- .../scripting/mapchooser_extended.sp | 2 + .../scripting/rockthevote_extended.sp | 5 +- 8 files changed, 149 insertions(+), 136 deletions(-) mode change 100644 => 100755 FakeClients/scripting/FakeClients.sp diff --git a/AutoRecorder/scripting/AutoRecorder.sp b/AutoRecorder/scripting/AutoRecorder.sp index c21c12a9..7e0d5e27 100644 --- a/AutoRecorder/scripting/AutoRecorder.sp +++ b/AutoRecorder/scripting/AutoRecorder.sp @@ -123,7 +123,8 @@ public void OnClientDisconnect_Post(int client) public Action Timer_CheckStatus(Handle hTimer) { - CheckStatus(); + CheckStatus(); + return Plugin_Handled; } public Action Command_Record(int client, int args) @@ -251,4 +252,4 @@ public int Native_GetDemoRecordingNumber(Handle hPlugin, int numParams) public int Native_GetDemoRecordingTick(Handle hPlugin, int numParams) { return GetGameTickCount() - g_iRecordingFromTick; -} \ No newline at end of file +} diff --git a/Discord_UNLOZE/scripting/Discord_UNLOZE.sp b/Discord_UNLOZE/scripting/Discord_UNLOZE.sp index cf1f48e5..8dd450d2 100644 --- a/Discord_UNLOZE/scripting/Discord_UNLOZE.sp +++ b/Discord_UNLOZE/scripting/Discord_UNLOZE.sp @@ -192,70 +192,73 @@ public Action Command_PrintToAllChat(int args) public Action Timer_DataProcessor(Handle hThis) { - if (!g_bProcessingData) - return; + if (!g_bProcessingData) + return Plugin_Handled; - if (g_iRatelimitRemaining == 0 && GetTime() < g_iRatelimitReset) - return; + if (g_iRatelimitRemaining == 0 && GetTime() < g_iRatelimitReset) + return Plugin_Handled; - //PrintToServer("[Timer_DataProcessor] Array Length #1: %d", g_arrQueuedMessages.Length); + //PrintToServer("[Timer_DataProcessor] Array Length #1: %d", g_arrQueuedMessages.Length); - char sContent[1024]; - g_arrQueuedMessages.GetString(0, sContent, sizeof(sContent)); - g_arrQueuedMessages.Erase(0); + char sContent[1024]; + g_arrQueuedMessages.GetString(0, sContent, sizeof(sContent)); + g_arrQueuedMessages.Erase(0); - char sURL[128]; - g_arrQueuedMessages.GetString(0, sURL, sizeof(sURL)); - g_arrQueuedMessages.Erase(0); + char sURL[128]; + g_arrQueuedMessages.GetString(0, sURL, sizeof(sURL)); + g_arrQueuedMessages.Erase(0); - if (g_arrQueuedMessages.Length == 0) - g_bProcessingData = false; + if (g_arrQueuedMessages.Length == 0) + g_bProcessingData = false; - //PrintToServer("[Timer_DataProcessor] Array Length #2: %d", g_arrQueuedMessages.Length); + //PrintToServer("[Timer_DataProcessor] Array Length #2: %d", g_arrQueuedMessages.Length); - //PrintToServer("%s | %s", sURL, sContent); + //PrintToServer("%s | %s", sURL, sContent); - Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, sURL); + Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, sURL); - JSONObject RequestJSON = view_as(json_load(sContent)); + JSONObject RequestJSON = view_as(json_load(sContent)); - if (!hRequest || - !SteamWorks_SetHTTPRequestContextValue(hRequest, RequestJSON) || - !SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestCompleted) || - !SteamWorks_SetHTTPRequestRawPostBody(hRequest, "application/json", sContent, strlen(sContent)) || - !SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest, 10) || - !SteamWorks_SendHTTPRequest(hRequest)) - { - LogError("Discord SteamWorks_CreateHTTPRequest failed."); + if (!hRequest || + !SteamWorks_SetHTTPRequestContextValue(hRequest, RequestJSON) || + !SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestCompleted) || + !SteamWorks_SetHTTPRequestRawPostBody(hRequest, "application/json", sContent, strlen(sContent)) || + !SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest, 10) || + !SteamWorks_SendHTTPRequest(hRequest)) + { + LogError("Discord SteamWorks_CreateHTTPRequest failed."); - delete RequestJSON; - delete hRequest; + delete RequestJSON; + delete hRequest; - return; - } + return Plugin_Handled; + } + return Plugin_Handled; } -public Action Hook_UserMessage(UserMsg msg_id, Handle bf, const players[], int playersNum, bool reliable, bool init) + +public Action Hook_UserMessage(UserMsg msg_id, Handle bf, const int[] players, int playersNum, bool reliable, bool init) { - char sMessageName[32]; - char sMessageSender[64]; - int iAuthor = BfReadByte(bf); - bool bIsChat = view_as(BfReadByte(bf)); if (bIsChat) bIsChat=false; //fucking compiler shut the fuck up REEEEEE - BfReadString(bf, sMessageName, sizeof(sMessageName), false); - BfReadString(bf, sMessageSender, sizeof(sMessageSender), false); + char sMessageName[32]; + char sMessageSender[64]; + int iAuthor = BfReadByte(bf); + bool bIsChat = view_as(BfReadByte(bf)); if (bIsChat) bIsChat=false; //fucking compiler shut the fuck up REEEEEE + BfReadString(bf, sMessageName, sizeof(sMessageName), false); + BfReadString(bf, sMessageSender, sizeof(sMessageSender), false); - if (iAuthor <= 0 || iAuthor > MaxClients) - return; + if (iAuthor <= 0 || iAuthor > MaxClients) + return Plugin_Handled; - if (strlen(sMessageName) == 0 || strlen(sMessageSender) == 0) - return; + if (strlen(sMessageName) == 0 || strlen(sMessageSender) == 0) + return Plugin_Handled; - if (strcmp(sMessageName, "#Cstrike_Name_Change") == 0) - return; + if (strcmp(sMessageName, "#Cstrike_Name_Change") == 0) + return Plugin_Handled; - if (sMessageName[13] == 'C' || sMessageName[13] == 'T' || sMessageName[13] == 'S') - g_bTeamChat = true; - else - g_bTeamChat = false; + if (sMessageName[13] == 'C' || sMessageName[13] == 'T' || sMessageName[13] == 'S') + g_bTeamChat = true; + else + g_bTeamChat = false; + return Plugin_Handled; } stock bool Steam32IDtoSteam64ID(const char[] sSteam32ID, char[] sSteam64ID, int Size) @@ -350,26 +353,27 @@ stock void Discord_MakeStringSafe(const char[] sOrigin, char[] sOut, int iOutSiz stock int OnTransferComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, int client) { - if (bFailure || !bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK) - { - if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) - { - LogError("SteamAPI HTTP Response failed: %d", eStatusCode); - } + if (bFailure || !bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK) + { + if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) + { + LogError("SteamAPI HTTP Response failed: %d", eStatusCode); + } - delete hRequest; - return; - } + delete hRequest; + return 0; + } - int iBodyLength; - SteamWorks_GetHTTPResponseBodySize(hRequest, iBodyLength); + int iBodyLength; + SteamWorks_GetHTTPResponseBodySize(hRequest, iBodyLength); - char[] sData = new char[iBodyLength]; - SteamWorks_GetHTTPResponseBodyData(hRequest, sData, iBodyLength); + char[] sData = new char[iBodyLength]; + SteamWorks_GetHTTPResponseBodyData(hRequest, sData, iBodyLength); - delete hRequest; + delete hRequest; - APIWebResponse(sData, client); + APIWebResponse(sData, client); + return 0; } stock void APIWebResponse(const char[] sData, int client) @@ -520,58 +524,59 @@ stock void Discord_POST(const char[] sURL, char[] sText, bool bUsingUsername=fal public int OnHTTPRequestCompleted(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, JSONObject RequestJSON) { - if (bFailure || !bRequestSuccessful || (eStatusCode != k_EHTTPStatusCode200OK && eStatusCode != k_EHTTPStatusCode204NoContent)) - { - if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) - LogError("Discord HTTP request failed: %d", eStatusCode); + if (bFailure || !bRequestSuccessful || (eStatusCode != k_EHTTPStatusCode200OK && eStatusCode != k_EHTTPStatusCode204NoContent)) + { + if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) + LogError("Discord HTTP request failed: %d", eStatusCode); - if (eStatusCode == k_EHTTPStatusCode400BadRequest) - { - char sData[2048]; + if (eStatusCode == k_EHTTPStatusCode400BadRequest) + { + char sData[2048]; - (view_as(RequestJSON)).ToString(sData, sizeof(sData), 0); + (view_as(RequestJSON)).ToString(sData, sizeof(sData), 0); - LogError("Malformed request? Dumping request data:\n%s", sData); - } - else if (eStatusCode == k_EHTTPStatusCode429TooManyRequests) - { - g_iRatelimitRemaining = 0; - g_iRatelimitReset = GetTime() + 5; - } + LogError("Malformed request? Dumping request data:\n%s", sData); + } + else if (eStatusCode == k_EHTTPStatusCode429TooManyRequests) + { + g_iRatelimitRemaining = 0; + g_iRatelimitReset = GetTime() + 5; + } - delete RequestJSON; - delete hRequest; + delete RequestJSON; + delete hRequest; - return; - } + return 0; + } - static int iLastRatelimitRemaining = 0; - static int iLastRatelimitReset = 0; - char sTmp[32]; - bool bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-remaining", sTmp, sizeof(sTmp)); + static int iLastRatelimitRemaining = 0; + static int iLastRatelimitReset = 0; + char sTmp[32]; + bool bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-remaining", sTmp, sizeof(sTmp)); - if (!bHeaderExists) - LogError("x-ratelimit-remaining header value could not be retrieved"); + if (!bHeaderExists) + LogError("x-ratelimit-remaining header value could not be retrieved"); - int iRatelimitRemaining = StringToInt(sTmp); + int iRatelimitRemaining = StringToInt(sTmp); - bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-reset", sTmp, sizeof(sTmp)); + bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-reset", sTmp, sizeof(sTmp)); - if (!bHeaderExists) - LogError("x-ratelimit-reset header value could not be retrieved"); + if (!bHeaderExists) + LogError("x-ratelimit-reset header value could not be retrieved"); - int iRatelimitReset = StringToInt(sTmp); + int iRatelimitReset = StringToInt(sTmp); - if (iRatelimitRemaining < iLastRatelimitRemaining || iRatelimitReset >= iLastRatelimitReset) //don't be fooled by different completion times - { - g_iRatelimitRemaining = iRatelimitRemaining; - g_iRatelimitReset = iRatelimitReset; - } + if (iRatelimitRemaining < iLastRatelimitRemaining || iRatelimitReset >= iLastRatelimitReset) //don't be fooled by different completion times + { + g_iRatelimitRemaining = iRatelimitRemaining; + g_iRatelimitReset = iRatelimitReset; + } - //PrintToServer("limit: %d | remaining: %d || reset %d - now %d", g_iRatelimitLimit, g_iRatelimitRemaining, g_iRatelimitReset, GetTime()); + //PrintToServer("limit: %d | remaining: %d || reset %d - now %d", g_iRatelimitLimit, g_iRatelimitRemaining, g_iRatelimitReset, GetTime()); - delete RequestJSON; - delete hRequest; + delete RequestJSON; + delete hRequest; + return 0; } stock bool IsValidClient(int client) @@ -581,34 +586,34 @@ stock bool IsValidClient(int client) public Action OnLogAction(Handle hSource, Identity ident, int client, int target, const char[] sMsg) { - if (client <= 0) - return; + if (client <= 0) + return Plugin_Handled; - if ((StrContains(sMsg, "sm_psay", false)!= -1) || (StrContains(sMsg, "sm_chat", false)!= -1)) - return;// dont log sm_psay and sm_chat + if ((StrContains(sMsg, "sm_psay", false)!= -1) || (StrContains(sMsg, "sm_chat", false)!= -1)) + return Plugin_Handled;// dont log sm_psay and sm_chat - char sFinal[256]; - char sCurrentMap[32]; - char sDemoInfo[64]; - char sClientName[64]; + char sFinal[256]; + char sCurrentMap[32]; + char sDemoInfo[64]; + char sClientName[64]; - GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); + GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); - if (IsDemoRecording()) - Format(sDemoInfo, sizeof(sDemoInfo), "Demo: %d @ Tick: %d", GetDemoRecordingNumber(), GetDemoRecordingTick()); - else - Format(sDemoInfo, sizeof(sDemoInfo), "Not recording"); + if (IsDemoRecording()) + Format(sDemoInfo, sizeof(sDemoInfo), "Demo: %d @ Tick: %d", GetDemoRecordingNumber(), GetDemoRecordingTick()); + else + Format(sDemoInfo, sizeof(sDemoInfo), "Not recording"); - Format(sFinal, sizeof(sFinal), "[ %s ][ %s ]```%s```", sCurrentMap, sDemoInfo, sMsg); + Format(sFinal, sizeof(sFinal), "[ %s ][ %s ]```%s```", sCurrentMap, sDemoInfo, sMsg); - GetClientName(client, sClientName, sizeof(sClientName)); + GetClientName(client, sClientName, sizeof(sClientName)); - if (g_sAvatarURL[client][0] != '\0') - Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, true, g_sAvatarURL[client], false); - else - Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, false, "", false); + if (g_sAvatarURL[client][0] != '\0') + Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, true, g_sAvatarURL[client], false); + else + Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, false, "", false); - return; + return Plugin_Handled; } public Action CommandListener_SmChat(int client, const char[] sCommand, int argc) diff --git a/FakeClients/scripting/FakeClients.sp b/FakeClients/scripting/FakeClients.sp old mode 100644 new mode 100755 index c46ef847..6f4b35e7 --- a/FakeClients/scripting/FakeClients.sp +++ b/FakeClients/scripting/FakeClients.sp @@ -149,6 +149,7 @@ public Action RandomizePing(Handle timer) if(g_bFakePopulation[i]) g_iLatency[i] = g_iBaseLatency[i] + GetRandomInt(-3, 3); } + return Plugin_Continue; } //---------------------------------------------------------------------------------------------------- @@ -169,6 +170,7 @@ public Action RandomizeNames(Handle timer) } } delete hNames; + return Plugin_Continue; } //---------------------------------------------------------------------------------------------------- @@ -537,4 +539,4 @@ public void OnGameFrame() SetEntProp(iResEnt, Prop_Send, "m_iPing", g_iLatency[i], _, i); } } -} \ No newline at end of file +} diff --git a/PlayerManager/scripting/PlayerManager_Connect.sp b/PlayerManager/scripting/PlayerManager_Connect.sp index 2fd8ac84..07aaadc6 100644 --- a/PlayerManager/scripting/PlayerManager_Connect.sp +++ b/PlayerManager/scripting/PlayerManager_Connect.sp @@ -380,11 +380,12 @@ stock bool IsValidClient(int client) int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2) { - switch (iAction) - { - case MenuAction_Select, MenuAction_Cancel: - delete hMenu; - } + switch (iAction) + { + case MenuAction_Select, MenuAction_Cancel: + delete hMenu; + } + return 0; } //---------------------------------------------------------------------------------------------------- diff --git a/includes/SteamWorks.inc b/includes/SteamWorks.inc index 565969fb..bebbb3f3 100644 --- a/includes/SteamWorks.inc +++ b/includes/SteamWorks.inc @@ -270,9 +270,9 @@ typeset SteamWorksHTTPDataReceived typeset SteamWorksHTTPBodyCallback { - function void (const char sData[]); - function void (const char sData[], any value); - function void (const int data[], any value, int datalen); + function void (const char[] sData); + function void (const char[] sData, any value); + function void (const int[] data, any value, int datalen); }; #else diff --git a/includes/multicolors/colors.inc b/includes/multicolors/colors.inc index 17bf1b18..c0c8305d 100644 --- a/includes/multicolors/colors.inc +++ b/includes/multicolors/colors.inc @@ -589,10 +589,11 @@ stock void C_SetupProfile() public Action C_Event_MapStart(Event event, const char[] name, bool dontBroadcast) { - C_SetupProfile(); - - MuCo_LoopClients(i) - C_SkipList[i] = false; + C_SetupProfile(); + + MuCo_LoopClients(i) + C_SkipList[i] = false; + return Plugin_Handled; } /** diff --git a/mapchooser_extended/scripting/mapchooser_extended.sp b/mapchooser_extended/scripting/mapchooser_extended.sp index 1f235127..df55f96b 100755 --- a/mapchooser_extended/scripting/mapchooser_extended.sp +++ b/mapchooser_extended/scripting/mapchooser_extended.sp @@ -667,6 +667,7 @@ public Action Command_SetNextmap(int client, int args) public Action Command_ReloadMaps(int client, int args) { InitializeOfficialMapList(); + return Plugin_Handled; } public Action Command_hours_average(int client, int args) @@ -731,6 +732,7 @@ public Action Timer_StartWarningTimer(Handle timer) if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE) SetupWarningTimer(WarningType_Vote); + return Plugin_Handled; } public Action Timer_StartMapVote(Handle timer, Handle data) diff --git a/mapchooser_extended/scripting/rockthevote_extended.sp b/mapchooser_extended/scripting/rockthevote_extended.sp index 5df59321..520fdd88 100644 --- a/mapchooser_extended/scripting/rockthevote_extended.sp +++ b/mapchooser_extended/scripting/rockthevote_extended.sp @@ -336,8 +336,9 @@ void AttemptUnRTV(int client) public Action Timer_DelayRTV(Handle timer) { - g_RTVAllowed = true; - PrintToChatAll("[RTVE] RockTheVote is available now!"); + g_RTVAllowed = true; + PrintToChatAll("[RTVE] RockTheVote is available now!"); + return Plugin_Handled; } void StartRTV()