SA-MP Forums Archive
/engine script - 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 (/showthread.php?tid=388137)



/engine script - Swyft™ - 27.10.2012

Well as I am trying to create an engine script, it is working, but it is failing at the same time..

pawn Код:
CMD:engine(playerid, params[]) {
    new vehicleid = GetPlayerVehicleID(playerid);
    new engine, lights, alarm, doors, bonnet, boot, objective;

    if(GetPlayerState(playerid) == 2)
    {
        if(IsPlayerInAnyVehicle(playerid)) {
            switch(playerVariables[playerid][pCarEngine]) {
                case 0: {
                    playerVariables[playerid][pCarEngine] = 1;
                    SetVehicleParamsEx(vehicleid,true,lights,alarm,doors,bonnet,boot,objective);
                    format(szMessage, sizeof(szMessage), "* %s has put his keys in the ignition, turning on the vehicle.", szPlayerName);
                    nearByMessage(playerid, COLOR_PURPLE, szMessage);
                }
                default: {
                    playerVariables[playerid][pCarEngine] = 0;
                    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//this will check that what is the state of engine.That is is on or off.We can use it for multiple things like doors,alarms etc.But In this case I am using this for the engine only.
                    SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
                    format(szMessage, sizeof(szMessage), "* %s has put his keys in the ignition, turning off the vehicle.", szPlayerName);
                    nearByMessage(playerid, COLOR_PURPLE, szMessage);
                }
            }
        }
    }
    return 1;
}
So I got everything working, but when people enter a car they can still drive it.. and when they do /engine it says engine turns on.... which is kinda bugged any way on fixing this, hELP ASAP


Re: /engine script - ikbenremco - 27.10.2012

add under ongamemodeinit ManualVehicleEngineAndLights();


Re: /engine script - Swyft™ - 27.10.2012

I did...


Re: /engine script - Swyft™ - 27.10.2012

Hold up, actualy wait what I said was total opposite, if the vehicle is off and I do /engine, then it says the engine is turning off.. any suggestions?


Re: /engine script - Eric - 27.10.2012

Make sure all of your variables are set right.
Try this, though.

pawn Код:
CMD:engine(playerid, params[]) {
    new vehicleid = GetPlayerVehicleID(playerid);
    new engine, lights, alarm, doors, bonnet, boot, objective;

    if(GetPlayerState(playerid) == 2)
    {
        if(IsPlayerInAnyVehicle(playerid)) {
            switch(playerVariables[playerid][pCarEngine]) {
                case 0: {
                    playerVariables[playerid][pCarEngine] = 1;
                    SetVehicleParamsEx(vehicleid,true,lights,alarm,doors,bonnet,boot,objective);
                    format(szMessage, sizeof(szMessage), "* %s has put his keys in the ignition, turning on the vehicle.", szPlayerName);
                    nearByMessage(playerid, COLOR_PURPLE, szMessage);
                }
                case 1: {
                    playerVariables[playerid][pCarEngine] = 0;
                    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//this will check that what is the state of engine.That is is on or off.We can use it for multiple things like doors,alarms etc.But In this case I am using this for the engine only.
                    SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
                    format(szMessage, sizeof(szMessage), "* %s has put his keys in the ignition, turning off the vehicle.", szPlayerName);
                    nearByMessage(playerid, COLOR_PURPLE, szMessage);
                }
            }
        }
    }
    return 1;
}



Re: /engine script - Swyft™ - 27.10.2012

It's all good, I actually used the search function on SA-MP and found a solution! Thanks for trying to help though!