17.04.2011, 16:20
Hi! I need help with my engine system. Here is the command
And when you enter a vehicle,
Can't add whole OnPlayerStateChange, it's kinda much code. Anyways, if i'm outside a vehicle i get the "You are not the driver" message, but if im inside a car, nothing happens.
pawn Код:
command(engine, playerid, params[])
{
new string[128];
new newcar;
newcar = GetPlayerVehicleID(playerid);
new VehicleName[128];
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid, COLOR_GREY, "You are not the driver.");
}
else
{
if(CarSystem[newcar][cEngine] == 0 )
{
format(string, sizeof(string), "%s spins the %s's key into the ignition and turns on the engine.", UnderscoreToSpaceName(playerid), VehicleName[GetVehicleModel(newcar)-400]);
NearByMessage( playerid, NICESKY, string);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(newcar,1,1,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, WHITE, "Engine {62E36A}ON!");
CarSystem[newcar][cEngine] = 1;
return 1;
}
else
{
format(string, sizeof(string), "%s spins the %s's key into the ignition and turns off the engine.", UnderscoreToSpaceName(playerid), VehicleName[GetVehicleModel(newcar)-400]);
NearByMessage( playerid, NICESKY, string);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(newcar,0,0,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, WHITE, "Engine {F24B5C}OFF!");
CarSystem[newcar][cEngine] = 0;
}
}
return true;
}
pawn Код:
if(CarSystem[newcar][cEngine] == 0 )
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(newcar,0,0,alarm,doors,bonnet,boot,objective);
SendClientMessage(playerid, COLOR_GREY, "Turn on this vehicles engine by typing /eon.");
}
else
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(newcar,1,1,alarm,doors,bonnet,boot,objective);
}