Hello, I have created mine vehicles ownership,but I got a little problem with engine command.
Well, when I type /engine, if I am in ownable vehicle it says "You don't have the keys..." if it's not your car, but when you enter not ownable vehicle it shows error when you type /engine, any ideas how to fix?
Код:
CMD:engine(playerid, params[])
{
new Float: vehicle_health;
new vehicleid = GetPlayerVehicleID(playerid), string[256];
new vid = GetVehicleID(playerid);
GetVehicleHealth(vehicleid, vehicle_health);
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not in any car!");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_ERROR, "You must sit in the driver seat!");
if(GetPlayerVehicleAccess(playerid, vInfo[vid][Id]) == -1) return SendClientMessage(playerid, COLOR_ERROR, "You don't have the keys of this car!");
if(vehicle_health <= 350) return SendClientMessage(playerid, COLOR_ERROR, "The engine is broken!");
if(Engine[vehicleid] == 1)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 0, 0, alarm, doors, bonnet, boot, objective);
Engine[vehicleid] = 0;
format(string,sizeof(string),"** %s turns off the engine of %s", GetName(playerid), GetVehicleName(vehicleid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, 1, 1, alarm, doors, bonnet, boot, objective);
Engine[vehicleid] = 1;
format(string,sizeof(string),"** %s turns on the engine of %s", GetName(playerid), GetVehicleName(vehicleid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
return 1;
}
"but when you enter not ownable vehicle it shows error when you type /engine, any ideas how to fix?"
I think the problem is because my ownership is based on MAX_DSVEHICLES and it reads MAX_DSVEHICLES owner, but not MAX_VEHICLES