Vehicle damage textdraw mess up
#1

Hello, I've been working on a vehicle damage textdraw and so some reason it doesn't put the health in.. it shows as Damage: 0.000000... I can't see what i've done or gone wrong here, would love for some help!
pawn Код:
public OnPlayerUpdate(playerid)
{
        new ddamage[16];
    format(ddamage, sizeof(ddamage), "damage: %0.f", GetVehDamage(playerid));
    TextDrawSetString(DamageTD, ddamage);
}

stock GetVehDamage(playerid)
{
    new Float:health;
    new vehid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehid, health);
    return 1;
}
Reply
#2

stock GetVehDamage(playerid) should return the Float:health instead of 1.It should look like this
pawn Код:
public OnPlayerUpdate(playerid)
{
        new ddamage[16];
    format(ddamage, sizeof(ddamage), "damage: %0.f", GetVehDamage(playerid));
    TextDrawSetString(DamageTD, ddamage);
}

stock GetVehDamage(playerid)
{
    new Float:health;
    new vehid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehid, health);
    return health;
}
Reply
#3

Getting this error when I change return health;
Quote:

C:\Users\BLACK\Desktop\FunRoam\gamemodes\FunRoam.p wn(1201) : warning 213: tag mismatch

Reply
#4

When returning a float, you need to add a float tag to the function.
pawn Код:
stock Float:GetVehDamage(playerid)
Reply
#5

Adding a Float into the function brings this warning
Quote:

C:\Users\BLACK\Desktop\FunRoam\gamemodes\FunRoam.p wn(1196) : warning 208: function with tag result used before definition, forcing reparse

This works, it's just this warning i'm worried about.
Reply
#6

try using

pawn Код:
return _:health;
remove the Float: from the stock function.
Reply
#7

Quote:
Originally Posted by LeXuZ
Посмотреть сообщение
Adding a Float into the function brings this warning This works, it's just this warning i'm worried about.
Just move the function up in your script(somewhere before you use that function).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)