SA-MP Forums Archive
SpeedBoost Wrong? - 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: SpeedBoost Wrong? (/showthread.php?tid=547237)



SpeedBoost Wrong? - UltraScripter - 21.11.2014

Hi Guys I Made A Speed Boost Command But It Don't Work When i press 'w'

Code:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_FIRE)
    {
       new Car, Float:x, Float:y, Float:z;
       Car = GetPlayerVehicleID(playerid);
       if(IsPlayerInAnyVehicle(playerid))
       {
          GetVehicleVelocity(Car, x, y, z);
          SetVehicleVelocity(Car, x*1.5, y*1.5, z*1.5);
       }
    }
    return 1;
}
Thx For Helping !.


Re: SpeedBoost Wrong? - HY - 21.11.2014

I didn't understand. You press W, and isn't working. Actually here in this code you writed KEY_FIRE, LMB Button (Left Mouse Button). You still change it to :

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_UP)
    {
       new Car, Float:x, Float:y, Float:z;
       Car = GetPlayerVehicleID(playerid);
       if(IsPlayerInAnyVehicle(playerid))
       {
          GetVehicleVelocity(Car, x, y, z);
          SetVehicleVelocity(Car, x*1.5, y*1.5, z*1.5);
       }
    }
    return 1;
}



Re: SpeedBoost Wrong? - UltraScripter - 21.11.2014

no i meant if i press lmb
and i keep vehicle drive 'w' the speedboost dont work
sorry for my bad english hope u understand


Re : SpeedBoost Wrong? - Dutheil - 21.11.2014

pawn Код:
// PRESSED(keys)
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_UP))
    {
       if(IsPlayerInAnyVehicle(playerid))
       {
            new Car, Float:x, Float:y, Float:z;
            Car = GetPlayerVehicleID(playerid);
            GetVehicleVelocity(Car, x, y, z);
            SetVehicleVelocity(Car, x*1.5, y*1.5, z*1.5);
       }
    }
    return 1;
}



Re: SpeedBoost Wrong? - UltraScripter - 21.11.2014

thank you very much! !.