Game Version command

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Game Version command

Post by Grassy »

G'day, I've been looking all over the place trying to find a command to determine what game is running from the script.
For eg, many maps and mods can be compatable for AA SH & BT, only some small changes are needed to keep all versions happy.
In the scripts can be a game check at the top, something like;

level.gamever = ????? //mystery command to check it
if (level.gamever == "Allied Assault")
{
do all your scriptmaster stuff for sounds etc etc..
}
//Scriptmaster stuff skipped if not Allied Assault
//continue with rest of the script

I remember seeing something like this done in a mod a few years back, but I can't find it now. It was supposed to be compatable with all three game versions.
Grassy
An ambiguous question will get a similar answer...
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

level.gamever = getcvar version

The version string this gives you is a rather long one though... however I think you could also do:

level.gamever = getcvar shortversion

Which would just give you '1.11' or so.
Image
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Thanks JV, this is what I get.
** Spearhead **
"version" is:"Medal of Honor Spearhead 2.15 win-x86 Mar 4 2003" default:"Medal of Honor Spearhead 2.15 win-x86 Mar 4 2003"
"shortversion" is:"2.15" default:"2.15"


** Allied Assault **
"version" is:"Medal of Honor Allied Assault 1.11 win-x86 Mar 5 2002" default:"Medal of Honor Allied Assault 1.11 win-x86 Mar 5 2002"
"shortversion" is:"1.11" default:"1.11"


** Breakthrough **
"version" is:"Medal of Honor: Breakthrough 0.00 win-x86 Dec 1 2003" default:"Medal of Honor: Breakthrough 0.00 win-x86 Dec 1 2003"
"shortversion" is:"2.40" default:"2.40"
So..... would this method work?

Code: Select all

level.gamever = int( getcvar ( shortversion ))
if (level.gamever !=NIL)
{
   if(level.gamever==2.15)
   {
     level.gamename = "Spearhead" //dont need names, but names are easier to remember down the script ;-)
   }
   if(level.gamever==1.11)
   {
     level.gamename = "AlliedAssault"
     thread do_sound_aliases
   }
   if(level.gamever==2.40)
   {
     level.gamename = "Breakthrough"
   }
   else
   {
     println "** It seems your game version is not up to date **"
     println "** There are patches available that you need to install **"
    }
}
Grassy
An ambiguous question will get a similar answer...
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

i use this:

Code: Select all


getgame:
	local.game = getcvar "version"
	local.i=15

	if(local.game[local.i]==" ")
	{
		local.i= 17
	}
	
	local.gamestates = waitexec game.camperfile::statefiles

	for(local.g=1;local.g <= local.gamestates.size;local.g++)
	{
		if(local.game[local.i]==local.gamestates[local.g][1])
		{			
			local.state = local.gamestates[local.g] [2]
			break
		}
	}

	switch(local.game[local.i])
	{
	case "A":
		setcvar "g_statefile" local.state
		local.campersettings =  waitexec game.camperfile::weaponsaa
		game.game = "AA"
		end local.campersettings
	break 
	case "S":
		setcvar "g_statefile" local.state
		game.game = "SH"
		local.campersettings =  waitexec game.camperfile::weaponssh
		end local.campersettings		
	break
	case "B":
		setcvar "g_statefile" local.state
		game.game = "BT"
		local.campersettings =  waitexec game.camperfile::weaponsbt
		end local.campersettings
	break
	}
	

end local.cmdwant 
just clean up the stuff u dont need.

game.game is what i use in other scripts to run parts for the game. its from anti camper.

I dont check the whole string or the patch num cos they mightve diff for some people. more then one version was released of mohaa at diff dates etc;). However the title, That shouldnt of changed. no one has said it dont work to me so far and in testing it works.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Elgan, erm, looks impressive :? but I dont follow.
getgame:
local.game = getcvar "version"
local.i=15

if(local.game[local.i]==" ")
{
local.i= 17
}
What is the reason for setting local.i to = 15 and it's a NUL then make it 17 ??
Grassy
An ambiguous question will get a similar answer...
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

I just tried a shorter more simpler way, seems to work ok.

Code: Select all

//---------------------------------------------------------------------------
// Method to determine what game the player is using
//---------------------------------------------------------------------------
level.gamever = int( getcvar ( shortversion )) 
waitframe
   if(level.gamever > 1) 
   { 
     level.gamename = "Spearhead or Breakthrough"
   } 
   if(level.gamever < 2) 
   { 
     level.gamename = "AlliedAssault"
     waitthread Do_AA_sound_aliases
     thread Start_sound_loops
   } 

println "------------------------/zz/-------------------------"
println "Game Version : " level.gamever
println "Game type     : " level.gamename
println "------------------------/zz/-------------------------"
Returns in logfiles
//returns this in Spearhead
//------------------------/zz/-------------------------
//Game Version : 2
//Game type : Spearhead or Breakthrough
//------------------------/zz/-------------------------

//returns this in AlliedAssault
//------------------------/zz/-------------------------
//Game Version : 1
//Game type : AlliedAssault
//------------------------/zz/-------------------------
An ambiguous question will get a similar answer...
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

nice idea, but SH or bt. i needed all 3 , anyway

the reason i check for null is because in these 3 sentances. the A and S of allied and spearhead are at place 15. on breakthrough 15 is " ". The b of breakthrough comes in at 17.



medal of honor allied assault
medal of honor spearhead
medal of honor: breakthrough
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Elgan, 'roger that' understand now. Thanks mate :)
Grassy
An ambiguous question will get a similar answer...
Post Reply