Simple question rep+
#1

Hey, my question is VERY simple I think, Where Could I put
pawn Код:
{
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(i, 0, lights, false, doors, bonnet, boot, objective);
    }
In my script? Where would be the best place to put it so cars have the engine off? I tryed under OnVehicleSpawn, OnVehicleStreamIn etc etc.. But whenever a vehicle spawns, the engines get set to 0, and whenver a vehicle streams in, it gets set to 0, So would OnGamemodeinit Be the best way? But after the cars spawn the engine starts normally,
Reply
#2

I think in
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER) {
.
Reply
#3

I have that their.. But thats to set it to what the current engine state is.

pawn Код:
else if(newstate == PLAYER_STATE_DRIVER)
    {
        new carid = GetPlayerVehicleID(playerid);
        if(Vehicles[carid][Engine] == 0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, 0, lights, false, doors, bonnet, boot, objective);
        }
        else if(Vehicles[carid][Engine] == 1)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, 1, lights, false, doors, bonnet, boot, objective);
        }
    }
Reply
#4

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
I have that their.. But thats to set it to what the current engine state is.

pawn Код:
else if(newstate == PLAYER_STATE_DRIVER)
    {
        new carid = GetPlayerVehicleID(playerid);
        if(Vehicles[carid][Engine] == 0)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, 0, lights, false, doors, bonnet, boot, objective);
        }
        else if(Vehicles[carid][Engine] == 1)
        {
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, 1, lights, false, doors, bonnet, boot, objective);
        }
    }
pawn Код:
else if(newstate == PLAYER_STATE_DRIVER)
    {
        if(VehicleEngine[newcar] == 0) {

            if(!IsNotAEngineCar(newcar)) {
            //new engine,lights,alarm,doors,bonnet,boot,objective,panels,tires;
                GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(newcar,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
                GetVehicleDamageStatus(newcar,panels,doors,lights,tires);
                UpdateVehicleDamageStatus(newcar, panels, doors, 5, tires);
                VehAsk[playerid] = 1;
                SendClientMessage(playerid, COLOR_GREEN, "Engine is not started (/engine)");
                SendClientMessage(playerid, COLOR_GREEN, "If it is a faction vehicle (/fengine)");
            }

        }
See this is mine, and it works.
Reply
#5

I have this on game mode init:

PHP код:
public OnGameModeInit()
{
    for( new 
0;MAX_VEHICLESi++ )
    {
        
SetVehicleParamsEx(i0000000);
    }

Reply
#6

Hm, try this, place it under your OnGameModeInit:
pawn Код:
ManualVehicleEngineAndLights();
Then add your commands to power the engine on and off, etc. in the wanted callback.
Reply
#7

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
I have this on game mode init:

pawn Код:
public OnGameModeInit()
{
    for( new i = 0;i < MAX_VEHICLES; i++ )
    {
        SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0);
    }
}
Why would you do that, when you can just do;
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
    //Other Stuff here or what-ever.
    return 1;
}
Anyways, do the following:
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();// Vehicles engines are OFF
    return 1;
}
pawn Код:
// Command done using ZCMD.
CMD:engine(playerid, params[])
{
    if((GetPlayerState(playerid) == 2))
    {
        new carid = GetPlayerVehicleID(playerid);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        if(engine == VEHICLE_PARAMS_ON)
        {
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, VEHICLE_PARAMS_OFF, lights, false, doors, bonnet, boot, objective);
        }
        else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, VEHICLE_PARAMS_ON, lights, false, doors, bonnet, boot, objective);
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, " ** You must be the driver to use this command !");
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Lynn
Посмотреть сообщение
Why would you do that, when you can just do;
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
    //Other Stuff here or what-ever.
    return 1;
}
Anyways, do the following:
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();// Vehicles engines are OFF
    return 1;
}
pawn Код:
CMD:engine(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new carid = GetPlayerVehicleID(playerid);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        if(engine == VEHICLE_PARAMS_ON)
        {
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, VEHICLE_PARAMS_OFF, lights, false, doors, bonnet, boot, objective);
        }
        else if((engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET))
        {
            GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(carid, VEHICLE_PARAMS_ON, lights, false, doors, bonnet, boot, objective);
        }
    }
    return 1;
}
Because there are some cars that should be turned on, and those are accounted for.
Reply
#9

Quote:
Originally Posted by Nuke547
Посмотреть сообщение
Because there are some cars that should be turned on, and those are accounted for.
Your code would still turn off the vehicles(all) just in a more... inefficient way.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)