3DText Vehicle Health
#1

How can I make a 3dtextlabel to a vehicle that shows the health of the vehicle with green "X X X X X" letters and with 1000 health they are all green, 900 they are a different color and so on?
Reply
#2

I'm not sure but you can't make 3dtext for a vehicle but you can use textdraw, I can give you a good scrip with name,health,speed of vehicle
pawn Код:
#include <a_samp>
#include <a_players>

forward UpdateSpeed();

enum SavePlayerPosEnum{
    Float:LastX,
    Float:LastY,
    Float:LastZ
}

new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum];
new UpdateSeconds;
new Text:Status_A;
new Text:Status_B;
new Text:Status_C[MAX_PLAYERS];
new Text:Status_D;
new Text:Status_E;
new Text:Status_F;

new CarName[][] =
{
    "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel",
    "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
    "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
    "Esperanto", "Taxi", "Washington", "Bobcat", "Whoopee", "BF Injection",
    "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus",
    "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
    "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
    "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
    "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van",
    "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale",
    "Oceanic","Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy",
    "Hermes", "Sabre", "Rustler", "ZR-350", "Walton", "Regina", "Comet", "BMX",
    "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper",
    "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking",
    "Blista Compact", "Police Maverick", "Boxvillde", "Benson", "Mesa", "RC Goblin",
    "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT",
    "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "Stunt",
    "Tanker", "Roadtrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
    "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune",
    "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer",
    "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent",
    "Bullet", "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo",
    "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite",
    "Windsor", "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratium",
    "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
    "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper",
    "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400",
    "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
    "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car",
    "Police Car", "Police Car", "Police Ranger", "Picador", "S.W.A.T", "Alpha",
    "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs", "Boxville",
    "Tiller", "Utility Trailer"
};

public OnFilterScriptInit()
{
    print("................................................................................");
    print(".");
    print("..");
    print("...");
    print(".... Speedometer has loaded!");
    print("...");
    print("..");
    print(".");
    print("................................................................................");
    SetTimer("UpdateSpeed",500, 1);
    return 1;
}

public OnFilterScriptExit()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            TextDrawDestroy(Status_A);
            TextDrawDestroy(Status_B);
            TextDrawDestroy(Status_C[i]);
            TextDrawDestroy(Status_D);
            TextDrawDestroy(Status_E);
            TextDrawDestroy(Status_F);
        }
    }
    print("................................................................................");
    print(".");
    print("..");
    print("...");
    print(".... Speedometer has unloaded!");
    print("...");
    print("..");
    print(".");
    print("................................................................................");
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_ONFOOT)
    {
        TextDrawHideForPlayer(playerid,Status_A);
        TextDrawHideForPlayer(playerid,Status_B);
        TextDrawHideForPlayer(playerid,Status_C[playerid]);
        TextDrawHideForPlayer(playerid,Status_D);
        TextDrawHideForPlayer(playerid,Status_E);
        TextDrawHideForPlayer(playerid,Status_F);
    }
    return 1;
}

public UpdateSpeed()
{
    new Float:x,Float:y,Float:z;
    new Float:distance,value,string[256];
    new Float:health;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            TextDrawDestroy(Status_A);
            TextDrawDestroy(Status_B);
            TextDrawDestroy(Status_C[i]);
            TextDrawDestroy(Status_D);
            TextDrawDestroy(Status_E);
            TextDrawDestroy(Status_F);
        }
    }

    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            GetPlayerPos(i, x, y, z);
            GetVehicleHealth(GetPlayerVehicleID(i), health);
            distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
            value = floatround(distance * 5000);
            if(UpdateSeconds > 1)
            {
                value = floatround(value / UpdateSeconds);
            }
            format(string,sizeof(string),"Car: ~r~%s~n~~w~Health: ~r~%0.0f%%~n~~n~~g~SPEED:~w~~n~MPH: ~y~%d~w~~n~KM/h: ~y~%d",CarName[GetVehicleModel(GetPlayerVehicleID(i))-400],health/10,floatround(value/1600),floatround(value/1000));
            Status_A = TextDrawCreate(88.000000,264.000000,"xD");
            Status_B = TextDrawCreate(87.000000,251.000000,"~b~~h~~h~Car Status");
            Status_C[i] = TextDrawCreate(87.000000,274.000000,string);
            Status_D = TextDrawCreate(30.000000,264.000000,"x");
            Status_E = TextDrawCreate(88.000000,334.000000,"x");
            Status_F = TextDrawCreate(147.000000,265.000000,"x");
            TextDrawUseBox(Status_A,1);
            TextDrawBoxColor(Status_A,0x00000066);
            TextDrawTextSize(Status_A,0.000000,113.000000);
            TextDrawUseBox(Status_D,1);
            TextDrawBoxColor(Status_D,0x000000ff);
            TextDrawTextSize(Status_D,-2.000000,-4.000000);
            TextDrawUseBox(Status_E,1);
            TextDrawBoxColor(Status_E,0x000000ff);
            TextDrawTextSize(Status_E,-10.000000,113.000000);
            TextDrawUseBox(Status_F,1);
            TextDrawBoxColor(Status_F,0x000000ff);
            TextDrawTextSize(Status_F,-1.000000,-4.000000);
            TextDrawAlignment(Status_A,2);
            TextDrawAlignment(Status_B,2);
            TextDrawAlignment(Status_C[i],2);
            TextDrawAlignment(Status_D,2);
            TextDrawAlignment(Status_E,2);
            TextDrawAlignment(Status_F,2);
            TextDrawBackgroundColor(Status_A,0x000000ff);
            TextDrawBackgroundColor(Status_B,0x000000ff);
            TextDrawBackgroundColor(Status_C[i],0x000000ff);
            TextDrawBackgroundColor(Status_D,0x000000ff);
            TextDrawBackgroundColor(Status_E,0x000000ff);
            TextDrawBackgroundColor(Status_F,0x000000ff);
            TextDrawFont(Status_A,3);
            TextDrawLetterSize(Status_A,-0.000000,7.299998);
            TextDrawFont(Status_B,0);
            TextDrawLetterSize(Status_B,0.799999,1.900000);
            TextDrawFont(Status_C[i],1);
            TextDrawLetterSize(Status_C[i],0.299999,0.899999);
            TextDrawFont(Status_D,3);
            TextDrawLetterSize(Status_D,0.000000,7.299998);
            TextDrawFont(Status_E,3);
            TextDrawLetterSize(Status_E,-0.000000,-0.400000);
            TextDrawFont(Status_F,3);
            TextDrawLetterSize(Status_F,-0.000000,7.299999);
            TextDrawColor(Status_A,0xffffffff);
            TextDrawColor(Status_B,0xffffffff);
            TextDrawColor(Status_C[i],0xffffffff);
            TextDrawColor(Status_D,0xffffffff);
            TextDrawColor(Status_E,0xffffffff);
            TextDrawColor(Status_F,0xffffffff);
            TextDrawSetOutline(Status_A,1);
            TextDrawSetOutline(Status_B,1);
            TextDrawSetOutline(Status_C[i],1);
            TextDrawSetOutline(Status_D,1);
            TextDrawSetOutline(Status_E,1);
            TextDrawSetOutline(Status_F,1);
            TextDrawSetProportional(Status_A,1);
            TextDrawSetProportional(Status_B,1);
            TextDrawSetProportional(Status_C[i],1);
            TextDrawSetProportional(Status_D,1);
            TextDrawSetProportional(Status_E,1);
            TextDrawSetProportional(Status_F,1);
            TextDrawSetShadow(Status_A,1);
            TextDrawSetShadow(Status_B,1);
            TextDrawSetShadow(Status_C[i],1);
            TextDrawSetShadow(Status_D,1);
            TextDrawSetShadow(Status_E,1);
            TextDrawSetShadow(Status_F,1);

            TextDrawShowForPlayer(i,Status_A);
            TextDrawShowForPlayer(i,Status_B);
            TextDrawShowForPlayer(i,Status_C[i]);
            TextDrawShowForPlayer(i,Status_D);
            TextDrawShowForPlayer(i,Status_E);
            TextDrawShowForPlayer(i,Status_F);
        }
        SavePlayerPos[i][LastX] = x;
        SavePlayerPos[i][LastY] = y;
        SavePlayerPos[i][LastZ] = z;
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)