17.08.2012, 10:16
@****** - Really?
Maybe you got some other way to do this..
@avivelkayam - It will be a Timer.. or maybe it can be possible by GetTickCount.. i'll see after MAYBE ****** reply.
pawn Код:
if(HOLDING(KEY_SPRINT))
{
if(!PlayerInfo[playerid][pSprintEnabled])
{
PlayerInfo[playerid][pSprintEnabled] = true;
KillTimer(PlayerInfo[playerid][pSprintTimer]);
PlayerInfo[playerid][pSprintTimer] = SetTimerEx("CountSprint", SECONDS(1), true, "d", playerid);
}
return true;
}
if(RELEASED(KEY_SPRINT))
{
if(PlayerInfo[playerid][pSprintEnabled])
{
if(PlayerInfo[playerid][pSprintCount] < MAX_SPRINT_DEFAULT_VALUE)
{
KillTimer(PlayerInfo[playerid][pSprintTimer]);
PlayerInfo[playerid][pSprintTimer] = SetTimerEx("CountSprint", SECONDS(1), true, "d", playerid);
}
PlayerInfo[playerid][pSprintEnabled] = false;
}
return true;
}
return true;
}
function CountSprint(playerid)
{
if(PlayerInfo[playerid][pSprintEnabled])
{
PlayerInfo[playerid][pSprintCount] -= 1;
if(PlayerInfo[playerid][pSprintCount] <= 0)
{
PlayerInfo[playerid][pSprintCount] = 0;
PlayerInfo[playerid][pSprintEnabled] = false;
ApplyAnimation(playerid, "FAT", "IDLE_tired", 4.1, 1, 1, 1, 0, 0, 1);
}
}
else if(!PlayerInfo[playerid][pSprintEnabled])
{
PlayerInfo[playerid][pSprintCount] += 1;
if(PlayerInfo[playerid][pSprintCount] >= MAX_SPRINT_DEFAULT_VALUE)
{
ClearAnimations(playerid);
PlayerInfo[playerid][pSprintCount] = MAX_SPRINT_DEFAULT_VALUE;
KillTimer(PlayerInfo[playerid][pSprintTimer]);
}
}
new string[64];
format(string, sizeof(string), "~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~w~Sprint count: %d/%d", PlayerInfo[playerid][pSprintCount], MAX_SPRINT_DEFAULT_VALUE);
GameTextForPlayer(playerid, string, SECONDS(1), 3);
return true;
}
@avivelkayam - It will be a Timer.. or maybe it can be possible by GetTickCount.. i'll see after MAYBE ****** reply.