22.10.2011, 20:10
(
Last edited by JernejL; 23/10/2011 at 01:47 PM.
)
Recently i went thru a low level overhaul of the main gamemode that i work with, it is sometimes very difficult to monitor what a script is doing in background - i am sure that a lot of you spent many sessions placing and removing printf calls all around code while trying to debug complex bugs and issues in your scripts.
So i built this plugin, which logs all operative calls. This excludes the GetPlayerxxx, IsPlayerxxx and a few other functions on purpose, as the functions which retrieve data from sa-mp aren't as important as those that SET it - but you can recompile the plugin to see those (and the resulting spam) as well., the defines are in the plugin to do so.
The calls and data is all outputted to sa-mp console / server log, here is a example output:
You can see that the output is pretty well detailed.
The calls can also include streamer plugin calls, as long as the plugin is set to be loaded after the streamer (put ExecLogger at the end of plugin server.cfg line), this also works with other plugins that call sa-mp natives.
With detailed list of calls you are sending to sa-mp, you can optimize your script better. It will help you find redundant calls, unused code, wrong data, etc.. it also works well in tandem with Zeex's crashdetect plugin - you can see which sa-mp natives were made before the crash, and that helps you locate the problem in your code when there is no crashdetect stack trace)
Thanks to: Zeex, BlueG.
Be advised, that this is a 0.3C version - it will probably work in 0.3D - it is not tested there, so try it but in theory it should work directly.
Download for windows:
http://www.mathpudding.com/topsecretsamp/ExecLogger.rar
Download for linux:
http://www.mathpudding.com/topsecret...gger_linux.rar
IF YOU DO NOT UNDERSTAND WHAT THIS PLUGIN DOES, DO NOT JUST INSTALL IT BLINDLY FOR NO GOOD REASON, ESPECIALLY ON A LIVE SERVER - THIS IS FOR LOCAL TESTING ONLY.
source code (copy into examples folder of Zeex's plugin SDK and compile with code::blocks or make):
http://www.mathpudding.com/topsecret...Logger_src.rar
So i built this plugin, which logs all operative calls. This excludes the GetPlayerxxx, IsPlayerxxx and a few other functions on purpose, as the functions which retrieve data from sa-mp aren't as important as those that SET it - but you can recompile the plugin to see those (and the resulting spam) as well., the defines are in the plugin to do so.
The calls and data is all outputted to sa-mp console / server log, here is a example output:
Code:
[19:51:48] IsPlayerConnected (playerid = 349, result = 0); [19:51:48] SetTimer (funcname = "RunWeatherTimer" interval = 1000 repeating = 1, result = 3); [19:51:48] SetTimer (funcname = "CheckIRCCommand" interval = 1000 repeating = 1, result = 4); [19:51:48] CreateMenu (title = "Spectator" columns = 2 x = 125.00000 y = 130.00000 col1width = 190.00000 col2width = 0.0 = 150.00000, result = MENU:1); [19:51:48] SetMenuColumnHeader (menuid = MENU:1 column = 0 columnheader = "Action", result = 1); [19:51:48] SetMenuColumnHeader (menuid = MENU:1 column = 1 columnheader = "Mouse + Keys", result = 1); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "----------------------", result = 0); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "----------------------", result = 0); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "Previous player:", result = 1); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "~k~~PED_LOCK_TARGET~", result = 1); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "Next player:", result = 2); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "~k~~PED_FIREWEAPON~", result = 2); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "Change view:", result = 3); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "~k~~PED_DUCK~", result = 3); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "Exit spectator:", result = 4); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "~k~~PED_JUMPING~", result = 4); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = "----------------------", result = 5); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = "----------------------", result = 5); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = " ", result = 6); [19:51:48] AddMenuItem (menuid = MENU:1 column = 1 menutext = " ", result = 6); [19:51:48] AddMenuItem (menuid = MENU:1 column = 0 menutext = " Accept", result = 7); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 0, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 1, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 2, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 3, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 4, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 5, result = 1); [19:51:48] DisableMenuRow (menuid = MENU:1 row = 6, result = 1); [19:51:48] CreateObject (modelid = 14548 X = 335.81201 Y = 1004.71997 Z = 1950.50000 rX = 13.00000 rY = 0.00000 rZ = 0.00000 DrawDistance = 0.0 = 0.00000, result = 1); [19:51:48] CreateObject (modelid = 14548 X = -1343.31775 Y = -272.34680 Z = 300.57529 rX = 13.00000 rY = 0.00000 rZ = 46.81210 DrawDistance = 0.0 = 0.00000, result = 2); [19:51:48] CreateObject (modelid = 14548 X = 282.26001 Y = 1076.01001 Z = 0.00000 rX = 13.00000 rY = 0.00000 rZ = 90.00000 DrawDistance = 0.0 = 0.00000, result = 3); [19:51:48] CreateObject (modelid = 4847 X = -1117.63000 Y = 1483.83997 Z = 1.55000 rX = -8.00000 rY = 0.00000 rZ = -64.82000 DrawDistance = 0.0 = 0.00000, result = 4);
The calls can also include streamer plugin calls, as long as the plugin is set to be loaded after the streamer (put ExecLogger at the end of plugin server.cfg line), this also works with other plugins that call sa-mp natives.
With detailed list of calls you are sending to sa-mp, you can optimize your script better. It will help you find redundant calls, unused code, wrong data, etc.. it also works well in tandem with Zeex's crashdetect plugin - you can see which sa-mp natives were made before the crash, and that helps you locate the problem in your code when there is no crashdetect stack trace)
Thanks to: Zeex, BlueG.
Be advised, that this is a 0.3C version - it will probably work in 0.3D - it is not tested there, so try it but in theory it should work directly.
Download for windows:
http://www.mathpudding.com/topsecretsamp/ExecLogger.rar
Download for linux:
http://www.mathpudding.com/topsecret...gger_linux.rar
IF YOU DO NOT UNDERSTAND WHAT THIS PLUGIN DOES, DO NOT JUST INSTALL IT BLINDLY FOR NO GOOD REASON, ESPECIALLY ON A LIVE SERVER - THIS IS FOR LOCAL TESTING ONLY.
source code (copy into examples folder of Zeex's plugin SDK and compile with code::blocks or make):
http://www.mathpudding.com/topsecret...Logger_src.rar