SA-MP Forums Archive
Help pls!!! - 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: Help pls!!! (/showthread.php?tid=256980)



Help pls!!! - Cjgogo - 23.05.2011

I need help makinga toggle engine system,I saw another forum a High-Roller was saying something about gEngine and another something about ToggleEngine,so I need help if you could tell me some basics ideas what's the best way to do it(NOT THE WHOLE SCRIPT I like scripting things by myself just give me a few idnications)


Re: Help pls!!! - [DM]Kane - 23.05.2011

This might help:
https://sampwiki.blast.hk/wiki/GetVehicleParamsEx

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx


Re: Help pls!!! - Cjgogo - 23.05.2011

for example what's worng in this script?

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,0);
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid=GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
       SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,0);
       SendClientMessage(playerid,COLOR_PURPLE,"Press 2 to toggle engine");
    }
    return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SUBMISSION && IsPlayerInAnyVehicle(playerid))
    {
      new vehicleid=GetPlayerVehicleID(playerid);
      new Engine[MAX_VEHICLES];
      if(Engine[vehicleid] == 0)
      {
         SetVehicleParamsEx(vehicleid,1,0,0,0,0,0,0);
         SendClientMessage(playerid,COLOR_GREEN,"The engine is turned on");
      }
      else if(Engine[vehicleid] == 1)
      {
        SetVehicleParamsEx(vehicleid,0,0,0,0,0,0,0);
        SendClientMessage(playerid,COLOR_GREY,"The engine is turned off");
      }
    }
    return 1;
}
The only error is that it doesn't turn the engine off only on


Re: Help pls!!! - [DM]Kane - 23.05.2011

Use GetVehicleParamsEx first to get the current state of vehicle. and then Use SetVehicleParamsEx to set.
And yeah, you are using "SetVehicleParamsEx(vehicleid, 0, 0, ..)"
instead of 0, use VEHICLE_PARAMS_OFF and for 1 use VEHICLE_PARAMS_ON.


Re: Help pls!!! - Cjgogo - 23.05.2011

One word for you: THANKS(now is working as it should,I tried to use before a Toggle engine command but it was crap and buggy this is working perfectly with GetVehicleParams)


Re: Help pls!!! - [DM]Kane - 23.05.2011

No problem man, good luck with scripting