Get rid of the jack&kill bug! -
gamer931215 - 22.09.2010
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
Re: Get rid of the jack&kill bug! -
ksoriano100 - 22.09.2010
Im so proud im admin on your server___________________________ Finally the bug is fixed alot of ppl abuse this on dm server with me :O
Re: Get rid of the jack&kill bug! -
gamer931215 - 22.09.2010
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
Re: Get rid of the jack&kill bug! -
Slice - 23.09.2010
There are a couple other ways to do this actually. This, however, cover the most common way. Good job.
Re: Get rid of the jack&kill bug! -
Basicz - 23.09.2010
Nice job.
Re: Get rid of the jack&kill bug! -
willsuckformoney - 23.09.2010
Wrong section too, nice I know a server the needs this desperately.
Re: Get rid of the jack&kill bug! -
Jay_ - 23.09.2010
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.
Re: Get rid of the jack&kill bug! -
Slice - 23.09.2010
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.
Re: Get rid of the jack&kill bug! -
[KMA]DlennartD - 23.09.2010
Nice, anti ninja jack
Re: Get rid of the jack&kill bug! -
Las Venturas CNR - 23.09.2010
Wrong section...
Re: Get rid of the jack&kill bug! -
gamer931215 - 24.09.2010
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
)
Re: Get rid of the jack&kill bug! -
GoldenM4 - 29.09.2010
i love this script i will put some credits to u in a script i'm making
Re: Get rid of the jack&kill bug! -
Shubham - 08.11.2010
Really great work.
Re: Get rid of the jack&kill bug! -
Rzzr - 10.11.2010
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.
Re: Get rid of the jack&kill bug! -
Hiddos - 10.11.2010
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.
Re: Get rid of the jack&kill bug! -
WillyP - 10.11.2010
Nice gamer. :P
Re: Get rid of the jack&kill bug! -
Mean - 25.12.2010
Put it in tutorials section, anyways, this pwns.
Re: Get rid of the jack&kill bug! -
HyperZ - 25.12.2010
Nice job.
Re: Get rid of the jack&kill bug! -
juuleman - 25.12.2010
Nice, thanks!
Re: Get rid of the jack&kill bug! -
demonarn - 03.01.2011
nice it works