SA-MP Forums Archive
Help with engine - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with engine (/showthread.php?tid=467538)



Help with engine - Yako - 03.10.2013

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;
}



Re: Help with engine - jakejohnsonusa - 03.10.2013

"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?


Re: Help with engine - Yako - 03.10.2013

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


Re: Help with engine - Yako - 04.10.2013

Anybody, please help


Re: Help with engine - Jankingston - 05.10.2013

download this : Clicky