DayZ Server Tracker

Post gaming related scripts
User avatar
jigga
Posts: 93
Joined: 24 Jan 2014, 00:31

DayZ Server Tracker

12 Feb 2014, 20:36

The standalone version of DayZ is of course in alpha and does not remember the servers you have been on. I wrote a simple utility to track the servers you have been on.

I have not done much testing, so let me know if there are issues. I plan on releasing it to reddit, hence the billygrippo references and Legalese :) I apologize for any redundant or crappy code in advance :P

Code: Select all

/*
DayZ Server Tracker, written by /u/billygrippo
copyright © 2014 Joel Fazio

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

To obtain a copy of the GNU General Public License,
see http://www.gnu.org/licenses/.
*/



#NoEnv
#SingleInstance Force
#NoTrayIcon
#Persistent

;add gui
Gui, Add, Text, x110 y10 w280 h50 , Press Ctrl + M to force update. Double click a server to copy the IP and port to your clipboard. Message /u/billygrippo for help or suggestions.
Gui, Add, Button, x156 y397 w140 h40 gSetTimerButton, Set Timer
Gui, Add, ListView, x6 y77 r120 w680 h310 gMyListView vMyListViewVar, Name|IP|Time Stamp
Gui, Add, Text, x156 y447 w280 h30 vTimerText, Timer = 10 mins
;Gui, +hwndguihwnd +ToolWindow -MinimizeBox -MaximizeBox
Gui, Show, w700 h496, DayZ Server Tracker - By /u/billygrippo

;initialize stuff imo
SetWorkingDir, %A_MyDocuments%\DayZ\
setTimer, checkTimer, 600000

IfExist, Server Tracker.txt
{
	linesIndex = 0
	Loop, read, Server Tracker.txt
		{
			linesIndex++
			lastLine := A_LoopReadLine
		}
	;if file exists populate gui
	setGuiList(linesIndex)	
}
else
{
	FileAppend, , Server Tracker.txt	
}
return

GuiClose:
ExitApp

;label to handle double clicking the servers listview
MyListView:
Gui, ListView, MyListViewVar
if (A_GuiEvent = "DoubleClick"){
	LV_GetText(ip, A_EventInfo,2)
	Clipboard := ip
return
}
return

;timer, duh
checkTimer:
checkFile()
return

;hot key. change to whatever. use ~ to fire despite other modifiers, ie shift or something
~^m::
checkFile()
return

;handle changing the timer amount
SetTimerButton:
InputBox, newTime, Change Timer, Enter the desired timer in minutes. Enter 0 to disable the timer.
	if (ErrorLevel){
		return	
	}
	newTime = %newTime%
		if (RegExMatch(newTime, "\D")){
			MsgBox, Please enter a valid integer, you stupid jerkstore.
			goto, SetTimerButton
		}
		if (newTime = 0){
			SetTimer, checkTimer, off
			return
		}
	GuiControl, , TimerText, Timer = %newTime% Minutes
	newTime := newTime * 60000
	SetTimer, checkTimer, %newTime%
return


;check the dayz cfg file for last server, ignore if it has not changed since last check
checkFile()
{
	FileRead, serverName, %A_UserName%.DayZProfile
	{
		loop, parse, serverName, `n
		{

				if (instr(A_LoopField, "lastMPServerName")){
					len := StrLen(A_loopField) - 21
					serverList := SubStr(A_LoopField, 19, len)
				}
				if (instr(A_LoopField, "lastMPServer=")){
					len := StrLen(A_loopField) - 17
					iPList := SubStr(A_LoopField, 15, len)
				}
		}
		linesIndex = 0
		Loop, read, Server Tracker.txt
		{
			linesIndex++
			lastLine := A_LoopReadLine
		}
		if (serverList = ""){
			return	
		}
		if (InStr(lastLine, iPList)){
			return
		}
		FormatTime, theTime, R
		lastServer := serverList . "|" . iPList . "|" . theTime
		FileAppend, %lastServer%`n, Server Tracker.txt
		sleep, 200
		linesIndex++
		setGuiList(linesIndex)
		
	}
return
}

;populate the gui with the server list
setGuiList(lines){
	savedServers :=
	FileRead, savedServers, Server Tracker.txt
	Gui, ListView, MyListViewVar
	LV_Delete()
	FileRead, savedServers, Server Tracker.txt
	Loop, parse, savedServers, `n
	{
		
		Gui, ListView, MyListViewVar
		StringSplit, listArray, A_loopField, |
		LV_Add("", listArray1, listArray2, listArray3)
		if (A_Index = lines){
			break	
		}
	}
	LV_ModifyCol()
	
return	
}

Return to “Gaming Scripts (v1)”

Who is online

Users browsing this forum: No registered users and 17 guests