[FilterScript] [FS] Anti-Modshop Jack
#1

This is an effective way to prevent people from being jacked when they are modding their cars. Basically it changes the player's virtual world to something unique so that the cars won't be visible at the modshop gate or inside. Car locks are bugged that's why I did it this way.

It uses the virtual worlds 56-255 (every player gets one based on their id).

http://slice.pastebay.org/19382

Код:
#include <a_samp>

#define DEBUG false

bool:IsPlayerInSphere( playerid, Float:r, Float:x, Float:y, Float:z )
{
	new Float:xx, Float:yy, Float:zz;
	
	GetPlayerPos( playerid, xx, yy, zz );
	
	xx -= x;
	yy -= y;
	zz -= z;
	
	return ( ( xx * xx ) + ( yy * yy ) + ( zz * zz ) < ( r * r ) );
}

new stepTimer, bool:pInModshop[MAX_PLAYERS], pVehicle[MAX_PLAYERS], pWorld[MAX_PLAYERS];

public OnFilterScriptInit()
{
	stepTimer = SetTimer( "Step", 500, true );
	
	return 1;
}

public OnFilterScriptExit()
{
	KillTimer( stepTimer );
}

public OnPlayerConnect( playerid )
{
	pInModshop[playerid] = false;
}

forward Step();
public Step()
{
	new playerid, vehicleid, Float:x, Float:y, Float:z;
	
	for ( playerid = 0; playerid < GetMaxPlayers(); playerid++ )
	{
		if ( !IsPlayerConnected( playerid ) )
			continue;
		
		GetPlayerPos( playerid, x, y, z );
		
		vehicleid = GetPlayerVehicleID( playerid );
		
		if ( IsPlayerInSphere( playerid, 8.0, 617.5380,  -1.9900, 1000.6829 ) ||
		   IsPlayerInSphere( playerid, 8.0, 616.7803, -74.8151, 997.7710 ) ||
		   IsPlayerInSphere( playerid, 8.0, 615.2800, -124.2392, 997.6360 ) )
		{
			if ( pInModshop[playerid] )
				continue;
			
			pWorld[playerid]   = GetPlayerVirtualWorld( playerid );
			pInModshop[playerid] = true;
			pVehicle[playerid]  = vehicleid;
			
			if ( vehicleid != 0 )
				SetVehicleVirtualWorld( vehicleid, 56 + playerid );
			
			SetPlayerVirtualWorld( playerid, 56 + playerid );
			
			#if DEBUG == true
			SendClientMessage( playerid, 0xFFFFFFFF, "* Modshop enter." );
			#endif
		}
		else if ( pInModshop[playerid] )
		{
			if ( vehicleid != 0 )
				SetVehicleVirtualWorld( vehicleid, pWorld[playerid] );
			
			if ( pVehicle[playerid] != 0 && pVehicle[playerid] != vehicleid )
			{
				SetVehicleVirtualWorld( pVehicle[playerid], pWorld[playerid] );
				SetVehicleToRespawn  ( pVehicle[playerid] );
			}
			
			SetPlayerVirtualWorld( playerid, pWorld[playerid] );
			
			pInModshop[playerid] = false;
			
			#if DEBUG == true
			SendClientMessage( playerid, 0xFFFFFFFF, "* Modshop exit." );
			#endif
		}
	}
}
Share, modify, steal or whatever you want.
Reply


Messages In This Thread
[FS] Anti-Modshop Jack - by Slice - 28.03.2009, 21:29
Re: [FS] Anti-Modshop Jack - by edit - 28.03.2009, 21:39
Re: [FS] Anti-Modshop Jack - by Karlip - 28.03.2009, 21:45
Re: [FS] Anti-Modshop Jack - by CroAtTheTop - 28.03.2009, 21:48
Re: [FS] Anti-Modshop Jack - by Slice - 28.03.2009, 21:50
Re: [FS] Anti-Modshop Jack - by Shadow_ - 28.03.2009, 22:36
Re: [FS] Anti-Modshop Jack - by Slice - 29.03.2009, 19:59
Re: [FS] Anti-Modshop Jack - by UsaBoy91 - 09.07.2009, 15:45
Re: [FS] Anti-Modshop Jack - by Slice - 09.07.2009, 20:06
Re: [FS] Anti-Modshop Jack - by UsaBoy91 - 10.07.2009, 13:25

Forum Jump:


Users browsing this thread: 3 Guest(s)