24.10.2017, 20:49
Hey To all,
How can i convert the time fom milliseconds to seconds or minutes?
How can i convert the time fom milliseconds to seconds or minutes?
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;
}
Hey To all,
How can i convert the time fom milliseconds to seconds or minutes? |
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; }
new h, m, s; ConvertMilliseconds(4126623, h, m, s); printf("12335454667 milliseconds: %d: %d: %d", h, m, s);
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.
|
SetTimerEx("unarrest",(1000*60)*minutes,false,"i",otherplayerid );
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; } |