Police Radar - 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: Police Radar (
/showthread.php?tid=125659)
Police Radar -
br0adyb0ii - 05.02.2010
Does Anyone Have A Radar Command That Would Allow The Police To Tell How Fast The Vehicles Are Going Around Them.
Re: Police Radar -
mansonh - 05.02.2010
You could do something like that pretty simple.
There are obviously more sophisticated ways.
ClosestPlayerVehicleSpeed
playerid,
Float
![confused](images/smilies/confused.gif)
peed returns speed,
otherplayer(optional) if you want to specify a player
returns player that it got speed for or -1 for no player
pawn Код:
stock ClosestPlayerVehicleSpeed(playerid, &Float:speed, otherplayer=-1)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
new closest = -1, Float:dist = 200.0;
if(closest == otherplayer)
{
for(new pid=0; pid<GetMaxPlayers(); pid++)
{
if(!IsPlayerConnected(pid) || GetPlayerState != PLAYER_STATE_DRIVER || !IsPlayerInRangeOfPoint(pid,dist-1.0, X, Y, Z) || pid == playerid) continue;
//here we know we have someone closer
closese = pid;
new Float:pX, Float:Py, Float:Pz;
GetPlayerPos(pid, pX, Py, Pz);
distance = floatsqroot(floatpower(floatabs(pX-X),2)+floatpower(floatabs(pY-Y),2)+floatpower(floatabs(pZ-z),2));
}
}else if(IsPlayerConnected(pid) && GetPlayerState == PLAYER_STATE_DRIVER && IsPlayerInRangeOfPoint(otherplayer, dist, X, Y, Z) closest = otherplayer;
speed = GetVehicleVelocity(GetPlayerVehicleID(closest));
return closest;
}
Re: Police Radar -
UltraKiller - 05.05.2010
How i can use this stock in my comand to show cops the speed...?
This is my command:
if(strcmp(cmd, "/radar", true) ==0 )
{
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
{
if(OnDuty[playerid] == 1)
{
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not working!");
return 1;
}
}
return 1;
}