Bug or what?
#1

Hello guys as a friend of mine told me it would be better to use PlayerCreateTextdraw and all the related fuctions for a vehicle status system
Health:
Speed: etc..
But i still got the same problem which means that playerids > 0 doesn't show textdraw of Health and Speed why that happens?

Here is the code though.
pawn Код:
new PlayerText:SPEEDOS[MAX_PLAYERS];
new PlayerText:HEALTH[MAX_PLAYERS];


    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);
    new Float:vehicle_health,final_vehicle_health,health_string[256];
    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))*250.666667;
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"~y~Speed: ~w~%i",final_speed_int);
        PlayerTextDrawSetString(playerid,SPEEDOS[playerid], speed_string);
        PlayerTextDrawShow(playerid,SPEEDOS[playerid]);
        GetVehicleHealth(vehicleid,vehicle_health);
        final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5);
        format(health_string,256,"~r~Health: ~w~%i", final_vehicle_health);
        PlayerTextDrawSetString(playerid,HEALTH[playerid], health_string);
        PlayerTextDrawShow(playerid,HEALTH[playerid]);
    }
    else
    {
        PlayerTextDrawSetString(playerid,SPEEDOS[playerid], " ");
        PlayerTextDrawSetString(playerid,HEALTH[playerid], " ");
    }
    return 1;
}
Reply
#2

Can you show us how/where that function gets called? Also where are you using CreatePlayerTextdraw?

Also: isn't final_vehicle_health supposed to be a float?
Reply
#3

This is all what i have... and the createplayertextdraw is under onplayerconnect should i reput it under ongamemodeinit?
Reply
#4

I meant where the Speedometer(playerid) gets called.
Reply
#5

Quote:
Originally Posted by Mean
Посмотреть сообщение
I meant where the Speedometer(playerid) gets called.
OnPlayerConnect
pawn Код:
SetTimer("Speedometer",100,1);
Reply
#6

Replace it with:
pawn Код:
SetTimerEx("Speedometer",100,1, "i", playerid);
Must work then.
Reply
#7

Ok Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)