Problems in Speedometer Textdraw - 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)
+--- Thread: Problems in Speedometer Textdraw (
/showthread.php?tid=652090)
Problems in Speedometer Textdraw -
JaskaranSingh - 02.04.2018
I have created a speedometer and I want that TextDraw to show if a player is driving a vehicle.
Everything works fine until the second player drives another car. I see two TextDraws when the other player drives his car. I have spent hours on this and need urgent help.
Speedometer Function
PHP код:
public Speedometer(playerid)
{
new vehicleid, Float:health;
new engine, lights, alarm, doors, bonnet, boot, objective;
new fstring[32], string[512], string2[512];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
{
vehicleid = GetPlayerVehicleID(i);
GetVehicleHealth(vehicleid, health);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
format(fstring, sizeof(fstring),"Speed: %d Km/h", GetPlayerSpeed(i, true));
strcat(string, fstring, sizeof(string));
strcat(string, "~n~Fuel: ", sizeof(string));
format(string2, sizeof(string2), "%.0f%%", Fuel[vehicleid]);
if(Fuel[vehicleid] > 100)
strins(fstring, "~r~", 10, sizeof(fstring));
else if(Fuel[vehicleid] < 0.0)
strins(fstring, "~r~", 0, sizeof(fstring));
else
strins(fstring, "~r~", floatround(Fuel[vehicleid]/10.0), sizeof(fstring));
strcat(string, string2, sizeof(string));
strcat(string, "~n~Status: ", sizeof(string));
if(doors == 1)
strcat(string, "~r~Locked", sizeof(string));
else
strcat(string, "~g~Unlocked", sizeof(string));
TextDrawSetString(SpeedoText[i], string);
}
}
}
OnPlayerEnterVehicle Function
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
SpeedoText[playerid] = TextDrawCreate(520.0, 180.0," ");
TextDrawAlignment(SpeedoText[playerid], 1);
TextDrawFont(SpeedoText[playerid], 1);
TextDrawLetterSize(SpeedoText[playerid], 0.250, 0.900);
TextDrawSetShadow(SpeedoText[playerid], 1);
TextDrawUseBox(SpeedoText[playerid], 0);
TextDrawBoxColor(SpeedoText[playerid], 0x99);
TextDrawSetOutline(SpeedoText[playerid], 1);
TextDrawTextSize(SpeedoText[playerid], 600.000, 0.000);
TextDrawShowForPlayer(playerid, SpeedoText[playerid]);
}
return 1;
}
Re: Problems in Speedometer Textdraw -
jasperschellekens - 02.04.2018
Do you destroy/hide the textdraws when the player leaves the vehicle?