[Help]Textdraw for car's health - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Textdraw for car's health (
/showthread.php?tid=181497)
[Help]Textdraw for car's health -
zack3021 - 05.10.2010
I made my speedometer and a part for health but i cant seem to get any of the health codes i found to work.
Could someone plz show me one. And i will learn from it.
And a tut for how to show car healths in textdraws would be nice too.
Re: [Help]Textdraw for car's health -
Hash [NL-RP] - 05.10.2010
Код:
new Text3D:CarLabel[MAX_VEHICLES];
Top of script.
Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
new str[30];
new vehhealth = GetVehicleHealth(i, health);
format(str, sizeof(str), "%d", vehhealth);
CarLabel[i] = Create3DTextLabel(str, 0x00AE00FF, 0,0, 0, 20.0, 0, 1);
Attach3DTextLabelToVehicle( CarLabel[i],i, 0.0, 0.0, 2.0);
}
OnGameModeInit
Re: [Help]Textdraw for car's health -
zack3021 - 05.10.2010
Well that is a 3d label and i can type /dl in game to see it, i want to be able to show my cars health in a text draw.
Ok here is an example:
NOTE: THIS IS NOT MY PICTURE IT IS JUST AN EXAMPLE
I made my speedo but i want to know just like how i can put the speed on, how can i put the health on.
Re: [Help]Textdraw for car's health -
zack3021 - 06.10.2010
Anyone please help me.
Re: [Help]Textdraw for car's health -
Miguel - 06.10.2010
Use a timer and
OnPlayerStateChange:
pawn Код:
public OnGameModeInit()
{
SetTimer("UpdateTextDraws", 250, true);
return 1;
}
forward UpdateTextDraws();
public UpdateTextDraws()
{
new
i,
string[50],
Float:health,
Float:x,
Float:y,
Float:z,
Float:total;
for(i = 0; i < MAX_PLAYERS; i ++)
{
if(!IsPlayerConnected(i)) return 1;
if(IsPlayerInAnyVehicle(i))
{
GetVehicleHealth(GetPlayerVehicleID(i), health);
format(string, sizeof(string), "Health: %.2f", health);
TextDrawSetString(/*put here the variable of the health textdraw*/, string);
GetVehicleVelocity(GetPlayerVehicleID(i), x, y, z);
total = floatdiv(floatsqroot(x * x + y * y + z * z) * 200000, 3600);
total = floatdiv(total, 1.6);
format(string, sizeof(string), "%d m/h", floatround(total));
TextDrawSetString(/*put here the variable of the velocity textdraw*/, string);
return 1;
}
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new string[50];
format(string, sizeof(string), "Vehicle: %s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid)) - 400]);
TextDrawSetString(/*put here the variable of the vehicle textdraw*/, string);
}
return 1;
}
Re: [Help]Textdraw for car's health -
zack3021 - 06.10.2010
Thanks it worked perfectly. Heave a "cookie"