Checking time left in settimerex.
#1

Hey guys so i try to check when someone in mute how much time he have to be unmuted
so this is what i done :
PHP код:
new TimeUnMute[MAX_PLAYERS];
TimeUnMute[playerid] = SetTimerEx("MuteEnd"30000false"dd"playerid);
if(
InMute[playerid] == 1) return SendFormatMessage(playeridred"You can talk more %d seconds",TimeUnMute[playerid]),0
And its dosent work, why?
Reply
#2

Use GetTickCount :When the Timer Begin and store it in a variable, and in OnPlayerText variable2 = variable - gettikecount
https://sampwiki.blast.hk/wiki/GetTickCount
Reply
#3

Quote:
Originally Posted by GeekSiMo
Посмотреть сообщение
Use GetTickCount :When the Timer Begin and store it in a variable, and in OnPlayerText variable2 = variable - gettikecount
https://sampwiki.blast.hk/wiki/GetTickCount
Dosent understand
Reply
#4

because TimeUnMute is only a handler (that's what SetTimerEx returs), not a some kind of counter.
pawn Код:
new TimeUnMute[MAX_PLAYERS]
       MuteStart[MAX_PLAYERS];

TimeUnMute[playerid] = SetTimerEx("MuteEnd", 30000, false, "dd", playerid);
MuteStart[playerid] = GetTickCount();

if(InMute[playerid] == 1) return SendFormatMessage(playerid, red, "You can talk more %d seconds",(GetTickCount()-MuteStart[playerid])/1000),0;
Reply
#5

Quote:
Originally Posted by Scottas
Посмотреть сообщение
because TimeUnMute is only a handler (that's what SetTimerEx returs), not a some kind of counter.
pawn Код:
new TimeUnMute[MAX_PLAYERS]
       MuteStart[MAX_PLAYERS];

TimeUnMute[playerid] = SetTimerEx("MuteEnd", 30000, false, "dd", playerid);
MuteStart[playerid] = GetTickCount();

if(InMute[playerid] == 1) return SendFormatMessage(playerid, red, "You can talk more %d seconds",(GetTickCount()-MuteStart[playerid])/1000),0;
Thanks !
Reply
#6

Quote:
Originally Posted by Scottas
Посмотреть сообщение
because TimeUnMute is only a handler (that's what SetTimerEx returs), not a some kind of counter.
pawn Код:
new TimeUnMute[MAX_PLAYERS]
       MuteStart[MAX_PLAYERS];

TimeUnMute[playerid] = SetTimerEx("MuteEnd", 30000, false, "dd", playerid);
MuteStart[playerid] = GetTickCount();

if(InMute[playerid] == 1) return SendFormatMessage(playerid, red, "You can talk more %d seconds",(GetTickCount()-MuteStart[playerid])/1000),0;
Still dont work.
Reply
#7

pawn Код:
new TimeUnMute[MAX_PLAYERS];

TimeUnMute[playerid] = gettime() + 30; // 30sec

if(TimeUnMute[playerid] > 0)
{
    new TimeToEnd = (TimeUnMute[playerid] - gettime());
    if(TimeToEnd > 0) return !SendFormatMessage(playerid, red, "You can talk more %d seconds",TimeToEnd);
    TimeUnMute[playerid] = 0;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)