SA-MP Forums Archive
Adding nitro by pressing KEY_FIRE - 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: Adding nitro by pressing KEY_FIRE (/showthread.php?tid=350477)



Adding nitro by pressing KEY_FIRE - x96664 - 12.06.2012

Hi guys! Can somebody help me to make when player press the firekey or LMB to add nitro to his car ?


Re: Adding nitro by pressing KEY_FIRE - Faisal_khan - 12.06.2012

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if (IsPlayerInAnyVehicle(playerid))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        }
    }
    return 1;
}



Re: Adding nitro by pressing KEY_FIRE - sniperwars - 12.06.2012

pawn Код:
forward InfiniteNitro();

public OnGameModeInit()
{
      SetTimer("InfiniteNitro", 1000, 1);
      return 1;
}

public InfiniteNitro()
{
      new vehicleid;
      for(new i=0;i<MAX_PLAYERS;i++)
      {
           if(IsPlayerConnected(i))
           {
                if(GetPlayerState(i)==2)
                {
                     vehicleid=GetPlayerVehicleID(i);
                     if(CheckVehicle(vehicleid))
                     AddVehicleComponent(vehicleid,1010);
                }
           }
      }
      return 1;
}            

stock CheckVehicle(vehicleid)
{
      #define MAX_INVALID_NOS_VEHICLES 13

      new InvalidNOSVehicles[MAX_INVALID_NOS_VEHICLES] =
      {
              522, 481, 441, 468, 448, 446, 513, 521, 510, 430, 520, 476, 463
      };

      for(new i = 0; i < MAX_INVALID_NOS_VEHICLES; i++)
      {
            if(GetVehicleModel(vehicleid) == InvalidNOSVehicles[i]) return false;
      }
      return true;
}



Re: Adding nitro by pressing KEY_FIRE - kaisersouse - 12.06.2012

You may want to use a key like SUBMISSION, because if you activate NOS w/ FIRE and FIRE also gives you NOS...you'll get a quick burst before NOS is reapplied (which resets the NOS process). Know what I mean?

On my server I set the SUBMISSION (the '2' key by default) key to give NOS and fix the car. Might be something to think about .


Re: Adding nitro by pressing KEY_FIRE - x96664 - 12.06.2012

Thanks for the help!


Re: Adding nitro by pressing KEY_FIRE - Jonny5 - 12.06.2012

Quote:
Originally Posted by kaisersouse
Посмотреть сообщение
You may want to use a key like SUBMISSION, because if you activate NOS w/ FIRE and FIRE also gives you NOS...you'll get a quick burst before NOS is reapplied (which resets the NOS process). Know what I mean?

On my server I set the SUBMISSION (the '2' key by default) key to give NOS and fix the car. Might be something to think about .
that or just if they are holding the fire key
attach nos

when they release remove it.


this is kinda how i do it on my server

pawn Код:
if (HOLDING(KEY_FIRE)){//add Nitro from vehicle
                if(GetVehicleComponentInSlot(GetPlayerVehicleID(playerid),GetVehicleComponentType(1010)) != 1010){
                AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);}
            }else if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)){//remove Nitro from vehicle
                if(GetVehicleComponentInSlot(GetPlayerVehicleID(playerid),GetVehicleComponentType(1010)) == 1010){
                RemoveVehicleComponent(GetPlayerVehicleID(playerid),1010);}
            }


i did this personally because i like to control the nos,
just another idea is all.