SA-MP Forums Archive
[Help] Radar help(speedometer) - 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: [Help] Radar help(speedometer) (/showthread.php?tid=121114)



[Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Hey guys i just start to create my own Speedo meter radar for the police. but i got it to work perfect accept that the message does not exist a long time only for like 3 seconds. i used GameTextForPlayer(playerid, HGG, 2000, 5); but then i thought that i should make like an update that it repeat same things all the time until i stop it, then i used gspeedo there to stop it. but when i try now it change an show my speed all the time but if i then do /radar [ID] the othere players speed come up but only for a litte lite 3 seconds. so now i need your help to fix this because i got no idea how to fix this.

Код:
if(strcmp(cmd, "/radar", true) ==0 )
	{
   	if(gTeam[playerid] == 2 || IsACop(playerid))
		{
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /radar [id]");
			return 1;
			}
				giveplayerid = ReturnUser(tmp);
  				if(GetDistanceBetweenPlayers(playerid,giveplayerid) < 200)
				{
 					radarspeed(giveplayerid,playerid)
				}
   		}
    return 1;
	}
Код:
public radarspeed(giveplayerid, playerid)
{
	if(IsPlayerConnected(giveplayerid) && IsPlayerInAnyVehicle(giveplayerid))
	{
      if(gSpeedo[playerid] == 2)
      {
			new HGG[256];
			GetPlayerPos(giveplayerid,Xa,Ya,Za);
			KMH = floatsqroot(floatpower(floatabs(floatsub(Xa,Xb[giveplayerid])),2)+floatpower(floatabs(floatsub(Ya,Yb[giveplayerid])),2)+floatpower(floatabs(floatsub(Za,Zb[giveplayerid])),2));
			KMH *= 6.2;
			//Yukseklik = Za;
			//format(HGG, sizeof(HGG), "~b~~h~~h~Name: ~w~%s~n~~g~~h~Speed: ~w~%0.0f km/h~n~~n~~y~~h~Fuel: ~w~%d ~n~~r~~h~Health: ~w~%.2f", ArIsim[GetVehicleModel(GetPlayerVehicleID(i))-400], KMH, Gas[vehicle], Can);
			format(HGG,sizeof(HGG),"~n~~n~~n~~n~~n~~n~~n~~g~Vehicle: ~w~%s - ~g~Speed: ~w~%0.0f km/h", ArIsim[GetVehicleModel(GetPlayerVehicleID(giveplayerid))-400], KMH);
			GameTextForPlayer(playerid, HGG, 2000, 5);
		}
	}
}



Re: [Help] Radar help(speedometer) - GTAguillaume - 15.01.2010

You need a timer. :P
Код:
SetTimerEx("radarspeed",500,1,"ii",giveplayerid,playerid);
EDIT: Hmmm...
EDIT2: what do you mean? The timer?
BTW: Is GetVehicleVelocity not easyer?
EDIT3:
Код:
if(strcmp(cmd, "/radar", true) ==0 )
	{
   	if(gTeam[playerid] == 2 || IsACop(playerid))
		{
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
			SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /radar [id]");
			return 1;
			}
				giveplayerid = ReturnUser(tmp);
  				if(GetDistanceBetweenPlayers(playerid,giveplayerid) < 200)
				{
 					SetTimerEx("radarspeed",500,1,"ii",giveplayerid,playerid);
				}
   		}
    return 1;
	}



Re: [Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Quote:
Originally Posted by GTAguillaume
You need a timer. :P
Well i got an time and thats not the problem the problem is that it shows my Speed not the other player.


Re: [Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Quote:
Originally Posted by GTAguillaume
You need a timer. :P
Код:
SetTimerEx("radarspeed",500,1,"ii",giveplayerid,playerid);
EDIT: Hmmm...
One thing, can you explane to me what all this meens ? xD


Re: [Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Quote:
Originally Posted by GTAguillaume
You need a timer. :P
Код:
SetTimerEx("radarspeed",500,1,"ii",giveplayerid,playerid);
EDIT: Hmmm...
EDIT2: what do you mean? The timer?
Get one error, on this line, the error i get is giveplayerid.


Re: [Help] Radar help(speedometer) - Nero_3D - 15.01.2010

Lets start again

Quote:
Originally Posted by Everest Community
...gspeedo... if i then do /radar [ID] the othere players speed come up but only for a litte lite 3 seconds...
gspeedo ?

yes it shows for exactly 2 seconds because of GameTextForPlayer(playerid, HGG, 2000, 5);

Just say what the command should do, so we know what work is needed

Quote:
Originally Posted by Everest Community
Quote:
Originally Posted by GTAguillaume
You need a timer. :P
Код:
SetTimerEx("radarspeed",500,1,"ii",giveplayerid,playerid);
EDIT: Hmmm...
EDIT2: what do you mean? The timer?
Get one error, on this line, the error i get is giveplayerid.
You should put that in the line where radarspeed(giveplayerid,playerid) (notice the missing semicolon)
And if you dont know what it does => sa-mp wiki


Re: [Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Quote:
Originally Posted by ♣ Joker ♠
Lets start again

Quote:
Originally Posted by Everest Community
...gspeedo... if i then do /radar [ID] the othere players speed come up but only for a litte lite 3 seconds...
gspeedo ?

yes it shows for exactly 2 seconds because of GameTextForPlayer(playerid, HGG, 2000, 5);

Just say what the command should do, so we know what work is needed
Well the command is for police vehicles, When you are in a police vehicle like in real life you can see how fast other people is driving and i have create that now and it works perfect just taht i does only see the message for 2 seconds as you said, but i want the message to repeat until i want to turn it off by typing /turnoffradar and thats when the gspeedo comes.


Re: [Help] Radar help(speedometer) - Nero_3D - 15.01.2010

Quote:
Originally Posted by Everest Community
Well the command is for police vehicles, When you are in a police vehicle like in real life you can see how fast other people is driving and i have create that now and it works perfect just taht i does only see the message for 2 seconds as you said, but i want the message to repeat until i want to turn it off by typing /turnoffradar and thats when the gspeedo comes.
if everything works perfectly, ok
just use the code guillaume posted
if you want to stop the timer you need to kill it (KillTimer) (for that you need to save the timerid)


Re: [Help] Radar help(speedometer) - tony_fitto - 15.01.2010

Quote:
Originally Posted by ♣ Joker ♠
Quote:
Originally Posted by Everest Community
Well the command is for police vehicles, When you are in a police vehicle like in real life you can see how fast other people is driving and i have create that now and it works perfect just taht i does only see the message for 2 seconds as you said, but i want the message to repeat until i want to turn it off by typing /turnoffradar and thats when the gspeedo comes.
if everything works perfectly, ok
just use the code guillaume posted
if you want to stop the timer you need to kill it (KillTimer) (for that you need to save the timerid)
Works perfect thanks guys