Help with engine
#1

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;
}
Код:
stock GetVehicleID(playerid)
{

 	for(new i = 0; i < MAX_DSVEHICLES; i ++)
	{
	if(GetPlayerVehicleID(playerid) == vInfo[i][Vehicle]) return i;
	}
	return -1;
}
Reply
#2

"but when you enter not ownable vehicle it shows error when you type /engine, any ideas how to fix?"

Well, what error is it displaying?
Reply
#3

It shows message from this callback:

Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{

	if(!success)
	{
	new str[126];
	format(str, sizeof(str), "Unknown command! Please type /help for a list of available commands.",cmdtext);
	SendClientMessage(playerid, COLOR_ERROR, str);
	return 1;
	}
	return 1;
}
I think the problem is because my ownership is based on MAX_DSVEHICLES and it reads MAX_DSVEHICLES owner, but not MAX_VEHICLES
Reply
#4

Anybody, please help
Reply
#5

download this : Clicky
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)