News System

Started by KAKAN, Jul 14, 2015, 12:04 PM

Previous topic - Next topic

KAKAN

News System for newbies by me :)
Enjoy


function onScriptLoad()
{
NewTimer("TextUpdater",60000,0); \\ Edit it as u want, it is 60 seconds now
}


Functions...
function TextUpdater()
{
         if( GetPlayers() > 0 )
         {
                     local idx = random_msg[ rand() % random_msg.len() ];
                     ClientMessageToAll( idx[0], idx[1], idx[2], idx[3] );
          }
  }

Finally the main one "news" system

random_msg <- [
              ["**Message-1",255,255,255],
              ["**Message-2",255,0,0], \\ Add how many u want
];
oh no

jayant

#1
This is actually posted by Shadow, here in old forum - http://vcmp.liberty-unleashed.co.uk/forum/index.php?topic=1422.msg8979#msg8979

Edit - I just noticed that you are new here ? Dont take me rude please !

[VSS]Shawn

Stop fuc***** post unusefull and copied snippet and this is already posted by Matheus

KAKAN

Nope actually I made this, I didn't knew about that site, thanks for telling me that site, now I'll take a look at that website
oh no

[VSS]Shawn

nice try to fool players


MacTavish

#5
to reducing lag cause of timer it must be improved

function onScriptLoad()
{
 newsTimer <- NewTimer("TextUpdater",60000,0); \ Edit it as u want, it is 60 seconds no
newsTimer.Paused = true;
}

function onPlayerJoin(player)
{
if( newsTimer.Paused == true )
{
newsTimer.Paused = false;
print("timer resumed");
}
}

function onPlayerPart(player, reason)
{
if ( GetPlayers() == 0 && newsTimer.Paused == false )
{
newsTimer.Paused = true;
print("timer paused");
}
}

function TextUpdater()
{
       
                     ClientMessageToAll( random_msg[rand()% random_msg.len()],255,25,0 );
          }


random_msg <- ["msg 1", "msg2", "msg3"];





Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Stormeus

Quote from: Beztone on Jul 14, 2015, 04:50 PMto reducing lag cause of timer it must be improved

<snip>

... I mean technically yeah but you probably shaved off a lot less than a millisecond of execution time with that optimization. It's not like the overhead of calling a timer function takes seconds. It's inelegant.

There should be a balance between readability for the scripter and optimization for the server — this looks like an unnecessary microoptimization that just adds complexity.

FarisDon

Quote from: Stormeus on Jul 14, 2015, 06:28 PM
Quote from: Beztone on Jul 14, 2015, 04:50 PMto reducing lag cause of timer it must be improved

<snip>

... I mean technically yeah but you probably shaved off a lot less than a millisecond of execution time with that optimization. It's not like the overhead of calling a timer function takes seconds. It's inelegant.

There should be a balance between readability for the scripter and optimization for the server — this looks like an unnecessary microoptimization that just adds complexity.
Meh never understand what stormeus say in these type of cases :D will you describe it more clearly ?

Thijn

Quote from: Axel-Blaz on Jul 14, 2015, 06:48 PM
Quote from: Stormeus on Jul 14, 2015, 06:28 PM
Quote from: Beztone on Jul 14, 2015, 04:50 PMto reducing lag cause of timer it must be improved

<snip>

... I mean technically yeah but you probably shaved off a lot less than a millisecond of execution time with that optimization. It's not like the overhead of calling a timer function takes seconds. It's inelegant.

There should be a balance between readability for the scripter and optimization for the server — this looks like an unnecessary microoptimization that just adds complexity.
Meh never understand what stormeus say in these type of cases :D will you describe it more clearly ?
What's not to understand?

Stormeus

Quote from: Axel-Blaz on Jul 14, 2015, 06:48 PMMeh never understand what stormeus say in these type of cases :D will you describe it more clearly ?

It's a pointless fix because timers don't take years to run.

[VSS]Shawn

UseLess Lock the Topic

KAKAN

Yup, ur posts makes all the topics useless
oh no

Murdock

Quote from: Axel-Blaz on Jul 14, 2015, 06:48 PMMeh never understand what stormeus say in these type of cases :D will you describe it more clearly ?

http://www.learn-english-online.org might help in the future

KAKAN

oh no