[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
#2

Nicely done Slice
Reply
#3

Thanks,
this should be built into SA-MP srsly.
It's annoying :P
Reply
#4

Can about few players at the same time mod their vehicles in the same modshop with this FS too?
Reply
#5

Quote:
Originally Posted by CroAtTheTop
Can about few players at the same time mod their vehicles in the same modshop with this FS too?
Yes, they won't be placed ontop of eachother.
Reply
#6

This is one of the best [FS] i have seen out there very useful!

Quote:
Originally Posted by !Karlip
Thanks,
this should be built into SA-MP srsly.
It's annoying :P
And your correct, There should be Virtual Worlds added
Reply
#7

Thx for the feedback

I just tested it with passengers and it worked fine too, the car just goes invisible but no bugs/crashes.
Reply
#8

That's good , but i think :

pawn Код:
if (!IsPlayerConnected(playerid))
            continue;
must be
pawn Код:
if (IsPlayerConnected(playerid))
            continue;
isn't ?
Reply
#9

Quote:
Originally Posted by MJφ
That's good , but i think :

pawn Код:
if (!IsPlayerConnected(playerid))
            continue;
must be
pawn Код:
if (IsPlayerConnected(playerid))
            continue;
isn't ?
Continue will skip the code below it, so it the player is not connected it will go to the next player and check.
Reply
#10

i think must be

pawn Код:
if(!IsPlayerConnected(playerid)) break;
Because if that playerid isn't connected , the playerid loop is break , and it continue with the next playerid.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)