17.06.2013, 05:59
Quote:
|
^that seems like a LOT of extra work for a very simple process.
There's two ways you can do it, by detecting physical damage of the car (less processes required) or just checking the car every x seconds (the only real way to detect if it loses health from bullets). Method 1: Код:
new bool:disabled[MAX_VEHICLES];
public OnVehicleDamageStatusUpdate(vehicleid, playerid) {
//Will ONLY trigger when the car takes physical damage (no bullets)
new Float:vHealth;
GetVehicleHealth(vehicleid, vHealth);
if (health =< 300.0) {
disabled[vehicleid] = true;
}
return 1;
}
CMD:engine(playerid, params) {
//Do your validation stuff here
if (disabled[GetPlayerVehicleID(playerid)]) {
SendClientMessage(playerid, 0xCC0000FF, "The car's engine is too damaged to start!");
//Anything else you want to do
}
else {
//What to do when car is healthy
}
return 1;
}
Код:
new bool:disabled[MAX_VEHICLES];
public OnGameModeInit() {
SetTimer("vCheck", 1000, true);
return 1;
}
forward vCheck;
public vCheck() {
for (new i = 1; i <= MAX_VEHICLES; i++) {
if (!disabled[i]) {
new Float:health;
GetVehicleHealth(i, health);
if (health <= 300.0) {
disabled[i] = true;
}
}
}
return 1;
}
CMD:engine(playerid, params) {
//Do your validation stuff here
if (disabled[GetPlayerVehicleID(playerid)]) {
SendClientMessage(playerid, 0xCC0000FF, "The car's engine is too damaged to start!");
//Anything else you want to do
}
else {
//What to do when car is healthy
}
return 1;
}
|


