Time convert -
ImTobi - 24.10.2017
Hey To all,
How can i convert the time fom milliseconds to seconds or minutes?
Re: Time convert -
CodeStyle175 - 24.10.2017
PHP код:
MSToMinAndSec(ms){
new s[30],sec=floatround(ms/1000),min=floatround(sec/60);
format(s,sizeof(s),"%02d:%02d",min,floatround(sec - min*60));
return s;
}
Re: Time convert -
ImTobi - 24.10.2017
i mean like, i have a command to jail someone, but i must give the time in milliseconds
Re: Time convert -
kingmk - 24.10.2017
Quote:
Originally Posted by ImTobi
Hey To all,
How can i convert the time fom milliseconds to seconds or minutes?
|
1 millisecond = 0.001 seconds
Try this function.
Код:
forward ConvertMilliseconds(millisecond, &hours, &minutes, &seconds)
public ConvertMilliseconds(millisecond, &hours, &minutes, &seconds)
{
if (millisecond < 0) return false;
sec = millisecond / 1000;
minutes = secs / 60; seconds = secs % 60;
hours = minutes / 60; minutes = minutes % 60;
return true;
}
How to use?
Код:
new h, m, s;
ConvertMilliseconds(4126623, h, m, s);
printf("12335454667 milliseconds: %d: %d: %d", h, m, s);
Re: Time convert -
ImTobi - 24.10.2017
here's the whole command
CMD:arrest(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,5,1525.4839,-1677.7625,5.8906))return SendClientMessage(playerid,adminrot,"Du bist nicht am Arrest Punkt.");
new otherplayerid, grund[128], Zeit;
if(sscanf(params, "uis[128]",otherplayerid,Zeit,grund))return SendClientMessage(playerid,adminrot,"INFO: /arrest [id][Zeit in Millisekunden][grund]");
if(GetPlayerWantedLevel(otherplayerid) == 0)
{
SendClientMessage(playerid,adminrot,"Der Spieler hat keine Wanteds.");
return 1;
}
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid,rot,"Der Spieler ist nicht online!");
return 1;
}
else
{
SetPlayerPos(otherplayerid,263.8904,77.4725,1001.0 391);
SetPlayerInterior(otherplayerid, 6);
sInfo[playerid][payday] += 1500;
SetPlayerWantedLevel(otherplayerid,0);
SetTimerEx("unarrest",Zeit,false,"i",otherplayerid );
for(new i=0; i<MAX_PLAYERS; i++)
if(isPlayerInFrakt(i, 2))
{
if(onlspdduty[playerid] == false)return SCM(playerid,adminrot,"Du bist nicht im Dienst.");
new string[128];
format(string,sizeof(string),"HQ: Der Spieler %s[%i] wurde festgenommen. Grund: %s",sInfo[otherplayerid][rpname],otherplayerid,grund);
SendClientMessage(i,hqinfo,string);
}
}
return 1;
}
Re: Time convert -
kingmk - 24.10.2017
Quote:
Originally Posted by ImTobi
here's the whole command
CMD:arrest(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,5,1525.4839,-1677.7625,5.8906))return SendClientMessage(playerid,adminrot,"Du bist nicht am Arrest Punkt.");
new otherplayerid, grund[128], Zeit;
if(sscanf(params, "uis[128]",otherplayerid,Zeit,grund))return SendClientMessage(playerid,adminrot,"INFO: /arrest [id][Zeit in Millisekunden][grund]");
if(GetPlayerWantedLevel(otherplayerid) == 0)
{
SendClientMessage(playerid,adminrot,"Der Spieler hat keine Wanteds.");
return 1;
}
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid,rot,"Der Spieler ist nicht online!");
return 1;
}
else
{
SetPlayerPos(otherplayerid,263.8904,77.4725,1001.0 391);
SetPlayerInterior(otherplayerid, 6);
sInfo[playerid][payday] += 1500;
SetPlayerWantedLevel(otherplayerid,0);
SetTimerEx("unarrest",Zeit,false,"i",otherplayerid );
for(new i=0; i<MAX_PLAYERS; i++)
if(isPlayerInFrakt(i, 2))
{
if(onlspdduty[playerid] == false)return SCM(playerid,adminrot,"Du bist nicht im Dienst.");
new string[128];
format(string,sizeof(string),"HQ: Der Spieler %s[%i] wurde festgenommen. Grund: %s",sInfo[otherplayerid][rpname],otherplayerid,grund);
SendClientMessage(i,hqinfo,string);
}
}
return 1;
}
|
I recommend u to use english when u codding, cuz i don't undestood your scripts.
Re: Time convert -
ImTobi - 24.10.2017
Quote:
Originally Posted by kingmk
I recommend u to use english when u codding, cuz i don't undestood your scripts.
|
CMD:arrest(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,5,1525.4839,-1677.7625,5.8906))return SendClientMessage(playerid,adminrot,"You are not at the arrest Point.");
new otherplayerid, reason[128], Time;
if(sscanf(params, "uis[128]",otherplayerid,Time,reason))return SendClientMessage(playerid,adminrot,"INFO: /arrest [id][Time][Reason]");
if(GetPlayerWantedLevel(otherplayerid) == 0)
{
SendClientMessage(playerid,adminrot,"The Player doesn't have wanteds.");
return 1;
}
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid,rot,"The Player isn't online!");
return 1;
}
else
{
SetPlayerPos(otherplayerid,263.8904,77.4725,1001.0 391);
SetPlayerInterior(otherplayerid, 6);
sInfo[playerid][payday] += 1500;
SetPlayerWantedLevel(otherplayerid,0);
SetTimerEx("unarrest",Time,false,"i",otherplayerid );
for(new i=0; i<MAX_PLAYERS; i++)
if(isPlayerInFrakt(i, 2))
{
if(onlspdduty[playerid] == false)return SCM(playerid,adminrot,"You are not on duty.");
new string[128];
format(string,sizeof(string),"HQ: The Player %s[%i] got arrested. Reason: %s",sInfo[otherplayerid][rpname],otherplayerid,Reason);
SendClientMessage(i,hqinfo,string);
}
}
return 1;
}
Re: Time convert -
CodeStyle175 - 24.10.2017
are you stupid?
Re: Time convert -
Danisoni - 24.10.2017
1000 ms is 1 second, so you can easily calculate.
*** edit - here is calculation in minutes
Код:
SetTimerEx("unarrest",(1000*60)*minutes,false,"i",otherplayerid );
Re: Time convert -
NeewFooX - 25.10.2017
Quote:
Originally Posted by ImTobi
CMD:arrest(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,5,1525.4839,-1677.7625,5.8906))return SendClientMessage(playerid,adminrot,"You are not at the arrest Point.");
new otherplayerid, reason[128], Time;
if(sscanf(params, "uis[128]",otherplayerid,Time,reason))return SendClientMessage(playerid,adminrot,"INFO: /arrest [id][Time][Reason]");
if(GetPlayerWantedLevel(otherplayerid) == 0)
{
SendClientMessage(playerid,adminrot,"The Player doesn't have wanteds.");
return 1;
}
if(!IsPlayerConnected(otherplayerid))
{
SendClientMessage(playerid,rot,"The Player isn't online!");
return 1;
}
else
{
SetPlayerPos(otherplayerid,263.8904,77.4725,1001.0 391);
SetPlayerInterior(otherplayerid, 6);
sInfo[playerid][payday] += 1500;
SetPlayerWantedLevel(otherplayerid,0);
SetTimerEx("unarrest",Time,false,"i",otherplayerid );
for(new i=0; i<MAX_PLAYERS; i++)
if(isPlayerInFrakt(i, 2))
{
if(onlspdduty[playerid] == false)return SCM(playerid,adminrot,"You are not on duty.");
new string[128];
format(string,sizeof(string),"HQ: The Player %s[%i] got arrested. Reason: %s",sInfo[otherplayerid][rpname],otherplayerid,Reason);
SendClientMessage(i,hqinfo,string);
}
}
return 1;
}
|
yes ...