[FilterScript] Get rid of the jack&kill bug!
#1

About
Hello guys, after reading Las Venturas CNR's topic (https://sampforum.blast.hk/showthread.php?tid=178405)
i decided to make an bugfix for this.


The bug

Basicly when you jacked someone's vehicle, stepped in as passenger, and you keep pressing the space key the victim would die!


The fix

What is basicly does is when you pressed/holding/releasing the sprint key when youre stepping in an vehicle, and another player is inside it will teleport you to your position to stop you from jacking. This means it isnt possible to jack anymore if you use the space key!


The script:

pawn Код:
#include <a_samp>

#define HOLDING(%0) \
    ((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
   
new IsPlayerSteppingInVehicle[MAX_PLAYERS] = -1;

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    IsPlayerSteppingInVehicle[playerid] = -1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    IsPlayerSteppingInVehicle[playerid] = vehicleid;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (HOLDING(KEY_SPRINT) || PRESSED(KEY_SPRINT) || RELEASED(KEY_SPRINT))
    {
        if (IsPlayerSteppingInVehicle[playerid] > -1)
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if (GetPlayerVehicleID(i) == IsPlayerSteppingInVehicle[playerid] && i != playerid)
                {
                    new Float:x,Float:y,Float:z,pName[28],string[128];
                    GetPlayerPos(playerid,x,y,z);
                    SetPlayerPos(playerid,x,y,z);
                    GameTextForPlayer(playerid,"~r~Please do NOT abuse the \r\n~w~Jack bug",5000,4);
                    IsPlayerSteppingInVehicle[playerid] = -1;
                    GetPlayerName(playerid,pName,28);
                    format(string,sizeof string,"%s(%i) has tried to abuse the jack bug!",pName,playerid);
                    print(string);
                }
            }
        }
    }
    return 1;
}
I know im not very good in optimising code, if you have a better idea/tips/optimalisations, feel free to post !

Credits

Las Venturas CNR for inspiring me
ksoriano100 for testing
me for scripting
Reply


Messages In This Thread
Get rid of the jack&kill bug! - by gamer931215 - 22.09.2010, 21:47
Re: Get rid of the jack&kill bug! - by ksoriano100 - 22.09.2010, 21:50
Re: Get rid of the jack&kill bug! - by gamer931215 - 22.09.2010, 21:55
Re: Get rid of the jack&kill bug! - by Slice - 23.09.2010, 06:47
Re: Get rid of the jack&kill bug! - by Basicz - 23.09.2010, 06:54
Re: Get rid of the jack&kill bug! - by willsuckformoney - 23.09.2010, 08:08
Re: Get rid of the jack&kill bug! - by Jay_ - 23.09.2010, 11:58
Re: Get rid of the jack&kill bug! - by Slice - 23.09.2010, 12:04
Re: Get rid of the jack&kill bug! - by [KMA]DlennartD - 23.09.2010, 14:02
Re: Get rid of the jack&kill bug! - by Las Venturas CNR - 23.09.2010, 23:26
Re: Get rid of the jack&kill bug! - by gamer931215 - 24.09.2010, 07:37
Re: Get rid of the jack&kill bug! - by GoldenM4 - 29.09.2010, 20:47
Re: Get rid of the jack&kill bug! - by Shubham - 08.11.2010, 18:06
Re: Get rid of the jack&kill bug! - by Rzzr - 10.11.2010, 17:32
Re: Get rid of the jack&kill bug! - by Hiddos - 10.11.2010, 18:10
Re: Get rid of the jack&kill bug! - by WillyP - 10.11.2010, 18:58
Re: Get rid of the jack&kill bug! - by Mean - 25.12.2010, 10:31
Re: Get rid of the jack&kill bug! - by HyperZ - 25.12.2010, 10:40
Re: Get rid of the jack&kill bug! - by juuleman - 25.12.2010, 10:41
Re: Get rid of the jack&kill bug! - by demonarn - 03.01.2011, 15:59
Re: Get rid of the jack&kill bug! - by Toreno - 03.01.2011, 17:19
Re: Get rid of the jack&kill bug! - by Jeffry - 01.02.2011, 15:02
Respuesta: Get rid of the jack&kill bug! - by ipsBruno - 01.02.2011, 15:06
Re: Get rid of the jack&kill bug! - by Xlithan - 14.01.2013, 19:34

Forum Jump:


Users browsing this thread: 4 Guest(s)