Hi guys.
a question. Can I make an action run every 30 seconds once the server is turned on? example:
Function Blablabla ()
{
Message ("Bla bla bla")
}it's an example
This message must be transmitted every 30 seconds once the server is started
			
			
			
				Yes
			
			
			
				You can use this
function onServerStart()
{
NewTimer("MessengerAllGlobal", 40000, 0 );
}
function MessengerAllGlobal()
{
if ( GetPlayers() >= 1 )
{
local RanNum = Random(1, 5); 
if ( RanNum == 1 )  Message("Blabla1");
else if ( RanNum == 2 )  Message("Blabla2");
else if ( RanNum == 3 )  Message("IBlabla3");
else if ( RanNum == 4 )  Message("Blabla4");
else if ( RanNum == 5 ) Message( "Blabla5");
}
function Random(min=0, max=RAND_MAX)
{
local r = rand();
srand(GetTickCount() * r);
return (r % ((max + 1) - min)) + min;
}
			
			
			
				Quote from: Eva on Mar 14, 2017, 09:40 PMYou can use this
function onServerStart()
{
NewTimer("MessengerAllGlobal", 40000, 0 );
}
function MessengerAllGlobal()
{
if ( GetPlayers() >= 1 )
{
local RanNum = Random(1, 5); 
if ( RanNum == 1 )  Message("Blabla1");
else if ( RanNum == 2 )  Message("Blabla2");
else if ( RanNum == 3 )  Message("IBlabla3");
else if ( RanNum == 4 )  Message("Blabla4");
else if ( RanNum == 5 ) Message( "Blabla5");
}
function Random(min=0, max=RAND_MAX)
{
local r = rand();
srand(GetTickCount() * r);
return (r % ((max + 1) - min)) + min;
}
But you think it will work.? Could it be that he will only give one advertisement? And will not announce more?
			
 
			
			
				I see no reason to not use an array instead of those life-taking hell of if statements
			
			
			
				Quote from: kennedyarz on Mar 15, 2017, 01:04 AMQuote from: Eva on Mar 14, 2017, 09:40 PMYou can use this
function onServerStart()
{
NewTimer("MessengerAllGlobal", 40000, 0 );
}
function MessengerAllGlobal()
{
if ( GetPlayers() >= 1 )
{
local RanNum = Random(1, 5); 
if ( RanNum == 1 )  Message("Blabla1");
else if ( RanNum == 2 )  Message("Blabla2");
else if ( RanNum == 3 )  Message("IBlabla3");
else if ( RanNum == 4 )  Message("Blabla4");
else if ( RanNum == 5 ) Message( "Blabla5");
}
function Random(min=0, max=RAND_MAX)
{
local r = rand();
srand(GetTickCount() * r);
return (r % ((max + 1) - min)) + min;
}
But you think it will work.? Could it be that he will only give one advertisement? And will not announce more?
If you want just 1 just set it like this:  local RanNum = Random(1, 1); 
Quote from: KAKAN on Mar 15, 2017, 02:46 AMI see no reason to not use an array instead of those life-taking hell of if statements
I just gave an example of how i did it, and it works fine.
Maybe you can show how to do it in a different "more efficient way"
			
 
			
			
				Quote from: Eva on Mar 15, 2017, 09:12 AMMaybe you can show how to do it in a different "more efficient way"
dunno if its efficient, but its better than typing if all the time.
yourMsgs <- [ "Message 1",
"Message 2" ]; //....
function RandMsg(){
Message( yourMsgs[ Random( 0, yourMsgs.len() - 1 ) ] );
}I was not talking about efficiency, for a lazy person like me, its hard to type 100 if statements if you got 100 messages to print.
			
 
			
			
				Quote from: Eva on Mar 14, 2017, 09:40 PMYou can use this
If you want just 1 just set it like this:  local RanNum = Random(1, 1); 
LMAO
Quote from: Eva on Mar 14, 2017, 09:40 PMMaybe you can show how to do it in a different "more efficient way"
function onScriptLoad()
{
    NewTimer("BlaBla", 30000, 0);
}
function BlaBla()
{
    MessageAll("Blah Blah Blah!!!");
}
			 
			
			
				Quote from: KAKAN on Mar 15, 2017, 11:53 AMI was not talking about efficiency, for a lazy person like me, its hard to type 100 if statements if you got 100 messages to print.
xD i use ctrl c and v , still you have to type the 100 messages.
but anyway i learned something :) thnx
			
 
			
			
				The truth is that thanks 
@Eva, I worked as you say, and 
@KAKAN my function was not to give messages, just an example. Topic solved