weapon hold breath help??
#1

im pretty new to scripting but im trying to make it so you can hold your breath while aiming using space and aim button

Код:
else if(newkeys & KEY_SPRINT && newkeys & KEY_AIM && weaponAttached[playerid] == 0)
		{
			if(BreatheTime[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You need to wait before holding your breathe again!");
			SetPlayerDrunkLevel(playerid, 0);
  			BreatheTimer[playerid] = SetTimerEx("BreathTime", 10000, false, "d", playerid);
            PlayerPlaySound(playerid, 165, 0.0, 0.0, 10.0);
			BreatheTime[playerid] = 1;
			return 1;
					
		}




forward BreathTime(playerid);
public BreathTime(playerid)
{
	BreatheTime[playerid] = 0;
    SendClientMessage(playerid, 0x42CC33C8, "You can hold your breath again!");
    return 1;
}
i didnt really follow any tutorials just started it, can anyone help tho?
Reply
#2

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

if(PRESSED(KEY_SPRINT) && PRESSED(KEY_AIM) && weaponAttached[playerid] == 0)
{
    if(BreatheTime[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You need to wait before holding your breathe again!");
    SetPlayerDrunkLevel(playerid, 0);
    BreatheTimer[playerid] = SetTimerEx("BreathTime", 10000, false, "d", playerid);
    PlayerPlaySound(playerid, 165, 0.0, 0.0, 10.0);
    BreatheTime[playerid] = 1;
}

forward BreathTime(playerid);
public BreathTime(playerid)
{
    BreatheTime[playerid] = 0;
    SendClientMessage(playerid, 0x42CC33C8, "You can hold your breath again!");
    return 1;
}
I didn't test it, but you can try that.
Reply
#3

nah that didnt really work, for it to work i had to press them at the same exact time.

but u kind of helped me, i used this now

Код:
if(HOLDING(KEY_SPRINT) && weaponAttached[playerid] == 0)
		{
			if(IsPlayerAiming(playerid))
Reply
#4

Quote:
Originally Posted by Trucido
Посмотреть сообщение
nah that didnt really work, for it to work i had to press them at the same exact time.

but u kind of helped me, i used this now

Код:
if(HOLDING(KEY_SPRINT) && weaponAttached[playerid] == 0)
		{
			if(IsPlayerAiming(playerid))
Glad to have helped you somehow :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)