SA-MP Forums Archive
Nitro when press on LMB. Rep + - 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: Nitro when press on LMB. Rep + (/showthread.php?tid=336977)



Nitro when press on LMB. Rep + - Karl[NDZ] - 24.04.2012

Hey im making a drift server and I want to have so when you click on LMB you get nitro but when you release LMB it goes away.


Re: Nitro when press on LMB. Rep + - kizla - 24.04.2012

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

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



Re: Nitro when press on LMB. Rep + - 2KY - 24.04.2012

https://sampforum.blast.hk/showthread.php?tid=311714


Re: Nitro when press on LMB. Rep + - Karl[NDZ] - 24.04.2012

Quote:
Originally Posted by kizla
Посмотреть сообщение
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if (IsPlayerInAnyVehicle(playerid))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        }
    }
    return 1;
}
That dont remove the nos when I release the key


Re: Nitro when press on LMB. Rep + - Karl[NDZ] - 24.04.2012

Quote:
Originally Posted by 2KY
Посмотреть сообщение
The same with this, I want so when I release the LMB the nitro turns deactivates.


Re: Nitro when press on LMB. Rep + - Karl[NDZ] - 24.04.2012

I fixed it now


Re: Nitro when press on LMB. Rep + - Tomer!.$ - 24.04.2012

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

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        if (IsPlayerInAnyVehicle(playerid))
        {
            new component = AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        }
    }
    if (RELEASED(KEY_FIRE))
    {
	if (IsPlayerInAnyVehicle(playerid))
	{
	    RemoveVehicleComponent(GetPlayerVehicleID(playerid), component);
	}
    }
    return 1;
}