saving timer
#1

hello guys
i need some help
i made robable timer
i want saving it with y_ini
and countdown when he is down the timer from his saving
PHP код:
new Robable=1;
forward RobTimer();
forward RobbingTimer(playerid);
public 
RobbingTimer(playerid)
{
    
Robable 1
    
SendClientMessage(playerid,0xFF0000"Sets the robbing variable to 1 so players can rob");
    return 
1;
}
SetTimer("RobTimer"400000false); 
its working good but need to saving the timer in enum and countdown when he is online the timer
Reply
#2

help please
Reply
#3

Can you repeat that in english?
Reply
#4

Quote:
Originally Posted by Runn3R
Посмотреть сообщение
Can you repeat that in english?
okay
i mean
Saving this timer if player not finished his countdown
PHP код:
SetTimer("RobTimer"400000false); 
get how much he is have to can use this cmds and saving the time and countdown in his saving when he is online
u know what i mean now!!
Reply
#5

Don't use the timer.

Create another entry in your enum and use the gettime() + 400 function to save the time plus your desired waiting time (400 in this case) when the player issues the command.

Before the command's functions, make a conditional statement to check if the variable of the player is equal or bigger than the actual gettime() and let the functions execute if the player complies with the requirements.

For saving it just do the same as other integer variables in your PlayerSave function.

The structure would look like this:

PHP код:
yourcommand
{
    
check if player variable is NOT over gettime(), then return something;
    
robbing functions;
    
set the player variable to gettime() + 400;
    return 
1;

Reply
#6

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Don't use the timer.

Create another entry in your enum and use the gettime() + 400 function to save the time plus your desired waiting time (400 in this case) when the player issues the command.

Before the command's functions, make a conditional statement to check if the variable of the player is equal or bigger than the actual gettime() and let the functions execute if the player complies with the requirements.

For saving it just do the same as other integer variables in your PlayerSave function.

The structure would look like this:

PHP код:
yourcommand
{
    
check if player variable is NOT over gettime(), then return something;
    
robbing functions;
    
set the player variable to gettime() + 400;
    return 
1;

what about saving it here ? to saving and load
like this
PHP код:
INI_WriteInt(File,"RobTimer",pRobTimer(playerid)); 
Reply
#7

Why don't do it like this?

Код:
CMD:rob(playerid, params[])
{
      Temp[playerid] = gettime();
      if(gettime() - Temp[playerid] < 300) 
      {
      // do things here
      }else return SendClientMessage(playerid, -1, "Please wait before doing this again");
}
300 will set it to 300 seconds. The player cant use the command for the next 5 minutes

Edit:
You can save it like this:
Код:
INI_WriteInt(File,"RobTime",Temp[playerid]);
But i doubt that will actually be useful, unless you make it save every second.
It will be useful against re-logging to restore the timer.
Reply
#8

PHP код:
new Robable=1Count[MAX_PLAYERS]; 
forward RobTimer(); 
forward RobTimer(playerid); 
public 
RobTimer(playerid

    
Count[playerid]--;
    if(
Count[playerid]==0)
    {
        
Robable[playerid]=1;
        
SendClientMessage(playerid,0xFF0000"Sets the robbing variable to 1 so players can rob"); 
    }

SetTimer("RobTimer"1000false);
Count[playerid]=400;
INI_WriteInt(File,"RobTimer",Count[playerid]); 
Reply
#9

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
PHP код:
new Robable=1Count[MAX_PLAYERS]; 
forward RobTimer(); 
forward RobTimer(playerid); 
public 
RobTimer(playerid

    
Count[playerid]--;
    if(
Count[playerid]==0)
    {
        
Robable[playerid]=1;
        
SendClientMessage(playerid,0xFF0000"Sets the robbing variable to 1 so players can rob"); 
    }

SetTimer("RobTimer"1000false);
Count[playerid]=400;
INI_WriteInt(File,"RobTimer",Count[playerid]); 
there is much error
somone help please!!!
Reply
#10

Quote:
Originally Posted by astanalol
Посмотреть сообщение
there is much error
somone help please!!!
You really should be more specific.
What is the error?
what is wrong?
We can't help you if we don't know whats going on.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)