Convert gettime() - 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)
+--- Thread: Convert gettime() (
/showthread.php?tid=617868)
Convert gettime() -
Mencent - 27.09.2016
Hello.
I have a little ask.
This is my Code:
PHP код:
Spieler[playerid][pClanSperre] = gettime() + (60 * 60 * 3);
It's added 3 hours to gettime() and save it in
pClanSperre.
Now I want to get the hours, minutes and seconds from now up to "pClanSperre".
Can you Show me how I have to "convert" it?
Example:
PHP код:
You have %d hours, %d minutes and %d seconds a ban.
Thanks!
Re: Convert gettime() -
Konstantinos - 27.09.2016
pawn Код:
new hours, minutes, seconds;
hours = Spieler[playerid][pClanSperre] / 3600;
minutes = (Spieler[playerid][pClanSperre] % 3600) / 60;
seconds = Spieler[playerid][pClanSperre] % 60;
Re: Convert gettime() -
Mencent - 27.09.2016
It don't work really.
The time doesn't expire. And I think, I have to write it like this to get the hour.
PHP код:
hours = (Spieler[playerid][pClanSperre]-gettime()) / 3600;
But the time doesn't expire.
Re: Convert gettime() -
Nero_3D - 27.09.2016
Than you are saying that gettime is broken?
The given code is fine, just try it again
PHP код:
new
seconds = Spieler[playerid][pClanSperre] - gettime(),
minutes = (seconds % 3600) / 60,
hours = seconds / 3600;
seconds %= 60;
Respuesta: Convert gettime() -
adri1 - 27.09.2016
PHP код:
stock TimeConvertEx(sec, &days, &hours, &minutes, &seconds)
{
days = floatround(sec / 86400);
hours = floatround((sec - (days * 86400)) / 3600);
minutes = floatround((sec - (days * 86400) - (hours * 3600)) / 60);
seconds = sec % 60;
return 1;
}
Example:
Ban 3 days:
PHP код:
PlayerInfo[playerid][TempBan] = (gettime() + (86400 * 3) ); //set
//Check if player is still banned
if(gettime() < PlayerInfo[playerid][TempBan])
{
new d, h, m, s;
TimeConvertEx ((PlayerInfo[playerid][TempBan] - gettime()) , d, h, m, s);
new str[64];
format(str, 64, "You will get unbanned in %d days, %d hours, %d minutes %02d seconds.", d, h, m, s);
SendClientMessage(playerid, -1, str);
Kick(playerid); // Use settimer if not message wont show
return 1;
}
Re: Convert gettime() -
PrO.GameR - 28.09.2016
You indeed need to use Spieler[playerid][pClanSperre]-gettime() with Konstantinos's code (everywhere it uses the array)
Other than that it'll work fine.
Re: Convert gettime() -
Mencent - 28.09.2016
Thanks for all replys.
The tip of PrO.GameR was helpful and now it works. Thanks!