Altitudemeter Fail? -
johannetje2 - 11.04.2011
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??
Re: Altitudemeter Fail? -
Jefff - 11.04.2011
pawn Код:
new Text:Altitudemeter[MAX_PLAYERS];
not
pawn Код:
TextDrawSetString(Altitudemeter, AltitudeString[playerid]);
TextDrawShowForPlayer(playerid, AltitudeString[playerid]);
}
else
{
TextDrawHideForPlayer(playerid, AltitudeString[playerid]);
}
and SetTimerEx not SetTimer
Re: Altitudemeter Fail? -
johannetje2 - 11.04.2011
I think you're not right :S
Re: Altitudemeter Fail? -
woot - 11.04.2011
He is right.
Re: Altitudemeter Fail? -
WackoX - 11.04.2011
Quote:
Originally Posted by johannetje2
I think you're not right :S
|
He is.
Re: Altitudemeter Fail? -
Rivera - 11.04.2011
Yes he is. You need to define their length, so try it. And use pawn /pawn tags
Re: Altitudemeter Fail? -
johannetje2 - 11.04.2011
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!
Re: Altitudemeter Fail? -
Typhome - 11.04.2011
You're idi....
Follow that what Jefff said it.
Re: Altitudemeter Fail? -
johannetje2 - 11.04.2011
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.
Re: Altitudemeter Fail? -
Jefff - 11.04.2011
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]);
}