Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: KAKAN on Jul 14, 2015, 12:04 PM

Title: News System
Post by: KAKAN on Jul 14, 2015, 12:04 PM
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
];
Title: Re: News System
Post by: jayant on Jul 14, 2015, 02:18 PM
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 !
Title: Re: News System
Post by: [VSS]Shawn on Jul 14, 2015, 04:00 PM
Stop fuc***** post unusefull and copied snippet and this is already posted by Matheus
Title: Re: News System
Post by: KAKAN on Jul 14, 2015, 04:22 PM
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
Title: Re: News System
Post by: [VSS]Shawn on Jul 14, 2015, 04:36 PM
nice try to fool players

Title: Re: News System
Post by: MacTavish on Jul 14, 2015, 04:50 PM
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"];




Title: Re: News System
Post by: 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.
Title: Re: News System
Post by: FarisDon 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 ?
Title: Re: News System
Post by: Thijn on Jul 14, 2015, 07:24 PM
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?
Title: Re: News System
Post by: Stormeus on Jul 14, 2015, 07:32 PM
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.
Title: Re: News System
Post by: [VSS]Shawn on Jul 15, 2015, 08:39 AM
UseLess Lock the Topic
Title: Re: News System
Post by: KAKAN on Jul 15, 2015, 04:12 PM
Yup, ur posts makes all the topics useless
Title: Re: News System
Post by: Murdock on Jul 15, 2015, 05:56 PM
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
Title: Re: News System
Post by: KAKAN on Jul 16, 2015, 08:28 AM
LOL..!!