[Help] Mathematical calculations, to calculate the time in prison. - 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: [Help] Mathematical calculations, to calculate the time in prison. (
/showthread.php?tid=75529)
[Help] Mathematical calculations, to calculate the time in prison. -
vinewood - 02.05.2009
Someone would have the calculation, to show the player the minutes or hours that he should stay in prison? sorry I am bad in mathematics. :P
Код:
if(strcmp(cmd, "/time", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new mtext[20];
new year, month,day;
getdate(year, month, day);
if(month == 1) { mtext = "January"; }
else if(month == 2) { mtext = "February"; }
else if(month == 3) { mtext = "March"; }
else if(month == 4) { mtext = "April"; }
else if(month == 5) { mtext = "May"; }
else if(month == 6) { mtext = "June"; }
else if(month == 7) { mtext = "Juli"; }
else if(month == 8) { mtext = "August"; }
else if(month == 9) { mtext = "September"; }
else if(month == 10) { mtext = "October"; }
else if(month == 11) { mtext = "November"; }
else if(month == 12) { mtext = "December"; }
new hour,minuite,second;
gettime(hour,minuite,second);
FixHour(hour);
hour = shifthour;
ApplyAnimation(playerid, "PLAYIDLES", "time", 8.0, 0, 0, 0, 0, 0);
if (minuite < 10)
{
if (PlayerInfo[playerid][pJailTime] > 0)
{
format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
}
else
{
format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:0%d~g~|", day, mtext, hour, minuite);
}
}
else
{
if (PlayerInfo[playerid][pJailTime] > 0)
{
format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|~n~~w~Jail Time Left: %d sec", day, mtext, hour, minuite, PlayerInfo[playerid][pJailTime]-10);
}
else
{
format(string, sizeof(string), "~y~%d %s~n~~g~|~w~%d:%d~g~|", day, mtext, hour, minuite);
}
}
ApplyAnimation(playerid, "COP_AMBIENT", "Coplook_watch", 4.000000, 0, 0, 0, 0, 0);
GameTextForPlayer(playerid, string, 5000, 1);
}
return 1;
}
Re: [Help] Mathematical calculations, to calculate the time in prison. -
yom - 02.05.2009
The easiest way is to convert the return value of gettime(); (in seconds) into seconds, minutes, etc.
pawn Код:
enum tc_method
{
tc_milliseconds,
tc_seconds,
tc_minutes
}
stock TimeConvert(time, &dd=0, &hh=0, &mm=0, &ss=0, &ms=0, tc_method:method=tc_seconds)
{
if (method == tc_milliseconds)
{
ms = time % 1000;
time = (time - ms)/1000;
ss = time % 60;
time = (time - ss)/60;
}
else if (method == tc_seconds)
{
ss = time % 60;
time = (time - ss)/60;
}
mm = time % 60;
time = (time - mm)/60;
hh = time % 24;
time = (time - hh)/24;
dd = time;
}
Re: [Help] Mathematical calculations, to calculate the time in prison. -
JaYmE - 02.05.2009
1) you are not sending the formated strings ?
use
pawn Код:
Send Client Message(...);
2) the answer to your question is use a enum
Example:
pawn Код:
enum pStuff
{
JailedTime,
BailTime
}
new PlayerStuff[MAX_PLAYERS][pStuff];
public CheckJailTime()
{
for ( new i = 0; i < MAX_PLAYERS; i++ )
{
if(IsPlayerConnected(i))
{
new Hour,
Min,
Sec;
GetTime(Hour, Min, Sec);
PlayerStuff[i][JailedTime] = Min;
if(PlayerStuff[i][JailedTime] >= PlayerStuff[i][BailTime])
{
ReleasePlayerFromJail(i);
}
PlayerStuff[i][JailedTime] = 0;
PlayerStuff[i][JailedTime] = 0;
}
}
return 1;
}
Remember this is just a example but if you study the code and adjust it you can make it work for you
Damn, beat me