SA-MP Forums Archive
Problem with engine start - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with engine start (/showthread.php?tid=227882)



[SOLVED]Problem with engine start - Vukilore - 18.02.2011

Hi All
How are you ?
i have a problem with a command...
I would have a command than when we type /moteur, the engine of the vehicle go on, and when we retype /moteur, the engine go off...
I'm a beginner and i can't resolve this problem
(Sorry for my bad english, i'm french)

Code:
	
        if(strcmp("/moteur", cmdtext, true) == 0)
	{
	 if(IsPlayerInAnyVehicle(playerid))
	 {
	  new vid = GetPlayerVehicleID(playerid);
	  if(vid != INVALID_VEHICLE_ID)
	  {
	   GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	  if(engine == VEHICLE_PARAMS_ON)
          {
       	 GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
         SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
         PlayerPlaySound(playerid, 1022, 0.0, 0.0, 0.0);
         GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~y~Le moteur se ~r~ferme..", 3000, 3);
         }
	  if(engine == VEHICLE_PARAMS_OFF)
	  {
	   GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
           SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
           PlayerPlaySound(playerid, 1021, 0.0, 0.0, 0.0);
	   GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~y~Le moteur ~g~s'allume..", 3000, 3);
	  }
	  }
	  }
		return 1;
	}
Can you help me ? that's be cut thanks


Re: Problem with engine start - OKStyle - 18.02.2011

pawn Code:
if(!strcmp(cmdtext,"/moteur",true))
{
    GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == 1) SetVehicleParamsEx(GetPlayerVehicleID(playerid),0,lights,alarm,doors,bonnet,boot,objective);
    if(engine == 0) SetVehicleParamsEx(GetPlayerVehicleID(playerid),1,lights,alarm,doors,bonnet,boot,objective);
    return 1;
}



Re : Problem with engine start - Vukilore - 18.02.2011

Doesn't work....
thanks alot for your help.


Re: Problem with engine start - OKStyle - 18.02.2011

What precisely doesn't work? Some errors or warnings after compile?

You must add in top of the gamemode/script, not on command:
pawn Code:
new engine,lights,alarm,doors,bonnet,boot,objective;



Re: Problem with engine start - DRIFT_HUNTER - 18.02.2011

If you did not used SetVehicleParams than its -1 (unset) thats why it does not work


Re: Problem with engine start - MadeMan - 18.02.2011

pawn Code:
if(strcmp("/moteur", cmdtext, true) == 0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON)
        {
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            PlayerPlaySound(playerid, 1022, 0.0, 0.0, 0.0);
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~y~Le moteur se ~r~ferme..", 3000, 3);
        }
        else
        {
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
            PlayerPlaySound(playerid, 1021, 0.0, 0.0, 0.0);
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~y~Le moteur ~g~s'allume..", 3000, 3);
        }
    }
    return 1;
}



Re : Re: Problem with engine start - Vukilore - 19.02.2011

Quote:
Originally Posted by MadeMan
View Post
pawn Code:
if(strcmp("/moteur", cmdtext, true) == 0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new vid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == VEHICLE_PARAMS_ON)
        {
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            PlayerPlaySound(playerid, 1022, 0.0, 0.0, 0.0);
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~y~Le moteur se ~r~ferme..", 3000, 3);
        }
        else
        {
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
            PlayerPlaySound(playerid, 1021, 0.0, 0.0, 0.0);
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~y~Le moteur ~g~s'allume..", 3000, 3);
        }
    }
    return 1;
}

OH YEAH !, Greats thanks thats perfectly work ! Exactly same as I want!