11#pragma semicolon 1
22
3- #include <sdktools >
3+ #include <sourcemod >
44#include <tf2_stocks>
55#include <steamtools>
66
1111#pragma newdecls required
1212
1313ArrayList g_utaunts_id , g_utaunts_classname , g_utaunts_name ;
14- int g_iTauntEffect [MAXPLAYERS + 1 ], g_iTauntParticle [MAXPLAYERS + 1 ];
14+ int g_iTauntEffect [MAXPLAYERS + 1 ], g_iTauntParticle [MAXPLAYERS + 1 ], tryCount ;
15+ bool hadError ;
1516
1617public Plugin myinfo =
1718{
@@ -30,6 +31,7 @@ public void OnPluginStart()
3031
3132public void OnConfigsExecuted ()
3233{
34+ tryCount = 0 ;
3335 CreateRequest ();
3436}
3537
@@ -41,6 +43,18 @@ public Action Command_TauntEffect(int client, int args)
4143 return Plugin_Handled ;
4244 }
4345
46+ if (! strcmp (STEAM_API_KEY , " NAN" ))
47+ {
48+ ReplyToCommand (client , " [SM] The owner did not define a valid STEAM API KEY." );
49+ return Plugin_Handled ;
50+ }
51+
52+ if (hadError )
53+ {
54+ ReplyToCommand (client , " [SM] There was an error with the server's HTTP Request, try again later." );
55+ return Plugin_Handled ;
56+ }
57+
4458 char name [32 ], index [8 ];
4559
4660 Menu menu = new Menu (Handler );
@@ -147,9 +161,19 @@ public void OnHTTPResponse(HTTPRequestHandle request, bool successful, HTTPStatu
147161 if (! successful || eStatusCode != HTTPStatusCode_OK )
148162 {
149163 Steam_ReleaseHTTPRequest (request );
164+ hadError = true ;
165+
166+ if (tryCount < 10 )
167+ {
168+ CreateTimer (30.0 , TryAgain , _ , TIMER_FLAG_NO_MAPCHANGE ); // too many requests in a small interval can generate HTTP errors too
169+ }
170+
150171 return ;
151172 }
152173
174+ hadError = false ;
175+ tryCount = 0 ;
176+
153177 int len = Steam_GetHTTPResponseBodySize (request );
154178 char [] response = new char [len ];
155179 Steam_GetHTTPResponseBodyData (request , response , len );
@@ -201,6 +225,15 @@ public void OnHTTPResponse(HTTPRequestHandle request, bool successful, HTTPStatu
201225 Steam_ReleaseHTTPRequest (request );
202226}
203227
228+ public Action TryAgain (Handle timer )
229+ {
230+ if (hadError )
231+ {
232+ tryCount ++ ;
233+ CreateRequest ();
234+ }
235+ }
236+
204237bool IsInt (const char [] str , const int len )
205238{
206239 for (int i = 0 ; i < len ; i ++ )
0 commit comments