Speed showing twice -
Devix - 30.10.2012
Hey guys, somehow my speedometer is fucked.
Code:
Код:
public Speedometer()
{
new vehicleid, Float:health;
new engine, lights, alarm, doors, bonnet, boot, objective;
new fstring[32], string[512];
new string2[32], string3[104];
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);
strcat(string, " ", sizeof(string));
strcat(string, GetPlayer3DZone(i), sizeof(string));
strcat(string2, "Fuel:~w~", sizeof(string2));
fstring = "iiiiiiiiii";
if(Fuel[vehicleid] > 100.0) 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(string2, fstring, sizeof(string2));
strcat(string3, " ", sizeof(string3));
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(string3, fstring, sizeof(string3));
PlayerTextDrawSetString(i, SpeedoText, string3);
PlayerTextDrawSetString(i, FuelText, string2);
}
}
}
When two (or more) players are in separated vehicles it will show to one of the two players this:
http://i45.tinypic.com/2ed47k7.png
Thanks!
Re : Speed showing twice -
lelemaster - 30.10.2012
Make the textdraw for the players.
Sample:
new Text:FuelText[MAX_PLAYERS]
Re: Speed showing twice -
Nick.D - 30.10.2012
Yeah, basically what you're doing is showing a textdraw for anyone that is connected and in a vehicle, if anyone is connected and in a vehicle... if that makes sense?
Re: Speed showing twice -
Devix - 31.10.2012
I understand that. I currently use the PlayerTextDraw instead of the general TextDraw. Eitherway, should I make it like..
at onPlayerConnect:
speedotimer = SetTimerEx("Speedometer", 450, true, extra i = playerid) ((NOTE I know how to use this function but I am not home now, dont worry :P).
And then I can do:
public Speedometer(playerid) and get rid of the for-loop and i's in speedometer?