SetVehicleHealth(vehicleid, 1000.5);
GetVehicleHealth(vehicleid, current_health);
if(current_health <= 1000.25)
{
// Do something here.
}
else
{
// Do something else here.
}
health_set();
value_updated();
get_health(); // Working with the new value.
[23:51:42] Current Health: 419.000000 Vehicle ID: 1 By: 419.000000 [23:51:42] Current Health: 1400.000000 Vehicle ID: 1 By: 981.000000 [23:51:42] Current Health: 2688.000000 Vehicle ID: 1 By: 1288.000000 [23:51:42] Current Health: 3872.000000 Vehicle ID: 1 By: 1184.000000 [23:51:42] Current Health: 4031.000000 Vehicle ID: 1 By: 159.000000 [23:51:42] Current Health: 4058.000000 Vehicle ID: 1 By: 27.000000 [23:51:42] Current Health: 4687.000000 Vehicle ID: 1 By: 629.000000 [23:51:42] Current Health: 5805.000000 Vehicle ID: 1 By: 1118.000000 [23:51:42] Current Health: 6496.000000 Vehicle ID: 1 By: 691.000000 [23:51:42] Current Health: 7413.000000 Vehicle ID: 1 By: 917.000000 [23:51:42] Current Health: 8885.000000 Vehicle ID: 1 By: 1472.000000 [23:51:42] Current Health: 9923.000000 Vehicle ID: 1 By: 1038.000000 [23:51:42] Current Health: 10121.000000 Vehicle ID: 1 By: 198.000000 [23:51:43] Current Health: 11141.000000 Vehicle ID: 1 By: 1020.000000 [23:51:43] Current Health: 11423.000000 Vehicle ID: 1 By: 282.000000 [23:51:43] Current Health: 12868.000000 Vehicle ID: 1 By: 1445.000000 [23:51:43] Current Health: 14326.000000 Vehicle ID: 1 By: 1458.000000 [23:51:43] Current Health: 14364.000000 Vehicle ID: 1 By: 38.000000 [23:51:43] Current Health: 14580.000000 Vehicle ID: 1 By: 216.000000 [23:51:43] Current Health: 14697.000000 Vehicle ID: 1 By: 117.000000 [23:51:43] Current Health: 16011.000000 Vehicle ID: 1 By: 1314.000000 [23:51:43] Current Health: 16246.000000 Vehicle ID: 1 By: 235.000000 [23:51:43] Current Health: 16405.000000 Vehicle ID: 1 By: 159.000000 [23:51:43] Current Health: 17202.000000 Vehicle ID: 1 By: 797.000000 [23:51:43] Current Health: 18210.000000 Vehicle ID: 1 By: 1008.000000 [23:51:43] Current Health: 18750.000000 Vehicle ID: 1 By: 540.000000 [23:51:43] Current Health: 19028.000000 Vehicle ID: 1 By: 278.000000 [23:51:43] Current Health: 19084.000000 Vehicle ID: 1 By: 56.000000 [23:51:43] Current Health: 19976.000000 Vehicle ID: 1 By: 892.000000 [23:51:43] Current Health: 20494.000000 Vehicle ID: 1 By: 518.000000 [23:51:43] Current Health: 21480.000000 Vehicle ID: 1 By: 986.000000 [23:51:44] Current Health: 22907.000000 Vehicle ID: 1 By: 1427.000000 [23:51:44] Current Health: 23052.000000 Vehicle ID: 1 By: 145.000000 [23:51:44] Current Health: 24315.000000 Vehicle ID: 1 By: 1263.000000 [23:51:44] Current Health: 25570.000000 Vehicle ID: 1 By: 1255.000000 [23:51:44] Current Health: 26321.000000 Vehicle ID: 1 By: 751.000000 [23:51:44] Current Health: 27324.000000 Vehicle ID: 1 By: 1003.000000 [23:51:44] Current Health: 28407.000000 Vehicle ID: 1 By: 1083.000000 [23:51:44] Current Health: 29766.000000 Vehicle ID: 1 By: 1359.000000 [23:51:44] Current Health: 30647.000000 Vehicle ID: 1 By: 881.000000 [23:51:44] Current Health: 30943.000000 Vehicle ID: 1 By: 296.000000 [23:51:44] Current Health: 31236.000000 Vehicle ID: 1 By: 293.000000 [23:51:44] Current Health: 31811.000000 Vehicle ID: 1 By: 575.000000 [23:51:44] Current Health: 32508.000000 Vehicle ID: 1 By: 697.000000 [23:51:44] Current Health: 33003.000000 Vehicle ID: 1 By: 495.000000 [23:51:44] Current Health: 33657.000000 Vehicle ID: 1 By: 654.000000 [23:51:44] Current Health: 34437.000000 Vehicle ID: 1 By: 780.000000 [23:51:44] Current Health: 34810.000000 Vehicle ID: 1 By: 373.000000 [23:51:45] Current Health: 35884.000000 Vehicle ID: 1 By: 1074.000000 [23:51:45] Current Health: 36321.000000 Vehicle ID: 1 By: 437.000000 [23:51:45] Current Health: 36876.000000 Vehicle ID: 1 By: 555.000000 [23:51:45] Current Health: 37698.000000 Vehicle ID: 1 By: 822.000000 [23:51:45] Current Health: 37982.000000 Vehicle ID: 1 By: 284.000000 [23:51:45] Current Health: 39093.000000 Vehicle ID: 1 By: 1111.000000 [23:51:45] Current Health: 39134.000000 Vehicle ID: 1 By: 41.000000 [23:51:45] Current Health: 39757.000000 Vehicle ID: 1 By: 623.000000 [23:51:45] Current Health: 40487.000000 Vehicle ID: 1 By: 730.000000 [23:51:45] Current Health: 41892.000000 Vehicle ID: 1 By: 1405.000000 [23:51:45] Current Health: 42561.000000 Vehicle ID: 1 By: 669.000000 [23:51:45] Current Health: 43989.000000 Vehicle ID: 1 By: 1428.000000 [23:51:45] Current Health: 44563.000000 Vehicle ID: 1 By: 574.000000 [23:51:45] Current Health: 44641.000000 Vehicle ID: 1 By: 78.000000 [23:51:45] Current Health: 44673.000000 Vehicle ID: 1 By: 32.000000 [23:51:45] Current Health: 45294.000000 Vehicle ID: 1 By: 621.000000 [23:51:45] Current Health: 45683.000000 Vehicle ID: 1 By: 389.000000 [23:51:46] Current Health: 46218.000000 Vehicle ID: 1 By: 535.000000 [23:51:46] Current Health: 47607.000000 Vehicle ID: 1 By: 1389.000000 [23:51:46] Current Health: 48519.000000 Vehicle ID: 1 By: 912.000000 [23:51:46] Current Health: 49320.000000 Vehicle ID: 1 By: 801.000000 [23:51:46] Current Health: 49357.000000 Vehicle ID: 1 By: 37.000000 [23:51:46] Current Health: 50713.000000 Vehicle ID: 1 By: 1356.000000 [23:51:46] Current Health: 51814.000000 Vehicle ID: 1 By: 1101.000000 [23:51:46] Current Health: 52583.000000 Vehicle ID: 1 By: 769.000000 [23:51:46] Current Health: 52920.000000 Vehicle ID: 1 By: 337.000000 [23:51:46] Current Health: 53480.000000 Vehicle ID: 1 By: 560.000000 [23:51:46] Current Health: 54880.000000 Vehicle ID: 1 By: 1400.000000 [23:51:46] Current Health: 55456.000000 Vehicle ID: 1 By: 576.000000 [23:51:46] Current Health: 56706.000000 Vehicle ID: 1 By: 1250.000000 [23:51:46] Current Health: 58198.000000 Vehicle ID: 1 By: 1492.000000 [23:51:46] Current Health: 59561.000000 Vehicle ID: 1 By: 1363.000000 [23:51:46] Current Health: 59821.000000 Vehicle ID: 1 By: 260.000000 [23:51:46] Current Health: 60396.000000 Vehicle ID: 1 By: 575.000000 [23:51:47] Current Health: 61706.000000 Vehicle ID: 1 By: 1310.000000 [23:51:47] Current Health: 61986.000000 Vehicle ID: 1 By: 280.000000 [23:51:47] Current Health: 62550.000000 Vehicle ID: 1 By: 564.000000 [23:51:47] Current Health: 63966.000000 Vehicle ID: 1 By: 1416.000000 [23:51:47] Current Health: 64629.000000 Vehicle ID: 1 By: 663.000000 [23:51:47] Current Health: 65859.000000 Vehicle ID: 1 By: 1230.000000 [23:51:47] Current Health: 65999.000000 Vehicle ID: 1 By: 140.000000 [23:51:47] Current Health: 66996.000000 Vehicle ID: 1 By: 997.000000 [23:51:47] Current Health: 67358.000000 Vehicle ID: 1 By: 362.000000 [23:51:47] Current Health: 67389.000000 Vehicle ID: 1 By: 31.000000 [23:51:47] Current Health: 67813.000000 Vehicle ID: 1 By: 424.000000 [23:51:47] Current Health: 67898.000000 Vehicle ID: 1 By: 85.000000 [23:51:47] Current Health: 67993.000000 Vehicle ID: 1 By: 95.000000 [23:51:47] Current Health: 69419.000000 Vehicle ID: 1 By: 1426.000000 [23:51:47] Current Health: 70830.000000 Vehicle ID: 1 By: 1411.000000 [23:51:47] Current Health: 71470.000000 Vehicle ID: 1 By: 640.000000 [23:51:47] Current Health: 72637.000000 Vehicle ID: 1 By: 1167.000000 [23:51:48] Current Health: 73210.000000 Vehicle ID: 1 By: 573.000000 [23:51:48] Current Health: 74278.000000 Vehicle ID: 1 By: 1068.000000 [23:51:48] Current Health: 75529.000000 Vehicle ID: 1 By: 1251.000000 [23:51:48] Current Health: 76549.000000 Vehicle ID: 1 By: 1020.000000 [23:51:48] Current Health: 77557.000000 Vehicle ID: 1 By: 1008.000000 [23:51:48] Current Health: 79016.000000 Vehicle ID: 1 By: 1459.000000 [23:51:48] Current Health: 80240.000000 Vehicle ID: 1 By: 1224.000000 [23:51:48] Current Health: 80459.000000 Vehicle ID: 1 By: 219.000000 [23:51:48] Current Health: 81572.000000 Vehicle ID: 1 By: 1113.000000 [23:51:48] Current Health: 82508.000000 Vehicle ID: 1 By: 936.000000 [23:51:48] Current Health: 82853.000000 Vehicle ID: 1 By: 345.000000 [23:51:48] Current Health: 83066.000000 Vehicle ID: 1 By: 213.000000 [23:51:48] Current Health: 84394.000000 Vehicle ID: 1 By: 1328.000000 [23:51:48] Current Health: 85519.000000 Vehicle ID: 1 By: 1125.000000 [23:51:48] Current Health: 86133.000000 Vehicle ID: 1 By: 614.000000 [23:51:48] Current Health: 86650.000000 Vehicle ID: 1 By: 517.000000 [23:51:48] Current Health: 86893.000000 Vehicle ID: 1 By: 243.000000 [23:51:49] Current Health: 87745.000000 Vehicle ID: 1 By: 852.000000 [23:51:49] Current Health: 88519.000000 Vehicle ID: 1 By: 774.000000 [23:51:49] Current Health: 89762.000000 Vehicle ID: 1 By: 1243.000000 [23:51:49] Current Health: 90198.000000 Vehicle ID: 1 By: 436.000000 [23:51:49] Current Health: 90393.000000 Vehicle ID: 1 By: 195.000000 [23:51:49] Current Health: 91787.000000 Vehicle ID: 1 By: 1394.000000 [23:51:49] Current Health: 92500.000000 Vehicle ID: 1 By: 713.000000 [23:51:49] Current Health: 93153.000000 Vehicle ID: 1 By: 653.000000 [23:51:49] Current Health: 94502.000000 Vehicle ID: 1 By: 1349.000000 [23:51:49] Current Health: 95916.000000 Vehicle ID: 1 By: 1414.000000 [23:51:49] Current Health: 96159.000000 Vehicle ID: 1 By: 243.000000 [23:51:49] Current Health: 96499.000000 Vehicle ID: 1 By: 340.000000 [23:51:49] Current Health: 97239.000000 Vehicle ID: 1 By: 740.000000 [23:51:49] Current Health: 98530.000000 Vehicle ID: 1 By: 1291.000000 [23:51:49] Current Health: 98751.000000 Vehicle ID: 1 By: 221.000000 [23:51:49] Current Health: 100134.000000 Vehicle ID: 1 By: 1383.000000 [23:51:49] Current Health: 101582.000000 Vehicle ID: 1 By: 1448.000000 [23:51:50] Current Health: 103056.000000 Vehicle ID: 1 By: 1474.000000 [23:51:50] Current Health: 103751.000000 Vehicle ID: 1 By: 695.000000 [23:51:50] Current Health: 104215.000000 Vehicle ID: 1 By: 464.000000 [23:51:50] Current Health: 104988.000000 Vehicle ID: 1 By: 773.000000 [23:51:50] Current Health: 105584.000000 Vehicle ID: 1 By: 596.000000 [23:51:50] Current Health: 106395.000000 Vehicle ID: 1 By: 811.000000 [23:51:50] Current Health: 106885.000000 Vehicle ID: 1 By: 490.000000 [23:51:50] Current Health: 107169.000000 Vehicle ID: 1 By: 284.000000 [23:51:50] Current Health: 107836.000000 Vehicle ID: 1 By: 667.000000 [23:51:50] Current Health: 109322.000000 Vehicle ID: 1 By: 1486.000000 [23:51:50] Current Health: 109368.000000 Vehicle ID: 1 By: 46.000000 [23:51:50] Current Health: 110824.000000 Vehicle ID: 1 By: 1456.000000 [23:51:50] Current Health: 112131.000000 Vehicle ID: 1 By: 1307.000000 [23:51:50] Current Health: 113448.000000 Vehicle ID: 1 By: 1317.000000 [23:51:50] Current Health: 114455.000000 Vehicle ID: 1 By: 1007.000000 [23:51:50] Current Health: 115106.000000 Vehicle ID: 1 By: 651.000000 [23:51:50] Current Health: 116446.000000 Vehicle ID: 1 By: 1340.000000 [23:51:51] Current Health: 117129.000000 Vehicle ID: 1 By: 683.000000 [23:51:51] Current Health: 117236.000000 Vehicle ID: 1 By: 107.000000 [23:51:51] Current Health: 118267.000000 Vehicle ID: 1 By: 1031.000000 [23:51:51] Current Health: 119697.000000 Vehicle ID: 1 By: 1430.000000 [23:51:51] Current Health: 119943.000000 Vehicle ID: 1 By: 246.000000 [23:51:51] Current Health: 120469.000000 Vehicle ID: 1 By: 526.000000 [23:51:51] Current Health: 121106.000000 Vehicle ID: 1 By: 637.000000 [23:51:51] Current Health: 122241.000000 Vehicle ID: 1 By: 1135.000000 [23:51:51] Current Health: 122933.000000 Vehicle ID: 1 By: 692.000000 [23:51:51] Current Health: 124074.000000 Vehicle ID: 1 By: 1141.000000 [23:51:51] Current Health: 124697.000000 Vehicle ID: 1 By: 623.000000 [23:51:51] Current Health: 125941.000000 Vehicle ID: 1 By: 1244.000000 [23:51:51] Current Health: 126272.000000 Vehicle ID: 1 By: 331.000000 [23:51:51] Current Health: 126699.000000 Vehicle ID: 1 By: 427.000000 [23:51:51] Current Health: 127701.000000 Vehicle ID: 1 By: 1002.000000 [23:51:51] Current Health: 128879.000000 Vehicle ID: 1 By: 1178.000000 [23:51:51] Current Health: 128888.000000 Vehicle ID: 1 By: 9.000000 [23:51:52] Current Health: 129192.000000 Vehicle ID: 1 By: 304.000000 [23:51:52] Current Health: 130456.000000 Vehicle ID: 1 By: 1264.000000 [23:51:52] Current Health: 131926.000000 Vehicle ID: 1 By: 1470.000000 [23:51:52] Current Health: 132712.000000 Vehicle ID: 1 By: 786.000000 [23:51:52] Current Health: 133213.000000 Vehicle ID: 1 By: 501.000000 [23:51:52] Current Health: 133268.000000 Vehicle ID: 1 By: 55.000000 [23:51:52] Current Health: 134752.000000 Vehicle ID: 1 By: 1484.000000 [23:51:52] Current Health: 135589.000000 Vehicle ID: 1 By: 837.000000 [23:51:52] Current Health: 136108.000000 Vehicle ID: 1 By: 519.000000 [23:51:52] Current Health: 137002.000000 Vehicle ID: 1 By: 894.000000 [23:51:52] Current Health: 137151.000000 Vehicle ID: 1 By: 149.000000 [23:51:52] Current Health: 137779.000000 Vehicle ID: 1 By: 628.000000 [23:51:52] Current Health: 138799.000000 Vehicle ID: 1 By: 1020.000000 [23:51:52] Current Health: 139570.000000 Vehicle ID: 1 By: 771.000000 [23:51:52] Current Health: 140357.000000 Vehicle ID: 1 By: 787.000000 [23:51:52] Current Health: 140806.000000 Vehicle ID: 1 By: 449.000000 [23:51:52] Current Health: 141201.000000 Vehicle ID: 1 By: 395.000000 [23:51:53] Current Health: 142336.000000 Vehicle ID: 1 By: 1135.000000 [23:51:53] Current Health: 142809.000000 Vehicle ID: 1 By: 473.000000 [23:51:53] Current Health: 143861.000000 Vehicle ID: 1 By: 1052.000000 [23:51:53] Current Health: 144951.000000 Vehicle ID: 1 By: 1090.000000 [23:51:53] Current Health: 145068.000000 Vehicle ID: 1 By: 117.000000 [23:51:53] Current Health: 146169.000000 Vehicle ID: 1 By: 1101.000000 [23:51:53] Current Health: 147099.000000 Vehicle ID: 1 By: 930.000000 [23:51:53] Current Health: 147135.000000 Vehicle ID: 1 By: 36.000000 [23:51:53] Current Health: 148528.000000 Vehicle ID: 1 By: 1393.000000 [23:51:53] Current Health: 148982.000000 Vehicle ID: 1 By: 454.000000 [23:51:53] Current Health: 150407.000000 Vehicle ID: 1 By: 1425.000000 [23:51:53] Current Health: 150935.000000 Vehicle ID: 1 By: 528.000000 [23:51:53] Current Health: 152353.000000 Vehicle ID: 1 By: 1418.000000 [23:51:53] Current Health: 153511.000000 Vehicle ID: 1 By: 1158.000000 [23:51:53] Current Health: 154293.000000 Vehicle ID: 1 By: 782.000000 [23:51:53] Current Health: 155494.000000 Vehicle ID: 1 By: 1201.000000 [23:51:53] Current Health: 155513.000000 Vehicle ID: 1 By: 19.000000 [23:51:54] Current Health: 156142.000000 Vehicle ID: 1 By: 629.000000 [23:51:54] Current Health: 156713.000000 Vehicle ID: 1 By: 571.000000 [23:51:54] Current Health: 156713.000000 Vehicle ID: 1 By: 0.000000 [23:51:54] Current Health: 157759.000000 Vehicle ID: 1 By: 1046.000000 [23:51:54] Current Health: 158286.000000 Vehicle ID: 1 By: 527.000000 [23:51:54] Current Health: 159570.000000 Vehicle ID: 1 By: 1284.000000 [23:51:54] Current Health: 160256.000000 Vehicle ID: 1 By: 686.000000 [23:51:54] Current Health: 161434.000000 Vehicle ID: 1 By: 1178.000000 [23:51:54] Current Health: 161776.000000 Vehicle ID: 1 By: 342.000000 [23:51:54] Current Health: 162559.000000 Vehicle ID: 1 By: 783.000000 [23:51:54] Current Health: 162861.000000 Vehicle ID: 1 By: 302.000000 [23:51:54] Current Health: 163717.000000 Vehicle ID: 1 By: 856.000000 [23:51:54] Current Health: 163743.000000 Vehicle ID: 1 By: 26.000000 [23:51:54] Current Health: 164618.000000 Vehicle ID: 1 By: 875.000000 [23:51:54] Current Health: 165616.000000 Vehicle ID: 1 By: 998.000000 [23:51:54] Current Health: 166347.000000 Vehicle ID: 1 By: 731.000000 [23:51:54] Current Health: 167324.000000 Vehicle ID: 1 By: 977.000000
#include <a_samp>
main(){}
new veh; // Global as I'd like the Veh ID to be used elsewhere
forward Health();
public OnGameModeInit()
{
veh = CreateVehicle(400, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 0, 60); // Create a vehicle for test purposes
SetTimer("Health", 50, 1); // Start the timer up
return 1;
}
new Float:GetHealth; // Global variable to simulate as if I'm passing it through the function
public Health()
{
new Float:rand = random(1500); // Random increment to health
SetVehicleHealth(veh, GetHealth+rand); // Set that bad boy up with some new health
GetVehicleHealth(veh, GetHealth); // Let's get that puppies health & store it in GetHealth
printf("Current Health: %f Vehicle ID: %i By: %f",GetHealth, veh, rand); // Print it to the console
return 1;
}
![]() Once again, 1000.0 is not the max vehicle health! You can set it to whatever you want, you can even make it invulnerable if you set it high enough. I'm saying this because I've tried it, unlike some people who like to post even when they have no idea of what are they talking about... |