28.03.2009, 21:29
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
Share, modify, steal or whatever you want.
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 } } }