arrestKey in car
#1

Heey guys
How can i make a key in car. I want to make that you can use arrestkey in car but how?
pls help
admigo
Reply
#2

Arrestkey?WIch is that ?
Make a arrestkey?Pff,im a bit confused..
Reply
#3

Oh sorry i will explain better.
If you are cop you can arrest player with /arrest (id) and i made a key(mmb) that you can arrest the closest player. But i cant use it in a vehicle. How can i do it?
Here is my code:
Код:
if(newkeys == KEY_LOOK_BEHIND)
	{
	new ID = GetClosestPlayerToPlayer(playerid);
	dcmd_arrestkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
	dcmd_ticketkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
	if(GetPlayerWantedLevel(ID)==0 && GetDistanceBetweenPlayers(playerid,ID) > 4)
	{
	SendClientMessage(playerid,COLOR_RED,"No Suspect In Range!");
	}
	return 1;
	}
Reply
#4

There are some keys that you can use in cars. One is KEY_CHROUCH which is the Horn Key (H or Caps Lock).
Also, KEY_ACTION, KEY_FIRE, KEY_SPRINT (etc.) i find KEY_CHROUCH as the finest one.

Код:
if(newkeys == KEY_CHROUCH)
{
     new ID = GetClosestPlayerToPlayer(playerid);
     dcmd_arrestkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
     dcmd_ticketkey(playerid, IntToStr(GetClosestPlayerToPlayer(playerid)));
     if(GetPlayerWantedLevel(ID)==0 && GetDistanceBetweenPlayers(playerid,ID) > 4)
     {
          SendClientMessage(playerid,COLOR_RED,"No Suspect In Range!");
     }
     return 1;
}
The KEY_CHROUCH is also "C" so, to don`t allow cops using this thing while on foot, you can add something like:
Код:
if(IsPlayerInVehicle(playerid, the id of the car))
{
your script
}
PS: Also, don`t forgot to add a check if the player is a cop. Because i can`t see that in your script.
Reply
#5

Thanks dude i will test it. But Look behind is a car key because i look ingame to controls then vehicle i see look behind?
ps:i have cops in the dcmd
Reply
#6

Sorry dude dont work:S Is it not the problem of getclosestplayer look:
Код:
forward GetClosestPlayerToPlayer(playerid);
public GetClosestPlayerToPlayer(playerid)
{
    new Float:dist = 1000.0;
    new targetid = INVALID_PLAYER_ID;
    new Float:x1,Float:y1,Float:z1;
    new Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(i == playerid) continue;
        GetPlayerPos(i,x2,y2,z2);
        GetVehiclePos(i,x2,y2,z2);
        tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
        if(tmpdis < dist)
        {
            dist = tmpdis;
            targetid = i;
        }
    }
    return targetid;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)