[Include] SA:MP IsUp Tool - API
#6

Quote:
Originally Posted by Abagail
Посмотреть сообщение
I prefixed most; I remember you giving me this tip on one of my last includes I've done. And how would you suggest hooking ServerInformation_Response? Thanks!
Just by hooking them like any other callbacks, but you might need an additional array to store the searched server name.

pawn Код:
forward ServerInformation_Response(index, response_code, data[]);
public ServerInformation_Response(index, response_code, data[])
{
    if(response_code == 200)
    {
        if(strcmp(data, "Online", true) == 0)
        {
            ServerData[index][s_iOnline] = true;
            return true;
        }
        else
        {
            ServerData[index][s_iOnline] = false;
        }
        printf("%s", data);
    }
    else printf("Unable to load server data(response code returned %d)", response_code);
    #if defined iUServerInformation_Response
        return iUServerInformation_Response(index, response_code, data);
    #else
        return 1;
    #endif
}

#if defined _ALS_ServerInformation_Response
    #undef ServerInformation_Response
#else
    #define _ALS_ServerInformation_Response
#endif

#define ServerInformation_Response iUServerInformation_Response

#if defined iUServerInformation_Response
forward iUServerInformation_Response(index, response_code, data[]);
#endif

//So then, once if the data is received, they can check like:
public ServerInformation_Response(index, response_code, data[])
{
    if(IsServerOnline(index))
    {
        print("It's online!");
    }
    else
        print("It's not!");
    }
    return 1;
}
Or else another tip is that you can use CallLocalFunction as soon as the data is received, with additional parameters to check if the data is received or not. Mostly like the way zcmd handles.
Reply


Messages In This Thread
SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 16:20
Re: SA:MP IsUp Tool - API - by Kaperstone - 04.01.2015, 16:24
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 16:26
Re: SA:MP IsUp Tool - API - by Lordzy - 04.01.2015, 16:36
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 16:46
Re: SA:MP IsUp Tool - API - by Lordzy - 04.01.2015, 16:54
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 17:16
Re: SA:MP IsUp Tool - API - by Djole1337 - 04.01.2015, 17:20
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 17:22
Re: SA:MP IsUp Tool - API - by Djole1337 - 04.01.2015, 17:25
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 17:28
Re: SA:MP IsUp Tool - API - by Djole1337 - 04.01.2015, 17:35
Re: SA:MP IsUp Tool - API - by Abagail - 04.01.2015, 17:41
Re: SA:MP IsUp Tool - API - by Abagail - 05.01.2015, 23:47
Re: SA:MP IsUp Tool - API - by ViperAssasin11 - 06.01.2015, 00:35
Re: SA:MP IsUp Tool - API - by Abagail - 06.01.2015, 00:47
Re: SA:MP IsUp Tool - API - by Ryan_Bowe - 07.01.2015, 17:03
Re: SA:MP IsUp Tool - API - by Abagail - 07.01.2015, 17:14
Re: SA:MP IsUp Tool - API - by nickdodd25 - 07.01.2015, 17:53
Re: SA:MP IsUp Tool - API - by Abagail - 07.01.2015, 17:56

Forum Jump:


Users browsing this thread: 1 Guest(s)