[FilterScript] Advanced Anti-Driveby!
#1

Okay so I just finished this script without testing it, but found no errors in the making. Don't flame me as I have not tested this yet and YES, I'm a noob ffs.

Features:

Quote:

It's a little too basic. Good idea and all, but resetting the weapons when a player enters a vehicle doesn't always work. And it is only driver drive-by.
It's pretty good, just you could make it more accurate (e.g. freezes them for a second when they are in the vehicle, ejects them, disarms them and puts them back in).

It freezes the player once they are in any car, removes them from the car, resets their weapons, and puts them back to their nearest vehicle closest to them.

pawn Код:
#include <a_samp>

forward TakePlayerFromVehicle(playerid);
forward PutPlayerInCar(playerid);

new Weapons[MAX_PLAYERS][12];
new WeaponAmmo[MAX_PLAYERS][12];
new PlayerVehicle[MAX_PLAYERS];
new PutPlayerVehicle[MAX_PLAYERS];
new Car;

public OnFilterScriptInit()
{
        print("Anti-Driveby Loaded...");
        return 1;
}

public OnFilterScriptExit()
{
        print("Anti-Driveby Un-Loaded...");
        return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
        if (newstate==PLAYER_STATE_DRIVER || newstate==PLAYER_STATE_PASSENGER)
        {
        for(new i=0;i<12;i++)
        {
        GetPlayerWeaponData(playerid, i, Weapons[playerid][i], WeaponAmmo[playerid][i]);
        }
            TogglePlayerControllable(playerid, 0); // freeze the player while in the vehicle
            PlayerVehicle[playerid] = SetTimerEx("TakePlayerFromVehicle",1000,0,"i",playerid); // Sets a timer of about 1 second to eject the player from the car
        }
        if (newstate==PLAYER_STATE_ONFOOT && oldstate==PLAYER_STATE_DRIVER)
        {
        for(new i=0;i<12;i++)
        {
            GivePlayerWeapon(playerid, Weapons[playerid][i], WeaponAmmo[playerid][i]); //give their weapon back if they aint in the car anymore.
            }
        }
        return 1;
}

public TakePlayerFromVehicle(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) //check if the player is in ANY vehicle
    {
    RemovePlayerFromVehicle(playerid); //removes the player from the current vehicle
    ResetPlayerWeapons(playerid); //Resets the players weapons before going back in the car
    PutPlayerVehicle[playerid] = SetTimerEx("PutPlayerInCar",2000,0,"i",playerid); //sets a timer of about 2 seconds to put the player back in the vehicle
    }
    return 1;
}

public PutPlayerInCar(playerid)
{
        Car = GetNearestVehicle(playerid, 1); //Gets the nearest vehicle close to you (you can modify the distance if you want, I did this for my own purposes)
        PutPlayerInVehicle(playerid, Car, 0); //Put the player in the vehicle
}

stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ) return floatsqroot(floatadd(floatadd(floatpower(floatsub(X, PointX), 2.0), floatpower(floatsub(Y, PointY), 2.0)), floatpower(floatsub(Z, PointZ), 2.0)));

stock GetNearestVehicle(playerid, Float:Distance = 1000.0)
{
if(!Distance) Distance = 1000.0;
new Float:X[2], Float:Y[2], Float:Z[2], Float:NearestPos = floatabs(Distance), NearestVehicle = INVALID_VEHICLE_ID;
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
for(new i; i<MAX_VEHICLES; i++)
{
if(!IsVehicleStreamedIn(i, playerid) || IsPlayerInVehicle(playerid, i)) continue;
GetVehiclePos(i, X[1], Y[1], Z[1]);
if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i;
}
return NearestVehicle;
}
Credits:

Badger (for the idea)
Me (for the script)
Reply
#2

OMG

This will disarm only driver.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
         SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
}
This will disarm driver and passenger.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate==PLAYER_STATE_DRIVER || newstate==PLAYER_STATE_PASSENGER)
    {
         SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
}
You don't need so much functions in 0.3c. No need to freeze and use timers.
Reply
#3

im enter in vehicle im get ejected lol so fail
Reply
#4

Why did you released it if it's so bugged? You should test script before...
Reply
#5

Quote:
Originally Posted by Cypress
Посмотреть сообщение
OMG

This will disarm only driver.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
         SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
}
This will disarm driver and passenger.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate==PLAYER_STATE_DRIVER || newstate==PLAYER_STATE_PASSENGER)
    {
         SetPlayerArmedWeapon(playerid, 0);
    }
    return 1;
}
You don't need so much functions in 0.3c. No need to freeze and use timers.
I was in a rush and BTW if you didn't read this is my 3rd FS >.>

FTW, Hackers sometimes have way to manage getting weapons STILL inside the cars(as sad as it is, that's why macros and hackers were invented). your function "MIGHT" have some flaws in it as I said "MIGHT"

Quote:
Originally Posted by venice
Посмотреть сообщение
im enter in vehicle im get ejected lol so fail
Then you get put back into the nearest vehicle in 2 seconds...

Quote:
Originally Posted by Phanto90
Посмотреть сообщение
Why did you released it if it's so bugged? You should test script before...
Like I said I was in a rush, now I'm back and I see the disappointment.
I wanted to make this unique but I guess I failed. no need to be so harsh on me ):
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)