StopTimerEx - help!!
#1

how to stop a TimerEx. i have a code as below
pawn Код:
forward dance1(playerid);
forward dance2(playerid);
forward dance3(playerid);
forward dance4(playerid);
forward dance5(playerid);
forward dance6(playerid);
forward dance7(playerid);
forward dance8(playerid);
forward dance9(playerid);
forward dance10(playerid);
CMD:dance(playerid, params[])
{
#pragma unused params
ApplyAnimation( playerid, "DANCING" , "DANCE_LOOP" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
SetTimerEx("dance1", 2000, false, "d", playerid);
SetTimerEx("dance2", 4000, false, "d", playerid);
SetTimerEx("dance3", 6000, false, "d", playerid);
SetTimerEx("dance4", 8000, false, "d", playerid);
SetTimerEx("dance5", 10000, false, "d", playerid);
SetTimerEx("dance6", 12000, false, "d", playerid);
SetTimerEx("dance7", 14000, false, "d", playerid);
SetTimerEx("dance8", 16000, false, "d", playerid);
SetTimerEx("dance9", 18000, false, "d", playerid);
SetTimerEx("dance10", 20000, false, "d", playerid);
return 1;
}
public dance1(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DAN_DOWN_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance2(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DAN_LEFT_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance3(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DAN_LOOP_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance4(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DAN_RIGHT_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance5(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DAN_UP_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance6(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DNCE_M_A" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance7(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DNCE_M_B" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance8(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DNCE_M_C" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance9(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DNCE_M_D" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
public dance10(playerid)
{
ApplyAnimation( playerid, "DANCING" , "DNCE_M_E" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
}
i want to stop these TimerEx when pressing the enter button
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SECONDARY_ATTACK)
    {
 //what should be here???
        return 1;
    }
Reply
#2

Код:
new timer1 = SetTimerEx("dance1", 2000, false, "d", playerid);
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SECONDARY_ATTACK)
 	{
KillTimer(timer1);
		return 1;
	}
Reply
#3

Quote:
Originally Posted by Roel
Посмотреть сообщение
Код:
new timer1 = SetTimerEx("dance1", 2000, false, "d", playerid);
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_SECONDARY_ATTACK)
 	{
KillTimer(timer1);
		return 1;
	}
so what i should do here??
pawn Код:
CMD:dance(playerid, params[])
{
#pragma unused params
ApplyAnimation( playerid, "DANCING" , "DANCE_LOOP" , 2.0 , 0 , 1 , 1 , 0 , 2000 , 1);
SetTimerEx("dance1", 2000, false, "d", playerid);
SetTimerEx("dance2", 4000, false, "d", playerid);
SetTimerEx("dance3", 6000, false, "d", playerid);
SetTimerEx("dance4", 8000, false, "d", playerid);
SetTimerEx("dance5", 10000, false, "d", playerid);
SetTimerEx("dance6", 12000, false, "d", playerid);
SetTimerEx("dance7", 14000, false, "d", playerid);
SetTimerEx("dance8", 16000, false, "d", playerid);
SetTimerEx("dance9", 18000, false, "d", playerid);
SetTimerEx("dance10", 20000, false, "d", playerid);
return 1;
}
Reply
#4

Код:
	new DanceTimers[10];
	DanceTimers[0] = SetTimerEx("dance1", 2000, false, "d", playerid);
	DanceTimers[1] = SetTimerEx("dance2", 4000, false, "d", playerid);
	DanceTimers[2] = SetTimerEx("dance3", 6000, false, "d", playerid);
	DanceTimers[3] = SetTimerEx("dance4", 8000, false, "d", playerid);
	DanceTimers[4] = SetTimerEx("dance5", 10000, false, "d", playerid);
	DanceTimers[5] = SetTimerEx("dance6", 12000, false, "d", playerid);
	DanceTimers[6] = SetTimerEx("dance7", 14000, false, "d", playerid);
	DanceTimers[7] = SetTimerEx("dance8", 16000, false, "d", playerid);
	DanceTimers[8] = SetTimerEx("dance9", 18000, false, "d", playerid);
	DanceTimers[9] = SetTimerEx("dance10", 20000, false, "d", playerid);

// put this in your OnPlayerKeyStateChange:

    for (new All=0; All<sizeof(DanceTimers); All++) KillTimer(DanceTimers[All]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)