Need New GameTimer
#1

Heey guys,
I need a new gametimer.1minute = 1hour.
My old one is bugged when someone dies the time goes to -:00
Pls give me a new gametimer.

Thanks admigo
Reply
#2

if you mean counting the time a player is connected / allive with gametimer then you can try out this:
pawn Код:
forward IncreaseTime(playerid);
new gametime[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    KillTimer(gametime[playerid]);
    gametime[playerid] = SetTimerEx("IncreaseTime", 1000, true, "i", playerid);
    SetToNull(playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SetToNull(playerid);
    KillTimer(gametime[playerid]);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    SetToNull(playerid);
    return 1;
}

public IncreaseTime(playerid)
{
    new h, m;
    GetPlayerTimeEx(playerid, h, m);
    m++;
    if(m == 60)
    {
        h++;
        m = 0;
    }
    SetPlayerTimeEx(playerid, h, m);
    return 1;
}

stock SetToNull(playerid)
{
    SetPlayerTimeEx(playerid, 0, 0);
    return 1;
}
stock SetPlayerTimeEx(playerid, hour, minute)
{
    SetPVarInt(playerid, "hours", hour);
    SetPVarInt(playerid, "minutes", minute);
    return 1;
}
stock GetPlayerTimeEx(playerid, &hour, &minute)
{
    hour = GetPVarInt(playerid, "hours");
    minute = GetPVarInt(playerid, "minutes");
    return 1;
}
(no clue if it works, not tested I just wrote it up)

edit: 1 minute shadows 1 second irl... 1 hour = 1 minute note: the minutes get reset when the hours increase
Reply
#3

Thanks for reply.But i dont see the time.
Reply
#4

what do you mean with "you don't see the time"?
tried it like this? :

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/gettime", cmdtext, true, 8) == 0)
  {
    new h, m;
    GetPlayerTimeEx(playerid, h, m);
    new string[20];
    format(string, sizeof(string), "%d:%d", h, m);
    SendClientMessage(playerid, 0x999999AA, string);
    return 1;
  }
  return 0;
}
Reply
#5

Thansk dude but there is one problem.If you die the second tiemr goes to 00
Reply
#6

ah lol I've read your first post wrong... I thought you wanted the timer to be reset if you die^^...
remove this part:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SetToNull(playerid);
    return 1;
}
Reply
#7

Quote:
Originally Posted by Sascha
Посмотреть сообщение
ah lol I've read your first post wrong... I thought you wanted the timer to be reset if you die^^...
remove this part:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SetToNull(playerid);
    return 1;
}
I want to make this into textdraw. Can u help me with that because if i do that the timer bugged.
Reply
#8

I made the clock but only the clock spawns double when someone joins the game. How can i make just one textdraw?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)