SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 31/05/2010, 12:18 PM   #1
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default 2 timers into one

1. Timer

Quote:
public DynamicHostName()
{
if(hostname == 1)
{
hostname = 0;
SendRconCommand("hostname Name 1");
}
else
{
hostname = 1;
SendRconCommand("hostname Name 2");
}
}
2. Timer

Quote:
public OtherTimer()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (GetPlayerState(i) == 1) CheckForWalkingTeleport(i);
}
}
return 1;
}
I want to set that 2nd code to 1st so they should run together with that 1st timer
ArTisT is offline  
Old 31/05/2010, 12:31 PM   #2
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,150
Reputation: 6
Default Re: 2 timers into one

Under OnGameModeInit function:
Code:
SetTimer("function",3000,1); // you can chage these parameters
Anywhere in your script:
Code:
forward function();
public function()
{
 if(hostname == 1)
  {
   hostname = 0;
   SendRconCommand("hostname Name 1");
  }
  else
  {
   hostname = 1;
   SendRconCommand("hostname Name 2");
  }
  for(new i = 0; i < MAX_PLAYERS; i++)
   {
    if(IsPlayerConnected(i))
    {
    if (GetPlayerState(i) == 1) CheckForWalkingTeleport(i);
    }
   }
   return 1;
Is that what you want?
__________________
DJDhan is offline  
Old 31/05/2010, 12:44 PM   #3
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default Re: 2 timers into one

ye thanks.. so 2 things running in 1 timer its better like now instead have 2 timers ?
ArTisT is offline  
Old 31/05/2010, 01:22 PM   #4
Jakku
High-roller
 
Jakku's Avatar
 
Join Date: Apr 2009
Location: Heinola, Finland
Posts: 1,354
Reputation: 157
Default Re: 2 timers into one

Quote:
Originally Posted by ArTisT
ye thanks.. so 2 things running in 1 timer its better like now instead have 2 timers ?
It's better what less you have timers.
__________________
Jakku is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Timers Antonio [G-RP] Help Archive 8 17/08/2011 03:35 PM
timers ToPhrESH Help Archive 8 06/07/2010 07:22 PM
[HELP] timers argon Help Archive 8 26/07/2009 06:17 PM
Timers arnutisz Help Archive 0 18/07/2009 06:45 AM
TIMERS?!!? coole210 Help Archive 5 06/07/2009 04:18 AM


All times are GMT. The time now is 11:58 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.