SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 15/07/2019, 06:10 PM   #1
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default SDiag - automatic diagnostics of frequent problems when the server starts

SDiag

This include is intended to diagnose frequently encountered problems, many of which often appear through negligence. The script checks some conditions and then displays the corresponding warnings in the console and the server log.

Important note: this script only detects problems, but does not fix them on its own!

Currently it can detect the following problems:
  • Missing FILTERSCRIPT define in filterscripts (it's needed for many includes to work correctly)
  • Mismatch of MAX_PLAYERS macro and actual player slots on the server
  • GetTickCount overflow due to long continuous physical server operation
  • Outdated version of default SA-MP includes in relation to version of the server executable file (checks for 0.3.7, 0.3.7-R2, 0.3.7-R3 and 0.3.DL)
  • Absence of the scriptfiles folder or lack of access to it (it's needed for some scripts to work correctly)
  • Invalid maxnpc value in server.cfg when it exceeds the maximum player slots number on the server
  • Low sleep values in server.cfg, which can highly affect the accuracy of timers
  • Disabled query in server.cfg, which makes the server invisible for SA-MP launcher

Installation
Nothing complicated. Just download the script from one of the links below, move it to pawno/include folder and add to all filterscripts and gamemode by this way:
PHP Code:
#include <sdiag> 
and then recompile them.


How to use
When you turn the server on, a number of warnings will appear in the console if any problems are detected. Warnings in the gamemode are marked as "[SDiag: GM]" and "[SDiag: FS]" in filterscripts. Include doesn't have information about the name of the filterscript in which it detects a problem, but it's easy to understand in which filterscript it's occurred as after the warning you will see a message about the successful loading of that filterscript (before which the problem occurred).


Download
v1.1: MediaFire Pastebin


Warnings description
Below is an explanation and description of all the warnings that this script displays:

HTML Code:
One of your filterscripts doesn't have FILTERSCRIPT define
This warning occurs when one of your filterscripts doesn't have the "#define FILTERSCRIPT" code at the very beginning. Just add it and don't neglect it henceforth, because many includes change their behavior depending on whether they are included to a filterscript or gamemode.

HTML Code:
Your MAX_PLAYERS define isn't equal to the real number of player slots
This means that the value of the MAX_PLAYERS macro in one of your scripts doesn't match with the value of real player slots set in server.cfg. Discrepancy of these values can lead to "array index out of bounds" runtime errors with arrays that use MAX_PLAYERS as one of their dimensions.

HTML Code:
GetTickCount is less than 0. Please restart your computer
Occurs when your physical server (computer) runs continuously for several weeks, causing GetTickCount to overflow (takes negative values). In this case you just need to restart the computer (if turning off and then turning on doesn't help, then you need to exactly restart it).

HTML Code:
The SA-MP includes version doesn't match with the server version. Please update them
It means that the default SA-MP includes outdated in relation to the version of the server that is currently running. Just update your includes by downloading samp-server archive from the official site with the necessary version of the server and includes.

HTML Code:
Your scriptfiles folder isn't created or you don't have access to it (some scripts may not work correctly)
This occurs when you don't have the "scriptfiles" folder, which should be located in the folder with the server. It may also occur if you don't have access to it. In this case (in case of its absence) create it or (if it has already been created) contact the hosting technical support/configure access rights yourself. Some scripts save their data here and they cannot create this folder on their own.

HTML Code:
The variable 'maxnpc' exceeds the maximum number of player slots
This means that the value of the 'maxnpc' variable (the maximum number of NPC bots that can enter the server) in server.cfg exceeds the value of real player slots also set in server.cfg.

HTML Code:
The variable 'sleep' is less than the default value. Your timers may work less accurately
Occurs when the value of the 'sleep' variable in server.cfg is less than its default value (5). At lower values of this variable, timers created via SetTimer/SetTimerEx become less accurate being called with longer delays.

HTML Code:
Query is disabled. Your server will not be visible in masterlist
Indicates that the query variable in server.cfg is disabled. Query mechanism is responsible for sending the server name, the number of players on it and other data that the client sees in the server list before entering the game.


You can also suggest your ideas to add to this script. Perhaps there are still some frequent problems that you are already tired of encountering finding them manually each time? So share it.
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker

Last edited by OstGot; 08/11/2019 at 12:38 PM. Reason: v1.1
OstGot is offline   Reply With Quote
Old 16/07/2019, 12:04 PM   #2
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Added a more detailed description of the occurring warnings
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker
OstGot is offline   Reply With Quote
Old 16/07/2019, 12:51 PM   #3
NikitaFoxze
Little Clucker
 
NikitaFoxze's Avatar
 
Join Date: Mar 2018
Posts: 17
Reputation: 0
Thumbs up Re: SDiag - automatic diagnostics of frequent problems when the server starts

For newcomers the most times thank you!
NikitaFoxze is offline   Reply With Quote
Old 14/10/2019, 10:16 AM   #4
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Are there any other problems which automatic detection would be worth adding to this include? Any ideas.
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker
OstGot is offline   Reply With Quote
Old 19/10/2019, 09:44 AM   #5
MrAuto
Little Clucker
 
Join Date: Sep 2019
Posts: 8
Reputation: 2
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Quote:
GetTickCount is less than 0. Please restart your computer
This is normal behavior, it's nothing wrong with it
You only ever use GetTickCount to measure short amount of time preciously and the result is difference between two states of GetTickCount, so i doesn't matter if it's negative or positive.
The problem only occurs when overflow, but that something you need implement in the code itself

For Ideas, maybe check for some values in server.cfg, like 'announce' and 'query' to inform that server is not visible in server list etc.
maybe rcon password strength checker.

Also instead of making the same code twice for OnGameModeInit and OnFilterScriptInit i would make custom function for all the stuff that is the same no matter if it's gamemod or filterscript (just to make it more clear)
MrAuto is offline   Reply With Quote
Old 19/10/2019, 04:14 PM   #6
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Quote:
Originally Posted by MrAuto View Post
This is normal behavior, it's nothing wrong with it
You only ever use GetTickCount to measure short amount of time preciously and the result is difference between two states of GetTickCount, so i doesn't matter if it's negative or positive.
The problem only occurs when overflow, but that something you need implement in the code itself
I don't think it's normal behaviour as it breaks some scripts logic and as a result there are many problems when GetTickCount is less than zero due to overflow. I'm talking about the cases when you reset a variable with some previous tick in it and then you have the following code:
PHP Code:
if(GetTickCount() - previous_tick[playerid] < 1000//or smth similar
{
    
Kick(playerid);

So the original logic in this code is that when "previous_tick[playerid]" is resetting to 0 somewhere, then the check under "if" should return a value more than 1000 (GetTickCount() - 0 will be more than that almost always). And as you may have noticed, GetTickCount less than 0 will produce false condition applying.

And the main point why I added this check is not because there are some weird people who don't restart their server such a long period, no. As I found out after a complain on one of my scripts from people, some Windows desktops don't actually restart when you, for example, turn it off and then on (instead of restart option) or just set it to hibernate every now and again (what happens most often on laptops), so in these cases GetTickCount is also overflows after some weeks as it gets the uptime of the actual (physical) server.

Quote:
Originally Posted by MrAuto View Post
For Ideas, maybe check for some values in server.cfg, like 'announce' and 'query' to inform that server is not visible in server list etc.
maybe rcon password strength checker.

Also instead of making the same code twice for OnGameModeInit and OnFilterScriptInit i would make custom function for all the stuff that is the same no matter if it's gamemod or filterscript (just to make it more clear)
Thanks for the ideas. I also think it will be reasonable to put these warning messages into separate functions and call them instead, so that I don't have to change its text twice if I ever want to make some changes with it.
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker
OstGot is offline   Reply With Quote
Old 20/10/2019, 12:10 PM   #7
MrAuto
Little Clucker
 
Join Date: Sep 2019
Posts: 8
Reputation: 2
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Quote:
Originally Posted by OstGot View Post
I don't think it's normal behaviour as it breaks some scripts logic and as a result there are many problems when GetTickCount is less than zero due to overflow. I'm talking about the cases when you reset a variable with some previous tick in it and then you have the following code:
PHP Code:
if(GetTickCount() - previous_tick[playerid] < 1000//or smth similar
{
    
Kick(playerid);

So the original logic in this code is that when "previous_tick[playerid]" is resetting to 0 somewhere, then the check under "if" should return a value more than 1000 (GetTickCount() - 0 will be more than that almost always). And as you may have noticed, GetTickCount less than 0 will produce false condition applying.
This is not problem with GetTickCount but with not using it incorrectly, also why would you check for specific amount of ticks ? it's can't be used as metric of time
MrAuto is offline   Reply With Quote
Old 20/10/2019, 07:09 PM   #8
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Quote:
Originally Posted by MrAuto View Post
This is not problem with GetTickCount but with not using it incorrectly, also why would you check for specific amount of ticks ? it's can't be used as metric of time
I think you should get to know how this function works. It can be used (and it's commonly used) as metric of passed time if we talk about milliseconds. And the problem with overflow is not a problem of an incorrect script algorithm or incorrect use of this function in the script - this is a problem of long-term execution of the server when a variable with the number of milliseconds since the computer was started overflows the maximum int value.
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker
OstGot is offline   Reply With Quote
Old 08/11/2019, 12:37 PM   #9
OstGot
Gangsta
 
OstGot's Avatar
 
Join Date: Mar 2013
Location: Gomel, Belarus
Posts: 865
Reputation: 325
Default Re: SDiag - automatic diagnostics of frequent problems when the server starts

Updated to v1.1:
* Added check for invalid maxnpc value in server.cfg when it exceeds the maximum player slots number
* Added check for low sleep values in server.cfg, which can highly affect the accuracy of timers
* Added check for disabled query in server.cfg, which makes the server invisible for SA-MP launcher
__________________
aka Nexius
Don't want to always check for updates of my scripts?
Include it the last, after all others
Nexius's Update Checker
OstGot is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequent crashes in just one server. Possible fix? MafiaOink Client Support 2 03/08/2018 10:18 AM
Gamemode starts "hanging", ackslimit problems? faxxe Scripting Help 2 24/02/2017 05:10 PM
Server causes frequent client crashes (mostly 0x6BD) denNorske Scripting Help 2 17/12/2016 10:55 PM
Automatic Gate Code Problems AK47317 Help Archive 7 06/11/2010 12:14 PM
When 0.3 starts, i had problems with my script. [FBI]Gstar Help Archive 2 18/11/2009 09:58 PM


All times are GMT. The time now is 12:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.