Is it possible to grab stats of other servers (i.e. Players, map, name, gamemode) with lua?
The local server or any other server?
Other servers. Like I said.
EDIT: Actually both.
stats as in player count?
[QUOTE=Vl4dmir;33234812]Is it possible to grab stats of other servers [B](i.e. Players, map, name, gamemode)[/B] with lua?[/QUOTE]
[QUOTE=Vl4dmir;33235527][/QUOTE]
I'm a such of fast reader, You could always use MYSQL to save it every minute and then load it on the other server.
I guess I'll end up doing that. How would I get the number of players from the local server?
Yeah I would like to know how to do this as well!
I'm glad I'm not the only one.
#player.GetAll();
Does anyone know how Gametracker/HLSW pulls server information, and how to replicate in html or lua?
[QUOTE=Chessnut;33240762]#player.GetAll();[/QUOTE]
Did you even read?
-snip-
This thread is full of stupid. You can't get information from other servers, without the server networking it's information to you. If you want your own servers player count you can do this.
[lua]
local function PlayerCount()
return #player.GetAll();
end
[/lua]
[QUOTE=Stonna;33245305]This thread is full of stupid. You can't get information from other servers, without the server networking it's information to you. If you want your own servers player count you can do this.
[lua]
local function PlayerCount()
return #player.GetAll();
end
[/lua][/QUOTE]
Yeah you can
[url]http://www.facepunch.com/threads/1136961[/url]
+
[url]http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol[/url]
Thank you Disseminate, your post was most helpful.
[QUOTE=Disseminate;33245316]Yeah you can
[url]http://www.facepunch.com/threads/1136961[/url]
+
[url]http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol[/url][/QUOTE] I think what he was saying is that you can't do it without a special module.
Yup, standard lua this isn't possible.
[QUOTE=Disseminate;33245316]Yeah you can
[url]http://www.facepunch.com/threads/1136961[/url]
+
[url]http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol[/url][/QUOTE]
I have no idea what to do with this (new to lua), but I'm probably going to use MySQL to pass the stats. The main reason i needed it is to show the server stats on my main server, but also to kill those servers after a set amount of time of having no players. This is what I have so far, but it does nothing. And it'll probably show how new to lua I am >.<
[CODE]
function PlayerCheck()
local Var = RealTime()+10
if #player.GetAll() != 0
then Var = RealTime()+10
elseif Var < RealTime() and #player.GetAll() == 0
then game.ConsoleCommand("quit")
end
end
hook.Add("Think", "PlayerCheck", PlayerCheck)
[/CODE] Can someone help me with this? Also, is there a way to kill the server without having it restart?
EDIT: Just read over the wiki page and noticed that it only runs at first start or when players are on. Is there an alternative to GM:think()? or should I just use timers?
EDIT2: Also just noticed that timers only run when players are on the server...
[lua]
local function PlayerCheck()
local delay=10
timer.Simple(5,function()
if #player.GetHumans()==0 then
if #player.GetBots()==0 then
game.ConsoleCommand("bot\n")
end
timer.Create("KillServer",delay,1,function()
game.ConsoleCommand("quit\n")
end)
hook.Add("PlayerInitialSpawn","CancelKillServer",function(ply)
if !ply:IsBot() then
timer.Destroy("KillServer")
for k,v in pairs(player.GetBots()) do
v:Kick("")
end
end
end)
end
end)
end
hook.Add("PlayerDisconnected","ServerEmpty",PlayerCheck)
[/lua]
You'll have to disable your server watchdog to keep it from restarting.
How would I disable the watchdog? I'm running srcds_run directly from console, no bash script or anything. The server is linux btw.
Your script makes the bot when there are no players, kicks the bot when a player joins, and all that fine, but still doesnt quit the server.
Sorry, you need to Log In to post a reply to this thread.