new Text:SpeedoText[MAX_PLAYERS];
SpeedoText[playerid] = TextDrawCreate(540.000000, 400.000000, " ");
TextDrawAlignment(SpeedoText[playerid], 1);
TextDrawFont(SpeedoText[playerid],2);
TextDrawLetterSize(SpeedoText[playerid], 0.310, 1.400);
TextDrawSetShadow(SpeedoText[playerid],0);
TextDrawUseBox(SpeedoText[playerid], 0);
TextDrawBoxColor(SpeedoText[playerid], 0x00);
TextDrawDestroy(SpeedoText[playerid]);
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(IsPlayerInAnyVehicle(playerid) && !IsBicycle(GetPlayerVehicleID(playerid)))
{
TextDrawShowForPlayer(playerid, SpeedoText[playerid]);
}
else
{
TextDrawHideForPlayer(playerid, SpeedoText[playerid]);
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAY_STATE_DRIVER && !IsBicycle(GetPlayerVehicleID(playerid)))
{
TextDrawShowForPlayer(playerid, SpeedoText[playerid]);
}
else
{
TextDrawHideForPlayer(playerid, SpeedoText[playerid]);
}
return 1;
}
PHP код:
|
A few questions, why are you using TextDrawCreate to make a textdraw per player instead of CreatePlayerTextDraw, is the speedometer showing 2 times for the driver of the passenger and how exactly does the speedometer behave while there is 2 players inside of a vehicle?
|
You're talking about 2 different vehicles, right? Let's say you enter your Bullet and you see normally working Speedo but then when Bobby enters his let's say Infernus you see the speedo showing information about the speed of the infernus or fuel or w/e info you're showing like you can see your speedo going 150 mph(which is the Infernus speed) while you stay still in the Bullet?
|
Right, this speedo's speed is update via OnPlayerUpdate or a Timer, can you give me this timer/OnPlayerUpdate code?
|
forward Speedometer();
public Speedometer()
{
new vehicleid, Float:health;
new fstring[32], string[512];
foreach (new i : Player)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
vehicleid = GetPlayerVehicleID(i);
GetVehicleHealth(vehicleid, health);
string = "~w~";
strcat(string, "~w~~h~fuel: ~g~", sizeof(string));
fstring = "iiiiiiiiii";
if(VehicleInfo[vehicleid][eVehicleFuel] > 100.0) strins(fstring, "~r~", 10, sizeof(fstring));
else if(VehicleInfo[vehicleid][eVehicleFuel] < 0.0) strins(fstring, "~r~", 0, sizeof(fstring));
else strins(fstring, "~r~", floatround(VehicleInfo[vehicleid][eVehicleFuel]/10.0), sizeof(fstring));
strcat(string, fstring, sizeof(string));
strcat(string, "~n~~w~~h~", sizeof(string));
if(GetPVarInt(i, "Speedo")) format(fstring,sizeof(fstring),"mph: ~w~%d", GetPlayerSpeed(i, false));
else format(fstring,sizeof(fstring),"kph: ~w~%d", GetPlayerSpeed(i, true));
strcat(string, fstring, sizeof(string));
TextDrawSetString(SpeedoText[i], string);
}
}
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER && !IsBicycle(GetPlayerVehicleID(playerid)))
{
TextDrawShowForPlayer(playerid, SpeedoText[playerid]);
}
else
{
TextDrawHideForPlayer(playerid, SpeedoText[playerid]);
}