[Help] Radar help(speedometer)
#1

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);
		}
	}
}
Reply
#2

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;
	}
Reply
#3

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.
Reply
#4

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
Reply
#5

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.
Reply
#6

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
Reply
#7

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.
Reply
#8

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)
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)