PDA

View Full Version : Textdraw doesn't show


Abreezy
16/01/2012, 05:42 PM
Hey I created my own speedometer but it doesnt want to show up..Heres the codes:


new Text:SPEEDOS[MAX_PLAYERS];

new Text:SPEEDOMPH[MAX_PLAYERS];


SPEEDOS[playerid] = TextDrawCreate(587.000000, 357.000000, " ");
TextDrawColor(SPEEDOS[playerid], 16711935);
TextDrawSetOutline(SPEEDOS[playerid], 1);
TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);



SPEEDOMPH[playerid] = TextDrawCreate(580.000000, 422.000000, "M.P.H");
TextDrawLetterSize(SPEEDOMPH[playerid], 0.500000, 2.000000);
TextDrawColor(SPEEDOMPH[playerid], -65281);

if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);


TextDrawShowForPlayer(playerid,SPEEDOMPH[playerid]);
SetTimer("Speedometer", 100, true);
}



public Speedometer(playerid)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_ z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid != 0)
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed _z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+ (speed_z*speed_z))*85.416672; // 250.666667 = kmph // 199,4166672= mph
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"%i ",final_speed_int);
TextDrawSetString(SPEEDOS[playerid], speed_string);
}
else
{
TextDrawSetString(SPEEDOS[playerid], " ");

}
return 1;
}


Anyone see an issue? thanks in advance.

Scenario
16/01/2012, 05:49 PM
Are you creating the TD for the player when they connect?

Abreezy
16/01/2012, 05:59 PM
Yeah, because can't use [playerid] under ongamemodeinit

Scenario
16/01/2012, 06:12 PM
Well no, but you can create a loop...

for(new i = 0; i < MAX_PLAYERS; i++)

Abreezy
16/01/2012, 06:14 PM
Well no, but you can create a loop...

for(new i = 0; i < MAX_PLAYERS; i++)

Yeah thats right, It use to work perfectly fine before, No idea why it decided to stop working, But I'll just head to the loop i guess.