-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ps1
98 lines (76 loc) · 3.06 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#Location of Arma 3 server exe
$CMD= ''
#Directory of server profile data
$profileDir=''
#Parameters for the server
#All parameters can be found here
#https://community.bistudio.com/wiki/Arma_3_Startup_Parameters
$args=''
#Change mod directory to Workshop folder
$modDir=''
#Add mods from Worksop folder to the server startup
$modsArray = @(
''
)
#Add mods from Worksop folder to the server startup
#$modDir='C:\Program Files (x86)\Steam\steamapps\common\Arma 3\!Workshop\'
$serverModArray = @(
''
)
#You don't have to edit beyond this point
#Details on this folder can be found here:
#https://community.bistudio.com/wiki/server.cfg
$serverCfg='"-config=' + $profileDir + '\config\server.cfg"'
#Details on this folder can be found here:
#https://community.bistudio.com/wiki/basic.cfg
$basicCfg='"-cfg=' + $profileDir + '\config\basic.cfg"'
#Setting the directory of server profile data.
#This is the directory that contains all the server logs
$profiles='"-profiles=' + $profileDir + '"'
$args+=$profiles + ' ' + $serverCfg+ ' ' + $basicCfg
#Detection if all required directories exist
if (($CMD -eq '') -or ($profileDir -eq '') -or ($modDir -eq '')){
Read-Host "Looks like some variables have been left empty. Press enter to close the program"
Exit
}
if (-not (Test-Path $CMD -PathType leaf)){
Read-Host "Looks like the location of the arma 3 exe was not found. Press enter to close the program"
Exit
}
if (-not (Test-Path $profileDir -PathType container)){
Read-Host "Looks like the profileDir value you entered isn't a folder. Press enter to close the program"
Exit
}
if (-not (Test-Path $modDir -PathType container)){
Read-Host "Looks like the modDir value you entered isn't a folder. Press enter to close the program"
Exit
}
if (-not (Test-Path ($profileDir + '\config') -PathType container)){
Read-Host "Looks like the profile directory value you entered doesn't have a config folder. Press enter to close the program"
Exit
}
#Sets the location of the parameter file
$paramFile=$profileDir+'\config\parameters.par'
#Combines and formats all the mods to be parsed into the parameter file
$paramFileArgs= 'class Arg {'
if (($modsArray.length -gt 0) -and ($modsArray[0].length -gt 0)){
$mods='-mod=curator;kart;heli;mark;expansion;jets;argo;orange;tacops;tank;enoch;aow;'
for($i = 0; $i -lt $modsArray.length; $i++){
$mods += $modDir + '\' + $modsArray[$i] + ';'
}
$paramFileArgs+= 'mods="' + $mods + '";'
}
if (($serverModArray.length -gt 0) -and ($serverModArray[0].length -gt 0)){
$serMods= '-serverMod='
for($i = 0; $i -lt $serverModArray.length; $i++){
$serMods+= $modDir + '\' + $serverModArray[$i] + ';'
}
$paramFileArgs+= 'serverMods="' + $serMods + '";'
}
$paramFileArgs+= '};'
#parses mods into parameter file
Set-Content -Path $paramFile -Value $paramFileArgs
$args += ' -par=' + $paramFile
$server = Start-Process -FilePath $CMD -ArgumentList $args -passthru
#Set Processor Affinity
#$server.ProcessorAffinity=3840