Detecting if player click a key.
#2

You will be using the bit-wise AND check. I would go into detail why, but it explains thoroughly on the wiki. Take a look at this page: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange

Also, to check if the player clicked the right mouse button (which would be fire button), you can use the KEY_FIRE definition.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{    
   if (newkeys & KEY_FIRE)    
   {        
      new vehid = GetPlayerVehicleID(playerid);        
      if(IsPlayerInAnyVehicle(playerid))        
      {            
         if (turbo == 1)            
         {                
            new Float:Velocity[3];                
            GetVehicleVelocity(vehid, Velocity[0], Velocity[1], Velocity[2]);                
            if(Velocity[0] < maxspeed  && Velocity[1] < maxspeed && Velocity[0] > -maxspeed && Velocity[1] > -maxspeed)                
            {                    
               SetVehicleVelocity(vehid, Velocity[0]*speed, Velocity[1]*speed, 0.0);                
            }            
         }        
      }    
   }    
   return 1;
}
Reply


Messages In This Thread
Detecting if player click a key. - by Madsen - 03.07.2011, 19:30
Re: Detecting if player click a key. - by Bakr - 03.07.2011, 19:31
Re: Detecting if player click a key. - by Madsen - 03.07.2011, 19:34
Re: Detecting if player click a key. - by Vince - 03.07.2011, 19:36
Re: Detecting if player click a key. - by Bakr - 03.07.2011, 19:37
Re: Detecting if player click a key. - by MadeMan - 03.07.2011, 19:56
Re: Detecting if player click a key. - by Bakr - 03.07.2011, 20:00
Re: Detecting if player click a key. - by Madsen - 03.07.2011, 21:41

Forum Jump:


Users browsing this thread: 1 Guest(s)