SA-MP Forums Archive
Timer shows only maximum 60:00 instead of full time - 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: Timer shows only maximum 60:00 instead of full time (/showthread.php?tid=658957)



Timer shows only maximum 60:00 instead of full time - Zeus666 - 17.09.2018

Hi. I have a timer set which shows when you enter in admin jail.

But the problem is that if I admin jail a player for 61 minutes, the countdown it shows for 60:00

If I admin jail a player for 300 minutes, countdown it shows for 60:00

can someone explain me why?


PHP код:
forward AjailCount(playerid);
public 
OnPlayerConnect(playerid)
playertimer[playerid] = SetTimerEx("AjailCount"1000true"i"playerid); 
PHP код:
public AjailCount(playerid)
{
    if(--
pInfo[playerid][pJailed] < 1)
    {
        
KillTimer(playertimer[playerid]);
        
SendClientMessage(playeridCOLOR_RED"Ai iesit din AdminJail..");
        
SetPlayerInterior(playerid0);//You can change interior
        
SetPlayerVirtualWorld(playerid0); //You can change virtual world
        
SetPlayerPos(playerid1529.6,-1691.2,13.3);
        
SaveStats(playerid);
    }
    else
    {
        new 
str[32];
        
format(str,sizeof(str),"%02d:%02d",((pInfo[playerid][pJailed]/60)%60),pInfo[playerid][pJailed]%60);
        if(!
GameTextForPlayer(playeridstr12005))
            
KillTimer(playertimer[playerid]);
    }
    return 
1;




Re: Timer shows only maximum 60:00 instead of full time - SaMuRy - 17.09.2018

Quote:

new str[32];
format(str,sizeof(str),"%02d:%02d",((pInfo[playerid][pJailed]/60)%60),pInfo[playerid][pJailed]%60);
if(!GameTextForPlayer(playerid, str, 1200, 5))
KillTimer(playertimer[playerid]);
}
return 1;
}

Create a stock for the timer


Re: Timer shows only maximum 60:00 instead of full time - Calisthenics - 17.09.2018

We do not know what value pJailed may have for the certain player, show how an admin jails the player.

You included OnPlayerConnect on your code, does this mean the repeated timer is set when a player connects and not in the jail command? As this would be a bad idea.


Re: Timer shows only maximum 60:00 instead of full time - Zeus666 - 17.09.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
We do not know what value pJailed may have for the certain player, show how an admin jails the player.

You included OnPlayerConnect on your code, does this mean the repeated timer is set when a player connects and not in the jail command? As this would be a bad idea.
PHP код:
JailPlayer(playeridtargetidtimereason[])
{
    new 
string[128], adminname[MAX_PLAYER_NAME 1], targetname[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridadminnameMAX_PLAYER_NAME);
    
GetPlayerName(targetidtargetnameMAX_PLAYER_NAME);
    
SetPlayerPos(targetid346.870025309.259033999.155700);
    
SetPlayerVirtualWorld(targetid2);
    
SetPlayerInterior(targetid,6);
    
ResetPlayerWeapons(targetid);
    
ResetPlayerInventory(targetid);
    
SendClientMessage(targetid,-1,"*"COL_RED" Inventariul tau a fost restat!");
    
pInfo[targetid][pJailed] = time 60;
    
format(stringsizeof(string), "theres some text"adminnametargetnametimereason);
    
SendClientMessageToAll(COLOR_REDstring);
    
KillTimer(playertimer[targetid]);
    
playertimer[targetid] = SetTimerEx("AjailCount"1000true"i"targetid);
    
SaveStats(targetid);

at onplayerconnect it just retakes the time left inside the admin jail


Re: Timer shows only maximum 60:00 instead of full time - Undef1ned - 17.09.2018

PHP код:
format(str,sizeof(str),"%d:%02d",pInfo[playerid][pJailed] / 60pInfo[playerid][pJailed] % 60); 



Re: Timer shows only maximum 60:00 instead of full time - Zeus666 - 17.09.2018

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
PHP код:
format(str,sizeof(str),"%d:%02d",((pInfo[playerid][pJailed]/60)%60),pInfo[playerid][pJailed]%60); 
Still the same. Ajailed myself for 300 minutes, timer shows 60:00


Re: Timer shows only maximum 60:00 instead of full time - Undef1ned - 17.09.2018

PHP код:
format(strsizeof(str), "%s"TimeConvert(pInfo[playerid][pJailed]));  
stock TimeConvert(seconds)
{
    new 
tmp[16];
     new 
minutes floatround(seconds/60);
      
seconds -= minutes*60;
       
format(tmpsizeof(tmp), "%d:%02d"minutesseconds);
       return 
tmp;




Re: Timer shows only maximum 60:00 instead of full time - Zeus666 - 17.09.2018

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
PHP код:
format(strsizeof(str), "%s"TimeConvert(pInfo[playerid][pJailed]));  
stock TimeConvert(seconds)
{
    new 
tmp[16];
     new 
minutes floatround(seconds/60);
      
seconds -= minutes*60;
       
format(tmpsizeof(tmp), "%d:%02d"minutesseconds);
       return 
tmp;

If I already have this, it won't disturb it, no?

PHP код:
TimeConvert(time)
{
    new 
minutes;
    new 
seconds;
    new 
string[128];
    if(
time 59){
        
minutes floatround(time/60);
        
seconds floatround(time minutes*60);
        if(
seconds>9)format(string,sizeof(string),"%d:%d",minutes,seconds);
        else 
format(string,sizeof(string),"%d:0%d",minutes,seconds);
    }
    else{
        
seconds floatround(time);
        if(
seconds>9)format(string,sizeof(string),"0:%d",seconds);
        else 
format(string,sizeof(string),"0:0%d",seconds);
    }
    return 
string;




Re: Timer shows only maximum 60:00 instead of full time - Undef1ned - 17.09.2018

Well, replace the one you already have with the one that just happened to you.


Re: Timer shows only maximum 60:00 instead of full time - Zeus666 - 17.09.2018

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
Well, replace the one you already have with the one that just happened to you.
Many thanks. +rep