SA-MP Forums Archive
Engine script issue - 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: Engine script issue (/showthread.php?tid=318113)



Engine script issue - Cole_William - 13.02.2012

Ok guys when i enter my car the engine is allready on but i want it OFF when first enter and stay on when they get out/ back in....
Please help me!
If you can copy/past the corrections to this with a qoute that would help ALOT

I posted in pastebin for such large code http://pastebin.com/HwWf5emX


Re: Engine script issue - park4bmx - 13.02.2012

inser this
pawn Код:
//at the top
new VehEngineStat[MAX_VEHICLES];


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new playerState = GetPlayerState(playerid);
    if(newkeys & KEY_SUBMISSION && playerState == PLAYER_STATE_DRIVER)
    {
        if(VehLights[vehicleid] == 0) VehicleLights(vehicleid,true);
        else VehicleLights(vehicleid,false);
    }
}

//At the bottome
stock VehicleEngine(vehicleid,VAR)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(VAR == 1)
    {
        VehEngineStat[vehicleid]=1;
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    }else{
        VehEngineStat[vehicleid]=0;
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    }
}



Re: Engine script issue - Cole_William - 13.02.2012

Ok thanks I will try this


Re: Engine script issue - Cole_William - 13.02.2012

Tried it it didnt work.....


Re: Engine script issue - park4bmx - 13.02.2012

Quote:
Originally Posted by Cole_Trethewey
Посмотреть сообщение
Tried it it didnt work.....
what exactly u get errors or ?


Re: Engine script issue - Cole_William - 13.02.2012

I got ALOT of errors this might helpp: This is vortex.......Edit.... Like idk were i should paste it if you can tell me it would help


Re: Engine script issue - park4bmx - 13.02.2012

dont really know if vortex has this allredy :X
pawn Код:
//this goes at the top of your script/gamemode with all the other "new"
new VehEngineStat[MAX_VEHICLES];

//then add whats inside the callback into your current callback
//so do "CTRL + F" and type "OnPlayerKey" and it would show the "public" then just copy and past the callback bellow
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new playerState = GetPlayerState(playerid);
    if(newkeys & KEY_SUBMISSION && playerState == PLAYER_STATE_DRIVER)
    {
        if(VehLights[vehicleid] == 0) VehicleLights(vehicleid,true);
        else VehicleLights(vehicleid,false);
    }
}

//At the bottom , very bottom of the script just add this
stock VehicleEngine(vehicleid,VAR)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(VAR == 1)
    {
        VehEngineStat[vehicleid]=1;
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    }else{
        VehEngineStat[vehicleid]=0;
        SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
    }
}
it has been tested and i use it in one of my gamemodes so yeah
just to let you know

VehicleEngine(vehicleid,VAR)
vehicled is the vehicle's engine you want to taggle ON/OFF
VAR is the the ON/OFF fucntion, "TRUE" = ON , "FALSE" = OFF


Re: Engine script issue - Cole_William - 13.02.2012

For the Public do i post it over the old or just paste under?


Re: Engine script issue - Cole_William - 13.02.2012

Screw it xD


Re: Engine script issue - BrandyPenguin - 13.02.2012

If i under stand right you have problem with this code(engine command and engine)?
pawn Код:
public OnGameModeInit() {
// Do you have there next line:
    ManualVehicleEngineAndLights();
}
fix of engine command you can find:
http://pastebin.com/1knxYvkX