Need New GameTimer - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need New GameTimer (
/showthread.php?tid=256539)
Need New GameTimer -
Admigo - 21.05.2011
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
Re: Need New GameTimer -
Sascha - 21.05.2011
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
Re: Need New GameTimer -
Admigo - 21.05.2011
Thanks for reply.But i dont see the time.
Re: Need New GameTimer -
Sascha - 21.05.2011
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;
}
Re: Need New GameTimer -
Admigo - 21.05.2011
Thansk dude but there is one problem.If you die the second tiemr goes to 00
Re: Need New GameTimer -
Sascha - 22.05.2011
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;
}
Re: Need New GameTimer -
Admigo - 22.05.2011
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.
Re: Need New GameTimer -
Admigo - 22.05.2011
I made the clock but only the clock spawns double when someone joins the game. How can i make just one textdraw?