Jump to content
  • 0

How to check game guardian version in script?


Question

Posted

I need a script to automatically check the version of the Game Guardian, and if the version does not match the specified one, then the script exits. How can this be implemented? 

10 answers to this question

Recommended Posts

  • 1
Posted (edited)

you can try this

if gg.VERSION < "101.1" then 
gg.alert("Please use the latest version of GameGuardian.")
os.exit()
end

or this.

if gg.VERSION == "101.1" then
else
gg.alert('Please use GameGuardian version 101.1')
os.exit()
end

 

Edited by MonkeySAN
maybe its the 2nd one..
  • 1
Posted (edited)

gg api provide you 3 class member that can help you to identify a specific version of gg
 

print("GG build number: "..gg.BUILD)
print("GG string version: "..gg.VERSION)
print("GG numeric version: "..gg.VERSION_INT)

See the class reference for more info.

you can even do further test using package name lock, but we can not talk about it here, dm me if you want

Edited by MAARS
  • 1
Posted

There is built-in way to ensure that version is not older than specified one, by using "gg.require" function. For example: 

gg.require("101.1")

One other important note is NOT to compare version strings using operators ">" and "<" like it's done in some answers in this topic, because it won't work as expected in all cases. The condition "99.0" > "101.0" evaluates to true, but version 99.0 is not greater than 101.0. That's why to compare versions using by "greater than" or "less than" conditions "gg.VERSION_INT" constant that MAARS has mentioned in his answer should be used instead.

  • 0
Posted

Hi! There's many Implementation to do this:
Check Specific: You might want to use this ("If the version does not match the specified one, then the script exits.")

Specified_Version = "101.1"
if not (Specified_Version == gg.VERSION ) then 
	print("Please use GG Version:" .. Specified_Version)
	os.exit()
else
	do_function()
end
	

Specific Range: It will check if GG Version is in between 95 and 100.

if (gg.VERSION < "95.0") and (gg.VERSION > "100.0") then
	do_function()
else
	print("Only Supports GG Version 97,98,99,100")
	os.exit()
end

More Specific: This time We can use a List instead of (AND, OR, NOT).

function check()
	versionList = {95.0, 80.0, 71.0}
	versionCurrent = tonumber(gg.VERSION)
	for i, j in pairs(versionList) do
		if j == versionCurrent then
			return true
		end
	end
	return false
end

if check() then
	print('Compatible!')
else
	print('Not Compatible!')
end
  • 0
Posted
52 minutes ago, CmP said:

That's why to compare versions using by "greater than" or "less than" conditions "gg.VERSION_INT" constant that MAARS has mentioned in his answer should be used instead

so this way is much better for "greater than", "less than" or "equal" ?

if gg.VERSION_INT == 10101 then
else
  os.exit()
end

 

  • 0
Posted
Just now, MonkeySAN said:

so this way is much better for "greater than", "less than" or "equal" ?

For "equal" it doesn't matter much, since comparison of strings will work as well. For "greater than" and "less than" it is correct solution and string comparison is not. String comparison works by comparing strings character-by-character in alphabetical order, so it's not applicable for comparing strings that represent versions.

  • 0
Posted (edited)
1 hour ago, MonkeySAN said:

so this way is much better for "greater than", "less than" or "equal" ?

For me the gg.require function proposed by cmp is the best go for this, it require less code

Edited by MAARS
  • 0
Posted
5 hours ago, CmP said:

For "equal" it doesn't matter much, since comparison of strings will work as well. For "greater than" and "less than" it is correct solution and string comparison is not. String comparison works by comparing strings character-by-character in alphabetical order, so it's not applicable for comparing strings that represent versions.

This is exactly my initial Thought. I find it weird that You can compare Number via String on Lua. Usually it use Int or Floats, thanks for the clarity.

  • 0
Posted
4 minutes ago, MainC said:

I find it weird that You can compare Number via String on Lua.

String contents doesn't matter. If two strings are compared, they are compared accordingly. It's a simple system. It gets more complicated (and confusing) when variety of implicit conversions may be involved, like for example in JavaScript.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.