SA-MP Forums Archive
Anti Steal System Include - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Steal System Include (/showthread.php?tid=342007)



Anti Steal System Include - richardcor91 - 12.05.2012

Guys, I'm about to release a simple include that makes stolen filterscripts/gamemodes crash server if they are not running in your host ip and port. Of course it will only work if in your server.cfg you had:

Код:
bind 127.0.0.1 //your server ip
port 7777 //your server port - as usual
It goes like this:

Код:
#if defined _Anti_Steal_included
  #endinput
#endif
#define _Anti_Steal_included

#include <a_samp>
#include <YSI\y_hooks> //by ******: https://sampforum.blast.hk/showthread.php?tid=166016

#define IP_PORT "127.0.0.1:7777" //change this to your server host ip and port before compile your scripts with this include.

stock AntiSteal()
{
   	new SIp[32], SPort;
    GetServerVarAsString("bind", SIp, sizeof(SIp));
    SPort = GetServerVarAsInt("port");
	format(SIp, sizeof(SIp), "%s:%d", SIp, SPort);
	if(strcmp(SIp, IP_PORT, false))
	{
		print("This script was stolen. Crashing server now...");
		SetTimerEx("Bla", 1, false, "s", ""); //function to crash server
	}
    return 1;
}
My doubt:
I want to run the function OnGameModeInit if the script is a gamemode or OnFilterScriptInit if it is a filterscript. Is it possible to identify if script is a gamemode or filterscript without changing nothing in it? Anyway, that's why I'm hooking both:

Код:
hook OnGameModeInit()
{
	AntiSteal();
	return 1;
}

hook OnFilterScriptInit()
{
	AntiSteal();
	return 1;
}
Thanks!


Re: Anti Steal System Include - SuperViper - 12.05.2012

I recommend checking if 'FILTERSCRIPT' is defined.


Re: Anti Steal System Include - richardcor91 - 12.05.2012

I also thought about it. But that way, "#define FILTERSCRIPT" code is needed in each filterscript.
Anyway, is there any problem about hooking both functions?