15.09.2013, 17:07
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?
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;
}