SA-MP Forums Archive
[help] 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: [help] engine (/showthread.php?tid=600409)



[help] engine - ratxrat - 07.02.2016

how to set the engine off when the first ride??
im use
PHP код:
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new 
vid;
    
vid GetPlayerVehicleID(playerid);
    
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    
SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
    return 
1
but still on


Re: [help] engine - mirou123 - 07.02.2016

Is your code in OnPlayerEnterVehicle? If it is then change it to OnPlayerStateChange because OnPlayerEnterVehicle is called BEFORE the player enters. Which means the GetPlayerVehicleID(playerid) will return an invalid vehicle ID.


Re: [help] engine - ratxrat - 07.02.2016

oke thanks i will try put at OnPlayerStateChange


Re: [help] engine - mirou123 - 07.02.2016

Here is a list of available states if you need it.


Re: [help] engine - Joron - 07.02.2016

Quote:
Originally Posted by ratxrat
Посмотреть сообщение
how to set the engine off when the first ride??
im use
PHP код:
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new 
vid;
    
vid GetPlayerVehicleID(playerid);
    
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    
SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
    return 
1
but still on
Whats the problem i dont understand what your tryna say?


Re: [help] engine - mirou123 - 07.02.2016

Quote:
Originally Posted by Joron
Посмотреть сообщение
Whats the problem i dont understand what your tryna say?
He is saying that he wants to turn the engine of the vehicle off but that code is not working the engine doesn't stop.


Re: [help] engine - ratxrat - 07.02.2016

now working just put code to OnPlayerStateChange . sorry for my bad english ☺


Re: [help] engine - Joron - 07.02.2016

Quote:

CMD:engine(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You need to be the driver of the vehicle");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
if(engine == 1)
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_COOLBLUE, "You have turned the engine on");
}
else
{
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_COOLBLUE, "You have turned the engine off");
}
return 1;
}

Heres an Engine Command


Re: [help] engine - ratxrat - 07.02.2016

Quote:
Originally Posted by Joron
Посмотреть сообщение
Heres an Engine Command
i already use the command like this
PHP код:
CMD:mesin(playeridparams[])
{
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
Engine[vehicleid] == 0)
        {
        new 
engine,lights,alarm,doors,bonnet,boot,objective;
        new 
vid;
        
vid GetPlayerVehicleID(playerid);
        
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        
SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
        
SendClientMessage(playeridCOLOR_GREEN"Engine Starting...");
        
SetTimerEx("EngineTimer"20000"i"playerid);
        }
        else if(
Engine[vehicleid] == 1)
        {
        
Engine[vehicleid] = 0;
        new 
engine,lights,alarm,doors,bonnet,boot,objective;
        new 
vid;
        
vid GetPlayerVehicleID(playerid);
        
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        
SetVehicleParamsEx(vid,0,lights,alarm,doors,bonnet,boot,objective);
        
SendClientMessage(playeridCOLOR_RED"Mesin di matikan...");
        
        
TogglePlayerControllable(playerid,0);
        }
        return 
1
same like your code


Re: [help] engine - mirou123 - 07.02.2016

Quote:
Originally Posted by ratxrat
Посмотреть сообщение
now working just put code to OnPlayerStateChange . sorry for my bad english ☺
Glad I helped.