@@ -160,14 +160,16 @@ static std::string GetBotAnswer(int type, nlohmann::json response)
160160 catch (std::exception exc)
161161 {
162162 logprintf (" ChatBot Plugin Exception GetBotAnswer(): %s\n " , exc.what ());
163+ logprintf (" Chatbot Plugin Exception Response:\n %s" , response.dump (4 ).c_str ());
164+
163165 return response.dump (4 ).c_str ();
164166 }
165167 }
166168
167169 return " " ;
168170}
169171
170- static void DoRequest (std::string prompt, int playerid )
172+ static void DoRequest (std::string prompt, int id )
171173{
172174 std::string response;
173175
@@ -220,7 +222,7 @@ static void DoRequest(std::string prompt, int playerid)
220222
221223 std::string answer = GetBotAnswer (curChatBot, jresponse);
222224
223- AIResponse resp (playerid , prompt, answer);
225+ AIResponse resp (id , prompt, answer);
224226
225227 responseLock.lock ();
226228 responses.push (resp);
@@ -245,14 +247,14 @@ static void RequestsThread()
245247 requestLock.unlock ();
246248
247249 std::string prompt = curRequest.GetPrompt ();
248- int playerid = curRequest.GetPlayerID ();
250+ int id = curRequest.GetID ();
249251
250- if (!prompt.empty () && playerid >= 0 )
252+ if (!prompt.empty ())
251253 {
252254#ifdef _DEBUG
253255 logprintf (" \n new request: %s\n " , prompt.c_str ());
254256#endif
255- DoRequest (prompt, playerid );
257+ DoRequest (prompt, id );
256258 curRequest.Clear ();
257259 }
258260 else
@@ -271,7 +273,7 @@ PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
271273{
272274 pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
273275 logprintf = (logprintf_t )ppData[PLUGIN_DATA_LOGPRINTF];
274- logprintf (" \n\n ChatBot API Plugin by SimoSbara loaded\n " , PLUGIN_VERSION);
276+ logprintf (" \n\n ChatBot API Plugin %s by SimoSbara loaded\n " , PLUGIN_VERSION);
275277
276278 EncodingHelper::Init ();
277279
@@ -286,22 +288,22 @@ PLUGIN_EXPORT void PLUGIN_CALL Unload()
286288{
287289 running = false ;
288290
289- logprintf (" \n\n ChatBot API Plugin by SimoSbara unloaded\n " , PLUGIN_VERSION);
291+ logprintf (" \n\n ChatBot API Plugin %s by SimoSbara unloaded\n " , PLUGIN_VERSION);
290292}
291293
292294static cell AMX_NATIVE_CALL n_RequestToChatBot (AMX* amx, cell* params)
293295{
294296 char * pRequest = NULL ;
295297
296- CHECK_PARAMS (2 , " RequestToChatBot" ); // playerid , request string
298+ CHECK_PARAMS (2 , " RequestToChatBot" ); // id int , request string
297299
298300 amx_StrParam (amx, params[1 ], pRequest);
299301
300- int playerID = static_cast <int >(params[2 ]);
302+ int id = static_cast <int >(params[2 ]);
301303
302- if (playerID >= 0 && pRequest)
304+ if (pRequest)
303305 {
304- AIRequest newRequest (playerID , std::string (pRequest));
306+ AIRequest newRequest (id , std::string (pRequest));
305307
306308 requestLock.lock ();
307309 requestes.push (newRequest);
@@ -431,7 +433,7 @@ PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
431433 if (!amx_FindPublic (*a, " OnChatBotResponse" , &amxIndex))
432434 {
433435 // parametri al contrario
434- amx_Push (*a, response.GetPlayerID ());
436+ amx_Push (*a, response.GetID ());
435437 amx_PushString (*a, &amxAddresses[0 ], NULL , response.GetResponse ().c_str (), 0 , 0 );
436438 amx_PushString (*a, &amxAddresses[1 ], NULL , response.GetPrompt ().c_str (), 0 , 0 );
437439 amx_Exec (*a, NULL , amxIndex);
0 commit comments