Question
#1

Hello,

I just created a payday system for my server and I want to count the remaining time from the timer for example, Payday is sending each 1 hour if 30 mins have passed I want to print on stats that next payday is on 30 minutes or something like that, is that possible or not? I tried some codes with GetTickCount but didn't work
Reply
#2

Well, you could set a timer of 30 minutes at first and when the 30 minutes passes, print that on stats and then make ANOTHER timer for 30 minutes.
Reply
#3

Quote:
Originally Posted by Karan007
Посмотреть сообщение
Well, you could set a timer of 30 minutes at first and when the 30 minutes passes, print that on stats and then make ANOTHER timer for 30 minutes.
You think that I don't know how to do something like this?

I want to count how much minutes left until payday will be arrived
Reply
#4

In the timer you could use the timer name and minus it. Then you could use the last timer as integer to format how much times left. If you didn't understand, below is an example.

PHP код:
new testtimer 60// Using the variable that shows 60 seconds
forward test(playerid); // timer
public test(playerid){
    
testtimer--; // Subtracting the timer
    
if(testtimer == 30) return SendClientMessageToAll(-1"30 secs left");  //Check if 30 secs left
    
return 1;} 
Reply
#5

It is possible.

On top of script/your enum for saving player data:
Код:
new User[MAX_PLAYERS][pMinutes];
new minute[MAX_PLAYERS];

forward Minute(playerid);
OnPlayerLogin/Spawn:
Код:
minute[playerid] = SetTimerEx("Minute", 60000, true, "i", playerid);
Wherever you put you custom callbacks:

Код:
public Minute(playerid)
{
       return User[playerid][pMinutes]++;
}
When you display stats and want to show how much the player has to wait for a payday:
Код:
new str[128];
format(str,sizeof(str),"Minutes left = %d",60-User[playerid][pMinutes]); // If payday is every hour = 60 minutes
SendClientMessage(playerid,-1,str);
OnPlayerDisconnect:

Код:
KillTimer(minute[playerid]);
Reply
#6

sorry for first nab code :c
PHP код:
new paydaytime[MAX_PLAYERS];
public 
OnPlayerConnect(playerid) {
   
paydaytime[playerid] = 3600;
   
SetTimerEx("payday",1000,1,"i",playerid);
   return 
1;
}
forward payday(playerid);
public 
payday(playerid) {
     if(
paydaytime[playerid] == 0) {
        
//code
        
paydaytime[playerid] = 3600;
     } else if(
paydaytime[playerid] == 1800)
       {
        
// message
     
} else
     {
      
paydaytime[playerid] --;
   }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)