multiple syntax updates to adjust for 1.11.0.6946 SM build

This commit is contained in:
jenz 2023-08-29 18:10:57 +02:00
parent a0c0f7e92d
commit b64abac26d
8 changed files with 149 additions and 136 deletions

View File

@ -123,7 +123,8 @@ public void OnClientDisconnect_Post(int client)
public Action Timer_CheckStatus(Handle hTimer) public Action Timer_CheckStatus(Handle hTimer)
{ {
CheckStatus(); CheckStatus();
return Plugin_Handled;
} }
public Action Command_Record(int client, int args) 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) public int Native_GetDemoRecordingTick(Handle hPlugin, int numParams)
{ {
return GetGameTickCount() - g_iRecordingFromTick; return GetGameTickCount() - g_iRecordingFromTick;
} }

View File

@ -192,70 +192,73 @@ public Action Command_PrintToAllChat(int args)
public Action Timer_DataProcessor(Handle hThis) public Action Timer_DataProcessor(Handle hThis)
{ {
if (!g_bProcessingData) if (!g_bProcessingData)
return; return Plugin_Handled;
if (g_iRatelimitRemaining == 0 && GetTime() < g_iRatelimitReset) if (g_iRatelimitRemaining == 0 && GetTime() < g_iRatelimitReset)
return; 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]; char sContent[1024];
g_arrQueuedMessages.GetString(0, sContent, sizeof(sContent)); g_arrQueuedMessages.GetString(0, sContent, sizeof(sContent));
g_arrQueuedMessages.Erase(0); g_arrQueuedMessages.Erase(0);
char sURL[128]; char sURL[128];
g_arrQueuedMessages.GetString(0, sURL, sizeof(sURL)); g_arrQueuedMessages.GetString(0, sURL, sizeof(sURL));
g_arrQueuedMessages.Erase(0); g_arrQueuedMessages.Erase(0);
if (g_arrQueuedMessages.Length == 0) if (g_arrQueuedMessages.Length == 0)
g_bProcessingData = false; 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<JSONObject>(json_load(sContent)); JSONObject RequestJSON = view_as<JSONObject>(json_load(sContent));
if (!hRequest || if (!hRequest ||
!SteamWorks_SetHTTPRequestContextValue(hRequest, RequestJSON) || !SteamWorks_SetHTTPRequestContextValue(hRequest, RequestJSON) ||
!SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestCompleted) || !SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestCompleted) ||
!SteamWorks_SetHTTPRequestRawPostBody(hRequest, "application/json", sContent, strlen(sContent)) || !SteamWorks_SetHTTPRequestRawPostBody(hRequest, "application/json", sContent, strlen(sContent)) ||
!SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest, 10) || !SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest, 10) ||
!SteamWorks_SendHTTPRequest(hRequest)) !SteamWorks_SendHTTPRequest(hRequest))
{ {
LogError("Discord SteamWorks_CreateHTTPRequest failed."); LogError("Discord SteamWorks_CreateHTTPRequest failed.");
delete RequestJSON; delete RequestJSON;
delete hRequest; 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 sMessageName[32];
char sMessageSender[64]; char sMessageSender[64];
int iAuthor = BfReadByte(bf); int iAuthor = BfReadByte(bf);
bool bIsChat = view_as<bool>(BfReadByte(bf)); if (bIsChat) bIsChat=false; //fucking compiler shut the fuck up REEEEEE bool bIsChat = view_as<bool>(BfReadByte(bf)); if (bIsChat) bIsChat=false; //fucking compiler shut the fuck up REEEEEE
BfReadString(bf, sMessageName, sizeof(sMessageName), false); BfReadString(bf, sMessageName, sizeof(sMessageName), false);
BfReadString(bf, sMessageSender, sizeof(sMessageSender), false); BfReadString(bf, sMessageSender, sizeof(sMessageSender), false);
if (iAuthor <= 0 || iAuthor > MaxClients) if (iAuthor <= 0 || iAuthor > MaxClients)
return; return Plugin_Handled;
if (strlen(sMessageName) == 0 || strlen(sMessageSender) == 0) if (strlen(sMessageName) == 0 || strlen(sMessageSender) == 0)
return; return Plugin_Handled;
if (strcmp(sMessageName, "#Cstrike_Name_Change") == 0) if (strcmp(sMessageName, "#Cstrike_Name_Change") == 0)
return; return Plugin_Handled;
if (sMessageName[13] == 'C' || sMessageName[13] == 'T' || sMessageName[13] == 'S') if (sMessageName[13] == 'C' || sMessageName[13] == 'T' || sMessageName[13] == 'S')
g_bTeamChat = true; g_bTeamChat = true;
else else
g_bTeamChat = false; g_bTeamChat = false;
return Plugin_Handled;
} }
stock bool Steam32IDtoSteam64ID(const char[] sSteam32ID, char[] sSteam64ID, int Size) 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) stock int OnTransferComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, int client)
{ {
if (bFailure || !bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK) if (bFailure || !bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
{ {
if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) if (eStatusCode != k_EHTTPStatusCode429TooManyRequests)
{ {
LogError("SteamAPI HTTP Response failed: %d", eStatusCode); LogError("SteamAPI HTTP Response failed: %d", eStatusCode);
} }
delete hRequest; delete hRequest;
return; return 0;
} }
int iBodyLength; int iBodyLength;
SteamWorks_GetHTTPResponseBodySize(hRequest, iBodyLength); SteamWorks_GetHTTPResponseBodySize(hRequest, iBodyLength);
char[] sData = new char[iBodyLength]; char[] sData = new char[iBodyLength];
SteamWorks_GetHTTPResponseBodyData(hRequest, sData, 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) 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) public int OnHTTPRequestCompleted(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, JSONObject RequestJSON)
{ {
if (bFailure || !bRequestSuccessful || (eStatusCode != k_EHTTPStatusCode200OK && eStatusCode != k_EHTTPStatusCode204NoContent)) if (bFailure || !bRequestSuccessful || (eStatusCode != k_EHTTPStatusCode200OK && eStatusCode != k_EHTTPStatusCode204NoContent))
{ {
if (eStatusCode != k_EHTTPStatusCode429TooManyRequests) if (eStatusCode != k_EHTTPStatusCode429TooManyRequests)
LogError("Discord HTTP request failed: %d", eStatusCode); LogError("Discord HTTP request failed: %d", eStatusCode);
if (eStatusCode == k_EHTTPStatusCode400BadRequest) if (eStatusCode == k_EHTTPStatusCode400BadRequest)
{ {
char sData[2048]; char sData[2048];
(view_as<JSONRootNode>(RequestJSON)).ToString(sData, sizeof(sData), 0); (view_as<JSONRootNode>(RequestJSON)).ToString(sData, sizeof(sData), 0);
LogError("Malformed request? Dumping request data:\n%s", sData); LogError("Malformed request? Dumping request data:\n%s", sData);
} }
else if (eStatusCode == k_EHTTPStatusCode429TooManyRequests) else if (eStatusCode == k_EHTTPStatusCode429TooManyRequests)
{ {
g_iRatelimitRemaining = 0; g_iRatelimitRemaining = 0;
g_iRatelimitReset = GetTime() + 5; g_iRatelimitReset = GetTime() + 5;
} }
delete RequestJSON; delete RequestJSON;
delete hRequest; delete hRequest;
return; return 0;
} }
static int iLastRatelimitRemaining = 0; static int iLastRatelimitRemaining = 0;
static int iLastRatelimitReset = 0; static int iLastRatelimitReset = 0;
char sTmp[32]; char sTmp[32];
bool bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-remaining", sTmp, sizeof(sTmp)); bool bHeaderExists = SteamWorks_GetHTTPResponseHeaderValue(hRequest, "x-ratelimit-remaining", sTmp, sizeof(sTmp));
if (!bHeaderExists) if (!bHeaderExists)
LogError("x-ratelimit-remaining header value could not be retrieved"); 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) if (!bHeaderExists)
LogError("x-ratelimit-reset header value could not be retrieved"); 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 if (iRatelimitRemaining < iLastRatelimitRemaining || iRatelimitReset >= iLastRatelimitReset) //don't be fooled by different completion times
{ {
g_iRatelimitRemaining = iRatelimitRemaining; g_iRatelimitRemaining = iRatelimitRemaining;
g_iRatelimitReset = iRatelimitReset; 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 RequestJSON;
delete hRequest; delete hRequest;
return 0;
} }
stock bool IsValidClient(int client) 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) public Action OnLogAction(Handle hSource, Identity ident, int client, int target, const char[] sMsg)
{ {
if (client <= 0) if (client <= 0)
return; return Plugin_Handled;
if ((StrContains(sMsg, "sm_psay", false)!= -1) || (StrContains(sMsg, "sm_chat", false)!= -1)) if ((StrContains(sMsg, "sm_psay", false)!= -1) || (StrContains(sMsg, "sm_chat", false)!= -1))
return;// dont log sm_psay and sm_chat return Plugin_Handled;// dont log sm_psay and sm_chat
char sFinal[256]; char sFinal[256];
char sCurrentMap[32]; char sCurrentMap[32];
char sDemoInfo[64]; char sDemoInfo[64];
char sClientName[64]; char sClientName[64];
GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
if (IsDemoRecording()) if (IsDemoRecording())
Format(sDemoInfo, sizeof(sDemoInfo), "Demo: %d @ Tick: %d", GetDemoRecordingNumber(), GetDemoRecordingTick()); Format(sDemoInfo, sizeof(sDemoInfo), "Demo: %d @ Tick: %d", GetDemoRecordingNumber(), GetDemoRecordingTick());
else else
Format(sDemoInfo, sizeof(sDemoInfo), "Not recording"); 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') if (g_sAvatarURL[client][0] != '\0')
Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, true, g_sAvatarURL[client], false); Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, true, g_sAvatarURL[client], false);
else else
Discord_POST(DISCORD_ADMINLOGS_WEBHOOKURL, sFinal, true, sClientName, false, "", false); 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) public Action CommandListener_SmChat(int client, const char[] sCommand, int argc)

4
FakeClients/scripting/FakeClients.sp Normal file → Executable file
View File

@ -149,6 +149,7 @@ public Action RandomizePing(Handle timer)
if(g_bFakePopulation[i]) if(g_bFakePopulation[i])
g_iLatency[i] = g_iBaseLatency[i] + GetRandomInt(-3, 3); g_iLatency[i] = g_iBaseLatency[i] + GetRandomInt(-3, 3);
} }
return Plugin_Continue;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -169,6 +170,7 @@ public Action RandomizeNames(Handle timer)
} }
} }
delete hNames; delete hNames;
return Plugin_Continue;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -537,4 +539,4 @@ public void OnGameFrame()
SetEntProp(iResEnt, Prop_Send, "m_iPing", g_iLatency[i], _, i); SetEntProp(iResEnt, Prop_Send, "m_iPing", g_iLatency[i], _, i);
} }
} }
} }

View File

@ -380,11 +380,12 @@ stock bool IsValidClient(int client)
int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2) int MenuHandler_NotifyPanel(Menu hMenu, MenuAction iAction, int iParam1, int iParam2)
{ {
switch (iAction) switch (iAction)
{ {
case MenuAction_Select, MenuAction_Cancel: case MenuAction_Select, MenuAction_Cancel:
delete hMenu; delete hMenu;
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -270,9 +270,9 @@ typeset SteamWorksHTTPDataReceived
typeset SteamWorksHTTPBodyCallback typeset SteamWorksHTTPBodyCallback
{ {
function void (const char sData[]); function void (const char[] sData);
function void (const char sData[], any value); function void (const char[] sData, any value);
function void (const int data[], any value, int datalen); function void (const int[] data, any value, int datalen);
}; };
#else #else

View File

@ -589,10 +589,11 @@ stock void C_SetupProfile()
public Action C_Event_MapStart(Event event, const char[] name, bool dontBroadcast) public Action C_Event_MapStart(Event event, const char[] name, bool dontBroadcast)
{ {
C_SetupProfile(); C_SetupProfile();
MuCo_LoopClients(i) MuCo_LoopClients(i)
C_SkipList[i] = false; C_SkipList[i] = false;
return Plugin_Handled;
} }
/** /**

View File

@ -667,6 +667,7 @@ public Action Command_SetNextmap(int client, int args)
public Action Command_ReloadMaps(int client, int args) public Action Command_ReloadMaps(int client, int args)
{ {
InitializeOfficialMapList(); InitializeOfficialMapList();
return Plugin_Handled;
} }
public Action Command_hours_average(int client, int args) 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) if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
SetupWarningTimer(WarningType_Vote); SetupWarningTimer(WarningType_Vote);
return Plugin_Handled;
} }
public Action Timer_StartMapVote(Handle timer, Handle data) public Action Timer_StartMapVote(Handle timer, Handle data)

View File

@ -336,8 +336,9 @@ void AttemptUnRTV(int client)
public Action Timer_DelayRTV(Handle timer) public Action Timer_DelayRTV(Handle timer)
{ {
g_RTVAllowed = true; g_RTVAllowed = true;
PrintToChatAll("[RTVE] RockTheVote is available now!"); PrintToChatAll("[RTVE] RockTheVote is available now!");
return Plugin_Handled;
} }
void StartRTV() void StartRTV()