OnPlayerKeyStateChange
#1

Hey guys. Can someone show me how can i turn on nitro on car with Alt Key?/ I allrady have /nitro and when i press left click after typing command it will turn on. Can someone show me how can i turn it on without typing. Just by pressing Left Alt??
Reply
#2

PHP код:
// Top of your script
    #define     PRESSED(%0) \
                    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
// under OnPlayerKey...
if(PRESSED(KEY_FIRE))
{
// Your code ... 

Reply
#3

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

Keys don't have static values or assigns, they are depending on what user have set it to in "Control Settings".

>> You cannot use LALT (KEY_WALK) in vehicles.
Reply
#4

PHP код:
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys) {
    if(
PRESSED(KEY_FIRE)) {
        
// do stuff
    
}
    return 
1;

Reply
#5

Mine is when you press the key (left click and W (acceleration), you get a boost or nitro.
PHP код:
    if((newkeys KEY_FIRE) && (oldkeys KEY_SPRINT) && IsPlayerInAnyVehicle(playerid)) // Speed x2 - W + LEFT CLICK 
    
{
         new 
Float:xFloat:yFloat:z;
        
GetVehicleVelocity(GetPlayerVehicleID(playerid), xyz);
        
SetVehicleVelocity(GetPlayerVehicleID(playerid), x*2y*2z);
        return 
1;
    }
    if((
newkeys KEY_FIRE) && IsPlayerInAnyVehicle(playerid)) // Infinite nitro by pressing LEFT CLICK ONLY
    
{
        
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        return 
1;
    } 
There is an exemple.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)