/engine working for only ID 0? -
420Scripter - 15.09.2013
When I'm ID 0, it works perfectly.
But when I'm ID 1, I'll do /engine and it will say Engine starting... and nothing will happen, but ID 0 will get a message saying "The engine is too damaged to start!".
Why?
pawn Код:
CMD:engine(playerid, params[])
{
new Float:health;
new vehicle = GetPlayerVehicleID(playerid);
GetVehicleHealth(vehicle, health);
new engine, lights, alarm, doors, bonnet, boot, objective;
new vehicleid = GetPlayerVehicleID(playerid);
new string[126];
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You aren't in any vehicle!");
if(!IsPlayerDriver(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You aren't the driver of this vehicle!");
if(IsPlayerDriver(playerid))
{
if(engine != 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Engine starting...");
SetTimer("EngineTimer", 2000, 0);
return 1;
}
else
{
engine = 0;
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
}
return engine;
}
pawn Код:
forward EngineTimer(playerid);
public EngineTimer(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
new Float:health;
GetVehicleHealth(vehicleid, health);
new string[128];
engine = 1;
if(health < 252) return SendClientMessage(playerid, COLOR_WHITE, "The engine is too damaged to start!");
SendClientMessage(playerid, COLOR_WHITE, "Engine started.");
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "* %s turns the engine of the %s on.", GetPlayerNameEx(playerid), GetVehicleName(vehicleid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
Re: /engine working for only ID 0? -
Jefff - 15.09.2013
pawn Код:
forward EngineTimer(playerid, vehicleid);
public EngineTimer(playerid, vehicleid)
{
new Float:health;
GetVehicleHealth(vehicleid, health);
if(health < 252) SendClientMessage(playerid, COLOR_WHITE, "The engine is too damaged to start!");
else{
new string[128];
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_WHITE, "Engine started.");
SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
format(string, sizeof(string), "* %s turns the engine of the %s on.", GetPlayerNameEx(playerid), GetVehicleName(vehicleid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
return 1;
}
CMD:engine(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(!(0 < vehicleid < MAX_VEHICLES)) SendClientMessage(playerid, COLOR_WHITE, "You aren't in any vehicle!");
else if(!IsPlayerDriver(playerid)) SendClientMessage(playerid, COLOR_WHITE, "You aren't the driver of this vehicle!");
else{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine != 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Engine starting...");
SetTimerEx("EngineTimer", 2000, false, "ii", playerid, vehicleid);
}
else
{
new string[70];
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
return 1;
}