SA-MP Forums Archive
ManualVehicleEngineAndLights(); - 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: ManualVehicleEngineAndLights(); (/showthread.php?tid=405497)



ManualVehicleEngineAndLights(); - AphexCCFC - 06.01.2013

Hello. I have this:

pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        Fuel[i] = 100;
        SetVehicleToRespawn(i);
        SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0);
    }
}
All the vehicles saved in the actual gamemode work, but the ones that are created when bought from a dealership or spawned work with the "ManualVehicleEngineAndLights();" function except when I type "/engine" it says the engine has been turned off, so gotta type /engine twice to turn it off and back on to be able to drive the vehicles.

Here's my /engine code.

pawn Код:
CMD:engine(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective, vehicleid, string[128];
    vehicleid = GetPlayerVehicleID(playerid);
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You need to login first before using any command.");
        return 1;
    }
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not driving a vehicle.");
        return 1;
    }
    if(IsAPushBike(vehicleid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: Bicycles have no engine.");
        return 1;
    }
    if(IsANormalCar(vehicleid))
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You don't have the keys for this vehicle.");
        return 1;
    }
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(engine == 0)
    {
        TextDrawShowForPlayer(playerid, EngineTD[playerid]);
        Enginez[playerid] = SetTimerEx("EngineTimer", 15000, false, "i", playerid);
    }
    else
    {
        SetVehicleParamsEx(vehicleid, 0, 0, 0, 0, bonnet, boot, 0);
        if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
        {SetVehicleParamsEx(vehicleid, 0, 0, alarm, PlayerInfo[playerid][vLocked], bonnet, boot, 0);}
        if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
        {SetVehicleParamsEx(vehicleid, 0, 0, alarm, PlayerInfo[playerid][vVLocked], bonnet, boot, 0);}
        format(string, sizeof(string), "* %s turns the vehicle engine off.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    }
    return 1;
}
I thought the "ManualVehicleEngineAndLights();" function disables the vehicles engines using "SetVehicleParamsEx"...
If anyone could help me with this I'll rep them because I have been stuck on this for a week now.


Re: ManualVehicleEngineAndLights(); - AphexCCFC - 07.01.2013

Can anyone help please?


Re: ManualVehicleEngineAndLights(); - JM_Millers - 07.01.2013

PHP код:
public OnVehicleSpawn(vehicleid)
{
    
SetVehicleParamsEx(vehicleid0000000);




Re: ManualVehicleEngineAndLights(); - Vince - 07.01.2013

Also check if engine is -1.