arrestKey in car - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: arrestKey in car (
/showthread.php?tid=254750)
arrestKey in car -
Admigo - 12.05.2011
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
Re: arrestKey in car -
SkizzoTrick - 12.05.2011
Arrestkey?WIch is that ?

Make a arrestkey?Pff,im a bit confused..
Re: arrestKey in car -
Admigo - 12.05.2011
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;
}
Re: arrestKey in car -
Westiee - 12.05.2011
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.
Re: arrestKey in car -
Admigo - 12.05.2011
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
Re: arrestKey in car -
Admigo - 12.05.2011
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;
}