17.06.2013, 01:37
I need totaled scripts. Can someone help me?
new vehEngine[MAX_PLAYERS];
SetTimerEx("Total", 1000, true, "i", playerid);
forward Total(playerid);
Public Total (playerid) //This is probably not right, I'm typing it in this textbox, not the compiler.
{
new VehHealth = GetVehicleHealth(playerid);
if (VehHealth <= 300)
{
SetVehicleParams(vehicleid, 0, -1, -1, -1, -1, -1);
}
return 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;
}
|
^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;
}
|
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 OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
new Float:vHealth;
GetVehicleHealth(vehicleid, vHealth);
if (health =< 300.0)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,objective);
disabled[vehicleid] = true;
}
return 1;
}
CMD:engine(playerid, params)
{
if (disabled[GetPlayerVehicleID(playerid)]) return SendClientMessage(playerid, 0xCC0000FF, "The car's engine is too damaged to start!");
else
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid,1, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}

public OnGameModeInit()
{
ManualVehicleEngineAndLights();
return 1;
}