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

Im so proud im admin on your server___________________________ Finally the bug is fixed alot of ppl abuse this on dm server with me :O
Reply
#3

Quote:
Originally Posted by ksoriano100
Посмотреть сообщение
Im so proud im admin on your server___________________________ Finally the bug is fixed alot of ppl abuse this on dm server with me :O
yeah, thanks for testing
Reply
#4

There are a couple other ways to do this actually. This, however, cover the most common way. Good job.
Reply
#5

Nice job.
Reply
#6

Wrong section too, nice I know a server the needs this desperately.
Reply
#7

Instead of preventing the player from entering as passenger why not use the PutPlayerInVehicle function and warp them in manually? You can get the seatid from OnPlayerEnterVehicle IIRC.
Reply
#8

Quote:
Originally Posted by Jay_
Посмотреть сообщение
Instead of preventing the player from entering as passenger why not use the PutPlayerInVehicle function and warp them in manually? You can get the seatid from OnPlayerEnterVehicle IIRC.
He meant when you're jacking someone, you tap the space (sprint) key when you are in the passenger seat heading to the driver seat.
Entering as passenger is harmless.
Reply
#9

Nice, anti ninja jack
Reply
#10

Wrong section...
Reply
#11

Quote:
Originally Posted by Las Venturas CNR
Посмотреть сообщение
Wrong section...
Nope, i made it as an filterscript but i used wrong tag, i used tutorial instead of filterscript (cant edit that anymore )
Reply
#12

i love this script i will put some credits to u in a script i'm making
Reply
#13

Really great work.
Reply
#14

Quote:
Originally Posted by gamer931215
Посмотреть сообщение
Nope, i made it as an filterscript but i used wrong tag, i used tutorial instead of filterscript (cant edit that anymore )
Ask a moderator, they'll change it.
Reply
#15

If you still search for optimization tips:

pawn Код:
new string[128]; GetPlayerName(playerid, string, sizeof string);
format(string, sizeof string, "%s(%i) Did that", string, playerid);
And this one: Use PVars. Vehicle IDs start at '1', not at '0'. You could easily delete a PVar then as it returns '0' when it's not created.
Reply
#16

Nice gamer. :P
Reply
#17

Put it in tutorials section, anyways, this pwns.
Reply
#18

Nice job.
Reply
#19

Nice, thanks!
Reply
#20

nice it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)