28.04.2017, 12:26
Not trying to offend you, but you're offering to teach scripting where you've none to less scripting and actual knowledge of SA-MP. Some stuff that I'd suggest you is, that you read the SA-MP wiki, it has almost everything you need.
Use 1000 ms (1 second) timer, and call it under OnGameModeInit, kill it under OnGameModeExit. Use foreach or player-pool size loop instead of MAX_PLAYERS loop, I'd recommend foreach though, but it's totally up to you that which one you choose to use.
EDIT: Example given below:
Use 1000 ms (1 second) timer, and call it under OnGameModeInit, kill it under OnGameModeExit. Use foreach or player-pool size loop instead of MAX_PLAYERS loop, I'd recommend foreach though, but it's totally up to you that which one you choose to use.
EDIT: Example given below:
PHP код:
// Along with other defines
#define METRES_TO_FEET(%0) \
((%0) / 0.3047999995367040007042099189296)
// Under OnGameModeInit
SetTimer("updateVehicleTD", 1000, true);
// Somewhere in the script
forward updateVehicleTD();
public updateVehicleTD()
{
new string[50], Float: vehX, Float: vehY, Float: vehZ, vehHealth;
foreach(new i : Player)
{
if(IsPlayerInAnyVehicle(i))
{
format(string, sizeof string, "~b~KM/H: ~w~%d", GetKMHSpeed(i));
PlayerTextDrawSetString(i, vehKMH[i], string);
GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
format(string, sizeof string, "~b~Health: ~w~%0.0f", vHealth);
PlayerTextDrawSetString(i, vehHealth[i], string);
GetVehiclePos(GetPlayerVehicleID(playerid), vehX, vehY, vehZ);
format(string, sizeof string, "~b~Altitude: ~w~%d M", floatround(METRES_TO_FEET(z)));
PlayerTextDrawSetString(i, vehAlt[i], string);
}
}
return 1;
}