SA-MP Forums Archive
Police Speed 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 Speed Radar! (/showthread.php?tid=130284)



Police Speed Radar! - [LSR]State_Trooper - 26.02.2010

Ok, SO I was thinking of making a Radar for the Police so they could see the speed of a player. Like in some admin Scripts. It Syas something like " Admin warning: Playername is going 133 miles an hour" or what ever. I have attempted 2 times and have failed both times.

Any help is appreciated


Re: Police Speed Radar! - [LSR]State_Trooper - 26.02.2010

** BUMP **


Re: Police Speed Radar! - [LSR]State_Trooper - 26.02.2010

Anyone?

OFF TOPIC:

Yes sometime's I am In patiant


Re: Police Speed Radar! - VonLeeuwen - 26.02.2010

Wow, you are impatient.. Nope sorry can't help you.. Well, maybe I can :O

Code:
stock GetPlayerSpeed(playerid) // bottom of your script
{
    new Float:X, Float:Y, Float:Z;
    if(IsPlayerInAnyVehicle(playerid))
    {
        GetVehicleVelocity(GetPlayerVehicleID(playerid), X, Y, Z);
        return floatround(floatmul(floatmul(floatsqroot(floatpower(floatabs(X), 2) + floatpower(floatabs(Y), 2) + floatpower(floatabs(Z), 2)), 100), 1.621371192), floatround_round);
    }
    else
    {
        GetPlayerVelocity(playerid, X, Y, Z);
        return floatround(floatmul(floatmul(floatsqroot(floatpower(floatabs(X), 2) + floatpower(floatabs(Y), 2) + floatpower(floatabs(Z), 2)), 100), 1.621371192), floatround_round);
    }
}
You can add this somewhere, at a command or something, I'm sure you understand this
Code:
new Str[128];
format(Str, sizeof(Str), "You are driving %d km/hour!", GetPlayerSpeed(playerid));
SendClientMessage(playerid, Str);
return 1;
THIS IS NOT MADE BY ME, AND I DIDN'T TEST IT! IT HAS BEEN MADE BY "WANTED".


Re: Police Speed Radar! - addinol - 26.02.2010

FAIL:

You are driving %d km/hour!

He asked that police can see other players speed not his own.


Re: Police Speed Radar! - [LSR]State_Trooper - 26.02.2010

lol, Thanks for teh attempt tho!


Re: Police Speed Radar! - VonLeeuwen - 26.02.2010

Quote:
Originally Posted by addinol
FAIL:

You are driving %d km/hour!

He asked that police can see other players speed not his own.
He could tweak it, smartass..

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[128], idx;
	cmd = strtok(cmdtext, idx);
	new tmp[128];
	if(strcmp(cmd, "/speed", true) == 0)
	{
	  if(gteam == TEAM_LSPD)
	  {
		  tmp = strtok(cmdtext, idx);
		  if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000AA, "USAGE: /speed [id]");
	    new Str[128], iName[MAX_PLAYER_NAME], id;
	    id = strval(tmp);
			format(Str, sizeof(Str), "%s is driving %d km/hour.", iName, GetPlayerSpeed(id));
			SendClientMessage(playerid, 0xFF0000AA, Str);
		}
		else
		{
		  SendClientMessage(playerid,0xFF0000AA, "You are not a cop!");
		}
		return 1;
	}
	return 0;
}
UNTESTED


Re: Police Speed Radar! - bajskorv123 - 26.02.2010

Quote:
Originally Posted by VonLeeuwen
Code:
stock GetPlayerSpeed(playerid)
{
  new Float:X, Float:Y, Float:Z;
  if(IsPlayerInAnyVehicle(playerid))
  {
    GetVehicleVelocity(GetPlayerVehicleID(playerid), X, Y, Z);
    return floatround(floatmul(floatmul(floatsqroot(floatpower(floatabs(X), 2) + floatpower(floatabs(Y), 2) + floatpower(floatabs(Z), 2)), 100), 1.621371192), floatround_round);
  }
  else
  {
    GetPlayerVelocity(playerid, X, Y, Z);
    return floatround(floatmul(floatmul(floatsqroot(floatpower(floatabs(X), 2) + floatpower(floatabs(Y), 2) + floatpower(floatabs(Z), 2)), 100), 1.621371192), floatround_round);
  }
}
Woah, This really returns the players speed/vehicle speed in km/h?


Re: Police Speed Radar! - VonLeeuwen - 26.02.2010

The guy who made it says so, yes.

The guy who made this is called 'WANTED' and is from the Netherlands. It is not made by me.. (just saying it again :P)


Re: Police Speed Radar! - bajskorv123 - 26.02.2010

Quote:
Originally Posted by VonLeeuwen
The guy who made it says so, yes.
Nice


Off Topic:
Quote:
Originally Posted by addinol
FAIL:

You are driving %d km/hour!
He asked that police can see other players speed not his own.
Come up with something better yourself instead of just saying fail...