[Plugin] Isup plug-in
#1

Hello lads,

I figured it'd be better to introduce this system as a plug-in. Having it as an include relies on an API, and also is reliant on a web server to run whereas a plug-in can directly load the information.

Additionally, it will get the data from the server network itself so things such as ping, etc can be obtained from the local machine, and not the isup system.

Before I say anything else, I'd like to state that this uses a modified version of Cody Cumming's(by3t) C++ SA-MP query implementation mechanism. You can find that here:
https://sampforum.blast.hk/showthread.php?tid=437309

The include version can be found here: https://sampforum.blast.hk/showthread.php?tid=554654.

As of now there is simply one function:(EDIT: This is no longer the case.)

pawn Code:
native IsServerOnline(IP[], port=7777);
native set_ping_timeout(timeout);
native get_ping_timeout();
This function returns the ping(or 0 if unable to establish a connection) of the server.

I do plan on adding more natives allowing the user to get extra data such as playercount, connected player names(assuming it is less than 100 players), server version and more.

Example:
pawn Code:
#include <a_samp>
#include <isup>

public OnFilterScriptInit()
{
    new var;
    var = IsServerOnline("192.99.246.196", 7777);
   
    if(var)
    {
        printf("192.99.246.196:7777 is online.");
    }
   
    else
    {
        printf("192.99.246.196:7777 is offline.");
    }
   
    return true;
}
Bugs:

The only bug I found while testing is that if you use a hostname, the server will get an exception and crash. The fix for this is to just use the numeric IP address until the issue has been resolved.

UPDATE: This seems to be actually caused when an invalid IP addressed is passed. A IP validation check will be added in future versions, but for now be careful of the IP's you allow / place in the function.


This issue has been fixed - hostnames now should work properly. Additionally, invalid IP addresses / masks should no longer crash or hang the server.


Possible Uses:
This can be useful if you are a multi-server gaming community and you want to show users information / status of another one of the community's SA-MP servers.

Compilation Notes:
I have only built a binary for windows. You'll have to compile linux for yourself.

The download can be found here on github:
View on github(Click me)

(The github repository contains the source)

You can find a tutorial / documentary here. Additionally, all changes / downloads will be hosted on GitHub.

P.S: I have made a seperate repo that fixes Cody Cumming's original query a bit like this plugin does(allowing the use of hostnames while not crashing invalid IP addresses) which can be found here:
https://github.com/Abagail/sampquerycpp
Reply
#2

best plugin ever
Reply
#3

Quote:
Originally Posted by ConnorHunter
View Post
best plugin ever
Thank you for the feedback!
Reply
#4

Quote:
Originally Posted by Abagail
View Post
Hello lads,


The only bug I found while testing is that if you use a hostname, the server will get an exception and crash. The fix for this is to just use the numeric IP address until the issue has been resolved.

UPDATE: This seems to be actually caused when an invalid IP addressed is passed. A IP validation check will be added in future versions, but for now be careful of the IP's you allow / place in the function.
It crashes due to 'query.cpp'. When creating socket, 'inet_addr' used to convert ip_adress into host_adress. But you can use it with 'IPV4' (0.0.0.0). To get host adress from hostname, you have to use getaddrinfo
Reply
#5

Quote:
Originally Posted by Rancho
View Post
It crashes due to 'query.cpp'. When creating socket, 'inet_addr' used to convert ip_adress into host_adress. But you can use it with 'IPV4' (0.0.0.0). To get host adress from hostname, you have to use getaddrinfo
Thank you for the information, I will look into it.

OFF-TOPIC: Cheers for 2k posts!
Reply
#6

Quote:
Originally Posted by Abagail
View Post
Thank you for the information, I will look into it.

OFF-TOPIC: Cheers for 2k posts!
I looked plugin before try to fixing it. It says online for every ip even "1.0.0.0:7777"
Reply
#7

Yeah, I screwed something up while looking to solve the crash, and fix an issue where some servers didn't ping when they should be. I didn't know I had updated it as a commit.

I have fixed the issue, it should be working fine now.(Though the crash, and ping issue remain)
Reply
#8

The hostname crash has been fixed(you should be able to use hostnames directly now) thanks to Rancho. The updated source & binaries can be found on github.
Reply
#9

Hey abagail good plugin bro, nice work!
Reply
#10

Quote:
Originally Posted by BlueX
View Post
Hey abagail good plugin bro, nice work!
Thank you!
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)