Altitudemeter Fail?
#1

Hi samp scripters.

I've got a problem with my self-made altitudemeter.

If there are more players in the server, the meter will show the altitudes of all players.

Here is my code:

Код:
public RefreshAltitudeMeter(playerid)
{
	new Float:x, Float:y, Float:z;
 	if(IsPlayerInAnyVehicle(playerid))
    {
		
		GetPlayerPos(playerid, x, y, z);

	    format(AltitudeString, sizeof(AltitudeString), "Altitude: %.2f meters", z);
	    
	    TextDrawSetString(Altitudemeter, AltitudeString);
	    TextDrawShowForPlayer(playerid, Altitudemeter);
     }
     else
     {
     	TextDrawHideForPlayer(playerid, Altitudemeter);
        return 1;
     }
	return 1;
}
Can someone help me??
Reply
#2

pawn Код:
new Text:Altitudemeter[MAX_PLAYERS];
not
pawn Код:
new Text:Altitudemeter;
pawn Код:
TextDrawSetString(Altitudemeter, AltitudeString[playerid]);
    TextDrawShowForPlayer(playerid, AltitudeString[playerid]);
    }
    else
    {
        TextDrawHideForPlayer(playerid, AltitudeString[playerid]);
    }
and SetTimerEx not SetTimer
Reply
#3

I think you're not right :S
Reply
#4

He is right.
Reply
#5

Quote:
Originally Posted by johannetje2
Посмотреть сообщение
I think you're not right :S
He is.
Reply
#6

Yes he is. You need to define their length, so try it. And use pawn /pawn tags
Reply
#7

This is my code:


Defines...
Код:
new Text:Altitudemeter;
new AltitudeString[128];
Код:
Altitudemeter = TextDrawCreate(483.000000, 99.000000, "Altitude: 0.00 meters");
	TextDrawBackgroundColor(Altitudemeter, 255);
	TextDrawFont(Altitudemeter, 1);
	TextDrawLetterSize(Altitudemeter, 0.290000, 1.400000);
	TextDrawColor(Altitudemeter, -939523896);
	TextDrawSetOutline(Altitudemeter, 0);
	TextDrawSetProportional(Altitudemeter, 1);
	TextDrawSetShadow(Altitudemeter, 1);
Start the timer...
Код:
public OnPlayerSpawn(playerid)
{
	if (IsInDM[playerid] == 0)
        {
    	    SetTimerEx("RefreshAltitudeMeter", 100, true, "i", playerid);
        }
   return 1;
}
The timer code...
Код:
public RefreshAltitudeMeter(playerid)
{
	new playervehicleid;
	new Float:x, Float:y, Float:z;
 	if(IsPlayerInAnyVehicle(playerid))
    {
	    playervehicleid = GetPlayerVehicleID(playerid);
		GetVehiclePos(playervehicleid, x, y, z);

	    format(AltitudeString, sizeof(AltitudeString), "Altitude: %.2f meters", z);
	    
	    TextDrawSetString(Altitudemeter, AltitudeString);
	    TextDrawShowForPlayer(playerid, Altitudemeter);
     }
     else
     {
     	TextDrawHideForPlayer(playerid, Altitudemeter);
        return 1;
     }
	return 1;
}
Help!
Reply
#8

You're idi.... Follow that what Jefff said it.
Reply
#9

Jefff said the textdraw AltitudeString must been showed. But that's a string, not a textdraw.

Код:
TextDrawSetString(Altitudemeter, AltitudeString[playerid]);
    TextDrawShowForPlayer(playerid, AltitudeString[playerid]);
    }
    else
    {
        TextDrawHideForPlayer(playerid, AltitudeString[playerid]);
    }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What to do with the format?

Код:
format(AltitudeString, sizeof(AltitudeString), "Altitude: %.2f meters", z);
If i do what Jefff said, i receive 11 errors.
Reply
#10

Ops my bad Just replace to
pawn Код:
TextDrawSetString(Altitudemeter[playerid], AltitudeString);
    TextDrawShowForPlayer(playerid, Altitudemeter[playerid]); // You dont need that many times
    }
    else
    {
        TextDrawHideForPlayer(playerid, Altitudemeter[playerid]);
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)