Help pls!!!
#1

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)
Reply
#2

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

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
Reply
#3

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
Reply
#4

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.
Reply
#5

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)
Reply
#6

No problem man, good luck with scripting
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)