@@ -155,6 +155,82 @@ void CScriptDebugging::LogCustom (lua_State* luaVM, const char* szMessage)
155
155
LogWarning (luaVM, " %s" , szMessage);
156
156
}
157
157
158
+
159
+ void CScriptDebugging::LogString (const char * szPrePend, const SLuaDebugInfo& luaDebugInfo, const char * szMessage, unsigned int uiMinimumDebugLevel, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue)
160
+ {
161
+ SString strText = ComposeErrorMessage (szPrePend, luaDebugInfo, szMessage);
162
+
163
+ // Create a different message if type is "INFO"
164
+ if (uiMinimumDebugLevel > 2 )
165
+ strText = SString (" %s%s" , szPrePend, szMessage);
166
+
167
+ switch (uiMinimumDebugLevel)
168
+ {
169
+ case 1 :
170
+ ucRed = 255 , ucGreen = 0 , ucBlue = 0 ;
171
+ break ;
172
+ case 2 :
173
+ ucRed = 255 , ucGreen = 128 , ucBlue = 0 ;
174
+ break ;
175
+ case 3 :
176
+ ucRed = 0 , ucGreen = 255 , ucBlue = 0 ;
177
+ break ;
178
+ default :
179
+ break ;
180
+ }
181
+
182
+ // Check whether on(Client)DebugMessage is currently being triggered
183
+ if (!m_bTriggeringMessageEvent)
184
+ {
185
+ // Make sure the state of on(Client)DebugMessage being triggered can be retrieved later
186
+ m_bTriggeringMessageEvent = true ;
187
+
188
+ // Prepare onDebugMessage
189
+ CLuaArguments Arguments;
190
+ Arguments.PushString (szMessage);
191
+ Arguments.PushNumber (uiMinimumDebugLevel);
192
+
193
+ // Push the file name (if any)
194
+ if (!luaDebugInfo.strFile .empty ())
195
+ Arguments.PushString (luaDebugInfo.strFile );
196
+ else
197
+ Arguments.PushNil ();
198
+
199
+ // Push the line (if any)
200
+ if (luaDebugInfo.iLine != INVALID_LINE_NUMBER)
201
+ Arguments.PushNumber (luaDebugInfo.iLine );
202
+ else
203
+ Arguments.PushNil ();
204
+
205
+ // Push the colors
206
+ Arguments.PushNumber (ucRed);
207
+ Arguments.PushNumber (ucGreen);
208
+ Arguments.PushNumber (ucBlue);
209
+
210
+ // Call on(Client)DebugMessage
211
+ #ifdef MTA_CLIENT
212
+ g_pClientGame->GetRootEntity ()->CallEvent (" onClientDebugMessage" , Arguments, false );
213
+ #else
214
+ g_pGame->GetMapManager ()->GetRootElement ()->CallEvent (" onDebugMessage" , Arguments);
215
+ #endif
216
+
217
+ // Reset trigger state, so onDebugMessage can be called again at a later moment
218
+ m_bTriggeringMessageEvent = false ;
219
+ }
220
+
221
+ m_DuplicateLineFilter.AddLine ({ strText, uiMinimumDebugLevel, ucRed, ucGreen, ucBlue });
222
+
223
+ #ifdef MTA_CLIENT
224
+ if (g_pCore->GetCVars ()->GetValue < bool > (" filter_duplicate_log_lines" ) == false )
225
+ #else
226
+ if (g_pGame->GetConfig ()->GetFilterDuplicateLogLinesEnabled () == false )
227
+ #endif
228
+ {
229
+ m_DuplicateLineFilter.Flush ();
230
+ }
231
+ UpdateLogOutput ();
232
+ }
233
+
158
234
//
159
235
// Get best debug info we possibly can from the relevent lua state
160
236
//
0 commit comments