[Include] OnPlayerJackVehicle - (ninja)Jack detection!
#1

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

Good Job !
Reply
#3

nice, and useful include! suggestions: use foreach, and IsPlayerHoldingNinjaKeys can be prefixed with the bool: tag (to reduce memory usage).
Reply
#4

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 ?
Reply
#5

integer: 32 bit, boolean: 1 bit. am I wrong?
Reply
#6

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
integer: 32 bit, boolean: 1 bit. am I wrong?
Not wrong, it's true.
Reply
#7

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
Reply
#8

You can simply use
pawn Код:
if (ninjajack)
instead of
pawn Код:
if(ninjajack == true)
, but it's optional.

Anyway, good job, rep added.
Reply
#9

Useful for my roleplay server .
Reply
#10

Quote:
Originally Posted by KoczkaHUN
Посмотреть сообщение
You can simply use
pawn Код:
if (ninjajack)
instead of
pawn Код:
if(ninjajack == true)
, but it's optional.

Anyway, good job, rep added.
I know, but "== true" looks easyer to understand for "newbies"

And thx all
Reply
#11

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
Reply
#12

Quote:
Originally Posted by wups
View Post
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.
Reply
#13

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;
}
Reply
#14

nice!
thanks..
will use
Reply
#15

Quote:
Originally Posted by Hiddos
View Post
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)
Reply
#16

Nice include
Reply
#17

I really want to test this out.
Reply
#18

Rather than kicking the player, make them go 10,000 feet in the air and then they will die.
Reply
#19

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.
Reply
#20

What's ninja-jacking anyways? :P
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)