Speedometer!
#1

pawn Код:
if(IsPlayerInAnyVehicle(ID))
{
new Float:vX, Float:vY, Float:vZ, Float:Speed;
GetVehicleVelocity(GetPlayerVehicleID(ID), vX, vY, vZ);
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(vX, 2), floatpower(vY, 2)),  floatpower(vZ, 2))), 100.0);
if(MasinosID == BMX || MasinosID == MTBIKE || MasinosID == BIKE)
{
format(Stringas,35,"~w~Greitis KM/H: ~y~%i~n~",aVehicleNames[GetVehicleModel(GetPlayerVehicleID(ID))-400], floatround(Speed, floatround_floor));
TextDrawSetString(VHS[ID], Stringas[ID]);
}
else
{
format(Stringas,70,"~w~Greitis KM/H: ~y~%i~n~~w~Degalai: ~y~%iL~n~",floatround(Speed, floatround_floor),vehicleDB[GetPlayerVehicleID(ID)][gas]);
TextDrawSetString(VHS[ID], Stringas[ID]);
}
What's wrong? I can't see it, when i enter the car. Yes, i tryied to show the textdraw, when player enter the car, but it's isn't working.. Please help!
Reply
#2

Is this code under a timer?

Make sure to hide and reshow the textdraw after you reset the string in it. (TextDrawHide & TextDrawShow)

I'm curious though why you are using a global textdraw. You should be using a different textdraw for each player, so they don't get others results.
Reply
#3

Yes, under the timer. (foreaching)

I'm showing the textdraw when player enter some car ( newstate == PLAYER_STATE_DRIVER ), but no hiding. And, variable created with [MAX_PLAYERS], t.y for playerid.
Reply
#4

Bump. ; >
Reply
#5

textdrawshowforplayer? i don't see it anywhere in that script
Reply
#6

Quote:
Originally Posted by Grim_
Посмотреть сообщение
Is this code under a timer?

Make sure to hide and reshow the textdraw after you reset the string in it. (TextDrawHide & TextDrawShow)

I'm curious though why you are using a global textdraw. You should be using a different textdraw for each player, so they don't get others results.
i think it isnt under a timer
Reply
#7

Dude..

SetTimer("SPEEDO", 1000, true);

than

pawn Код:
public Speedo()
{
foreach(Player, ID)
{
if(IsPlayerInAnyVehicle(ID))
{
new Float:vX, Float:vY, Float:vZ, Float:Speed;
GetVehicleVelocity(GetPlayerVehicleID(ID), vX, vY, vZ);
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(vX, 2), floatpower(vY, 2)),  floatpower(vZ, 2))), 100.0);
if(MasinosID == BMX || MasinosID == MTBIKE || MasinosID == BIKE)
{
format(Stringas,35,"~w~Greitis KM/H: ~y~%i~n~",aVehicleNames[GetVehicleModel(GetPlayerVehicleID(ID))-400], floatround(Speed, floatround_floor));
TextDrawSetString(VHS[ID], Stringas[ID]);
}
else
{
format(Stringas,70,"~w~Greitis KM/H: ~y~%i~n~~w~Degalai: ~y~%iL~n~",floatround(Speed, floatround_floor),vehicleDB[GetPlayerVehicleID(ID)][gas]);
TextDrawSetString(VHS[ID], Stringas[ID]);
}
}
return true;
}
and than

onplayerstatechange

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
TextDrawShowForPlayer(playerid, VHS[playerid]);
}
creating:

pawn Код:
KrautiTextDrawus()
{
    foreach(Player, i)
    {
        VHS[i] = TextDrawCreate(495.000000,122.000000,"Spidometras");
        TextDrawAlignment(VHS[i], 0);
        TextDrawBackgroundColor(VHS[i], 0x000000ff);
        TextDrawFont(VHS[i], 1);
        TextDrawLetterSize(VHS[i], 0.299999,1.000000);
        TextDrawColor(VHS[i], 0xCCA129FF);
        TextDrawSetOutline(VHS[i], 0);
        TextDrawSetProportional(VHS[i], 1);
        TextDrawSetShadow(VHS[i], 1);
        TextDrawShowForPlayer(i, VHS[i]);
        KLaikas[i] = TextDrawCreate(200.000000,390.000000,"0");
        TextDrawAlignment(KLaikas[i],0);
        TextDrawBackgroundColor(KLaikas[i],0x000000ff);
        TextDrawFont(KLaikas[i],1);
        TextDrawLetterSize(KLaikas[i],0.455555,1.000000);
        TextDrawColor(KLaikas[i],0xffffffff);
        TextDrawSetOutline(KLaikas[i],1);
        TextDrawSetProportional(KLaikas[i],1);
        TextDrawSetShadow(KLaikas[i],1);
    }
    return 1;
}
Reply
#8

pawn Код:
if(IsPlayerInAnyVehicle(ID))
{
new Float:vX, Float:vY, Float:vZ, Float:Speed;
GetVehicleVelocity(GetPlayerVehicleID(ID), vX, vY, vZ);
Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(vX, 2), floatpower(vY, 2)),  floatpower(vZ, 2))), 100.0);
if(MasinosID == BMX || MasinosID == MTBIKE || MasinosID == BIKE)
{
format(Stringas[ID],35,"~w~Greitis KM/H: ~y~%i~n~",aVehicleNames[GetVehicleModel(GetPlayerVehicleID(ID))-400], floatround(Speed, floatround_floor));
TextDrawSetString(VHS[ID], Stringas[ID]);
}
else
{
format(Stringas[ID],70,"~w~Greitis KM/H: ~y~%i~n~~w~Degalai: ~y~%iL~n~",floatround(Speed, floatround_floor),vehicleDB[GetPlayerVehicleID(ID)][gas]);
TextDrawSetString(VHS[ID], Stringas[ID]);
}
Reply
#9

Nah, no td ;/
Reply
#10

Do a check with print(" ");
You may find which doesn't get called or which doesn't work or where it stops.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)