Engine System
#1

Hi! I need help with my engine system. Here is the command

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;
}
And when you enter a vehicle,

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);
        }
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.
Reply
#2

pawn Код:
if(IsPlayerInAnyVehicle(playerid))
?
Reply
#3

Ye, i added it but took it away to see if that caused the problem. It wasn't.
Reply
#4

Remove this post pelase.
Reply
#5

CarSystem[newcar][cEngine]. I don't recommend this. You should use a function to determine the vehicle parameters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)