A script that checks to see if the install of Gmod is legal

I wanted to include a script for a map I’m working on that would only allow it to run on legal copies of Gmod.

Basically, the idea I had was that it would first check to see if common ‘crack’ files used by Steam emulators were present in the Gmod directory itself, and any of the directories for games that Gmod is currently mounting. If it found any of these, map closes.

Then it would check to see where the process is currently running from. There’s a registry value that shows where steam.dll was last loaded from, and if the script finds that it is anything other than where it usually is run from ( X:\Program Files\Steam\ usually), then the map closes.

Unfortunately, I’m not an Lua coder, so I wouldn’t even know where to begin writing this.

I know someone is going to ask ‘Why bother?’, and my reasoning is that even though only legal players should be able to download this in the first place since I’ll be uploading it to garrysmod and only garrysmod, but I wanted to have this script in place for when people reupload it outside of garrysmod without my permission, probably for non-legal players.

Lua doesent work outside of Gmod, so you wont be able to detect that. Maybe with a module though.

Have a read of YouStream. I added antipiracy to it.

[editline]10:28PM[/editline]

It’s basic and shit, but works to a degree.

Yes you can, there’s an entity in Gmod’s FGD that allows scripts to be autorun on map start.

Although the model would be nice for some sort of ‘map can’t run without (scriptnamehere)’ trap so people can’t just remove the entity.

I stand corrected.

Maybe have it start a short timer on load, which the script then stops and if it isn’t stopped it will do horrible things?:3:

This seems really unorthodox, but if you must do this, I would do something like what ralle was saying, and remove the world entity as a consequence.

What? Since that entity is only defined in Garry’s Mod and it’s code is scripted in lua I really doubt it will work in any other game. So if you want to do a protection like that it will have to be for Garry’s Mod.

Now assuming you got such a lua script working there is nothing that can stop someone from disabling your script if they know which method you used.

If you distribute it with an external lua file people can simply delete it.
If you put your script in a lua_run’s entity’s keyvalyes the entity can be deleted, or more simply overwritten by the server running your map. Keep in mind that lua_run is nothing more then a scripted entity defined in the server’s lua state.

Of course I might be wrong and I’d be delighted to hear how so.

Pretty much.

Oh hi again, Mr. Quebec. :smile:

Except there really isn’t a way for a map to do something like this. It would have to be through Lua if I wanted it to check for the files that shouldn’t be there.

[editline]06:35PM[/editline]

Yeah, I know that. I thought about hiding multiple copies of the entity with ambiguous names or tying them to vital map systems (or just having the world get deleted if it can’t find the entity that runs the script).

Garry would have to add this sort of protection into Gmod itself, as it’s really the only way to really have this be uncircumventable.

If you’re worrying more about only allowing players with legal copies to play your map, you probably don’t have a map worth putting forth the effort to pull this off in the first place.

[editline]08:06PM[/editline]

Let me just add that circumvention for something like this is probably around 6 lines of code, so don’t bother. 3 of which would just be defining the function to eliminate your code.

If Garry had a reliable way to determine if a copy of Gmod was legit, I’m sure he’d be using it to disable those pirated copies.

^ that is the only answer you need.

If anyone could do it, everyone could and would be doing it by now.

The validating is on valve/steam side anyway!

He could actually Validate the files and then Validate to see if the CD-KEY matches the cd-keys that are real and not cracked if its cracked then the gmod will won’t open.

Nah, pirating doesn’t work this way. GMod also doesn’t use CD-keys, and Steam already does what you’re talking about, too.

And how would you know?

Because games are tied to your Steam account. Not CD-keys. If you have a brother or a sister who has a different account, and they try to play your game, they won’t be able to unless that account has it, too.

[editline]10:20PM[/editline]

:raise:

Pretty sure they still have some kind of cd key

No. However you can use keys which are generated specifically for store/development/promotional which assign a game to your account.

The only version of GMod that has had a CD key was the beta.