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



Car Engine - RoX123 - 12.01.2018

Hello,

I have one older Car Engine System,
Its alredy maked that i can turn on car with command /engine or button,
But when i press F and come in to car he automaticly put engine on (( I cant drive it, its only Engine on ))

So i want make that when i write /engine turning engine on, without that if i sit in car engine automaticly on,

What is function for car engine on/off,

PS sorry for my bad english


Re: Car Engine - RogueDrifter - 12.01.2018

at OnFilterScriptInit or OnGameModeInit put this ManualVehicleEngineAndLights();


Re: Car Engine - RoX123 - 12.01.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
at OnFilterScriptInit or OnGameModeInit put this ManualVehicleEngineAndLights();
It works, but now when i try to turn it on, hes not start hehe


Re: Car Engine - jasperschellekens - 12.01.2018

Quote:
Originally Posted by RoX123
Посмотреть сообщение
It works, but now when i try to turn it on, hes not start hehe
I use this one, you might want to edit it but works fine.

PHP код:
CMD:engine(playerid,params[])
{
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return ShowErrorDialog(playerid"You are not driving a vehicle");
    new 
vehicleid=GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective;
    new 
Float:health;
    
GetVehicleHealth(vehicleid,health);
    
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(
Fuel[vehicleid] <= 0) return ShowErrorDialog(playerid"This vehicle is out of fuel!");
    if(
health <= 650) return ShowErrorDialog(playerid"The car does not start anymore!");
    new 
Float:xFloat:yFloat:zname[MAX_PLAYER_NAME], string[100];
    
GetPlayerName(playeridnamesizeof(name));
    
GetPlayerPos(playeridxyz);
    for(new 
i=0i<GetMaxPlayers(); i++)
    {
        if(
IsPlayerInRangeOfPoint(i20.00xyz)) 
        {
            if(
engine == 1)
            {
                
SetVehicleParamsEx(vehicleid,0,0,alarm,doors,bonnet,boot,objective);
                if(
Gender[playerid] == 1)
                {
                    
format(string,sizeof(string),"%s(%i) switches the engine of his %s off.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
                    
SendClientMessage(iORANGEstring);
                }
                else if(
Gender[playerid] == 2)
                { 
                    
format(string,sizeof(string),"%s(%i) switches the engine of her %s off.",PlayerName(playerid),playerid);
                    
SendClientMessage(iORANGEstring);
                }
            }
            else
            {
                
SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
                if(
Gender[playerid] == 1)
                {
                    
format(string,sizeof(string),"%s(%i) switches the engine of his %s on.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
                    
SendClientMessage(iORANGEstring);
                }
                else if(
Gender[playerid] == 2)
                {
                    
format(string,sizeof(string),"%s(%i) switches the engine of her %s on.",PlayerName(playerid),playerid,VehicleNames[GetVehicleModel(vehicleid)-400]);
                    
SendClientMessage(iORANGEstring);
                }
            }
        }
    }
    return 
1;