OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
OnPlayerJackVehicle V1.1
About:
I've seen a few includes from
Wups and i was suprised how usefull those functions were, so i decided to make one myself for people who are annoyed by vehicle jackers.
This include will detect when players are jacking or getting jacked.
Callbacks:.
pawn Код:
public OnPlayerJackVehicle(playerid,victimid,vehicleid,bool:ninjajack)
{
/*playerid= the player whos jacking, victimid = the player who is getting jacked
vehicleid = the vehicle getting jacked and ninjajack is when a player is ninjajacking (bug abuse)
ninjajack will be true when positive (player was ninja jacking), and false when negative (no ninja jack).*/
return 1;
}
public OnPlayerGotJacked(playerid,jackerid,vehicleid)
{
/*Playerid = the playerid getting jacked, jackerid = the player whos jacking
and vehicleid is the vehicle getting jacked.*/
return 1;
}
Known bugs:
Код:
When you are jacking too fast between echother then OnPlayerGotJacked() will may not be called!
My advice is just using OnPlayerJackVehicle() !
Example script:
pawn Код:
/*
This example script is written by Gamer931215
This scripts is showing the usage of OPJV and will show
how to make it impossible to jack other players's vehicles!
*/
#include <a_samp>
#include <OPJV>
public OnPlayerJackVehicle(playerid,victimid,vehicleid,bool:ninjajack)
{
if(ninjajack == true)
{
SendClientMessage(playerid,0xffffffff,"Ninja-jacking is NOT allowed!");
Kick(playerid);
} else {
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid,"~w~Jacking is ~r~NOT ~w~allowed!",5000,6);
SetTimerEx("UnfreezePlayer",5000,false,"i",playerid);
}
return 1;
}
public OnPlayerGotJacked(playerid,jackerid,vehicleid)
{
PutPlayerInVehicle(playerid,vehicleid,0); //putting player back in vehicle (just in case)
return 1;
}
forward UnfreezePlayer(playerid);
public UnfreezePlayer(playerid)
{
TogglePlayerControllable(playerid,1);
}
Download:
http://pastebin.com/pgjDSd8i
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
serman - 20.08.2011
Good Job !
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
KoczkaHUN - 20.08.2011
nice, and useful include! suggestions: use foreach, and IsPlayerHoldingNinjaKeys can be prefixed with the bool: tag (to reduce memory usage).
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
Quote:
Originally Posted by KoczkaHUN
nice, and useful include! suggestions: use foreach, and IsPlayerHoldingNinjaKeys can be prefixed with the bool: tag (to reduce memory usage).
|
Well foreach requires another include which can be annoying for users, i like to keep everything as simple as possible in one file. Also isnt a integer and a boolean the same at memmory usage ?
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
KoczkaHUN - 20.08.2011
integer: 32 bit, boolean: 1 bit. am I wrong?
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
kurta999 - 20.08.2011
Quote:
Originally Posted by KoczkaHUN
integer: 32 bit, boolean: 1 bit. am I wrong?
|
Not wrong, it's true.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
Quote:
Originally Posted by KoczkaHUN
integer: 32 bit, boolean: 1 bit. am I wrong?
|
Quote:
Originally Posted by kurta999
Not wrong, it's true.
|
Ok updated it
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
KoczkaHUN - 20.08.2011
You can simply use
instead of
, but it's optional.
Anyway, good job, rep added.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
Darnell - 20.08.2011
Useful for my roleplay server
.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
Quote:
Originally Posted by KoczkaHUN
You can simply use instead of , but it's optional.
Anyway, good job, rep added.
|
I know, but "== true" looks easyer to understand for "newbies"
And thx all
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
wups - 20.08.2011
Hah, quite original.
Use foreach:
Code:
#tryinclude <foreach>
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
Quote:
Originally Posted by wups
Hah, quite original.
Use foreach:
Code:
#tryinclude <foreach>
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
|
Oh never thought about #tryinclude ^^
Thanks, this has been added now.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
Hiddos - 20.08.2011
LOLWUT is this
Code:
public OnPlayerGettingJacked(playerid,jackerid,vehicleid)
{
/*Playerid = the playerid getting jacked, jackerid = the player whos jacking
and vehicleid is the vehicle getting jacked.*/
return 1;
}
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
Kaperstone - 20.08.2011
nice!
thanks..
will use
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
gamer931215 - 20.08.2011
Quote:
Originally Posted by Hiddos
LOLWUT is this
Code:
public OnPlayerGettingJacked(playerid,jackerid,vehicleid)
{
/*Playerid = the playerid getting jacked, jackerid = the player whos jacking
and vehicleid is the vehicle getting jacked.*/
return 1;
}
|
Forgot to rename it,
There are two callbacks:
OnPlayerJackVehicle (is called when a player is attempting to jack a vehicle)
OnPlayerGotJacked (is called AFTER a player is jacked)
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
IstuntmanI - 20.08.2011
Nice include
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
TheArcher - 04.09.2011
I really want to test this out.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
Scenario - 04.09.2011
Rather than kicking the player, make them go 10,000 feet in the air and then they will die.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
AlExAlExAlEx - 19.03.2012
I prefer to slap them, set their health to 1, reset weapons and give pink dildo.
That'll teach them.
By the way, this include is so perfect and easy to use.Thank you.
Re: OnPlayerJackVehicle - (ninja)Jack detection! -
rbN. - 20.03.2012
What's ninja-jacking anyways? :P