Member
|
03-24-2013
, 02:33
Re: Server Query
|
#22
|
Quote:
Originally Posted by Scherzo
Server Queries
Library to asynchronous request fetching information about other server of HL game. Server queries - Valve Developer Community
Available requests:
Info. Server name, map name, current number of players, max number of players, name of game.
Code:
stock ServerInfo(const szServer[], const szCallback[]);
Code:
new const SERVER_ADDRESS[] = "192.168.0.14:27015";
public info()
{
ServerInfo(SERVER_ADDRESS, "cbInfo");
return PLUGIN_HANDLED;
}
public cbInfo(const szServer[], _A2A_TYPE, const Response[], len, success, latency)
{
if(!success)
return;
new szName[64], szMap[64], szDirectory[64], szDescription[64];
new iPlayers = 0;
new iMaxPlayers = 0;
ServerResponseParseInfo(Response, szName, 63, szMap, 63, szDirectory, 63, szDescription, 63, iPlayers, iMaxPlayers);
client_print(0, print_chat, "Server name: %s", szName);
client_print(0, print_chat, "Map: %s", szMap);
client_print(0, print_chat, "Folder: %s", szDirectory);
client_print(0, print_chat, "Description: %s", szDescription);
client_print(0, print_chat, "Players: %d / %d", iPlayers, iMaxPlayers);
}
CODE]
|
Hi, I'm getting errors when I put the code together
L 03/20/2013 - 20 9:12: [AMXX] Run time error 5: memory access
L 03/20/2013 - 20 9:12: [AMXX] [0] server_query.inc::ServerResponseReadByte (line 230)
L 03/20/2013 - 20 9:12: [AMXX] [1] server_query.inc::ServerResponseParseInfo (line 119)
L 03/20/2013 - 20 9:12: [AMXX] [2] serversinfo.sma::cbInfo (line 48 )
Does anyone know what's the reason for this?
My plugin compiles all the time, but doesn't work correctly
Last edited by chungsy; 03-24-2013 at 02:42.
|
|