12.02.2014, 20:17
This command works fine, however, sometimes when you try to start the vehicle's engine it takes up to 5 seconds before it actually works...There isn't that much code there, so I dunno what the issue could me. It's not lag from the server, because i tried it on localhost.
pawn Код:
CMD:engine(pid)
{
if(IsPlayerInAnyVehicle(pid))
{
new id = GetPlayerVehicleID(pid);
if(VBroke[id] == 1) return ErrorMessage(pid, "Vehicle is broken or out of fuel.");
if(VehicleInfo[id][vRented] == pid || VehicleInfo[id][vFaction] == PlayerInfo[pid][pFaction] || strmatch(VehicleInfo[id][vOwner], GetName(pid)))
{
new engine, lights, alarm, doors, bonnet, boot, objective, string[100];
GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 0)
{
SetVehicleParamsEx(id, 1, lights, alarm, doors, bonnet, boot, objective);
format(string, sizeof(string), "twists the key, starting the engine of the %s.", GetVehicleFriendlyName(id));
MeMessage(pid, string);
return 1;
}
else
{
SetVehicleParamsEx(id, 0, lights, alarm, doors, bonnet, boot, objective);
format(string, sizeof(string), "twists the key, shutting off the engine of the %s.", GetVehicleFriendlyName(id));
MeMessage(pid, string);
return 1;
}
}
else return ErrorMessage(pid, "You don't have a key for this vehicle.");
}
else return ErrorMessage(pid, "You aren't in a vehicle.");
}