KAKAN

  • Wiki Contributor
  • Posts: 3,343
News System
« on July 14th, 2015, 01:04 PM »
News System for newbies by me :)
Enjoy


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


Functions...
Code: [Select]
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

Code: [Select]
random_msg <- [
              ["**Message-1",255,255,255],
              ["**Message-2",255,0,0], \\ Add how many u want
];
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

jayant

  • Full Member
  • #MOMO-CS
  • Posts: 163

[VSS]Shawn

  • Full Member
  • Posts: 210
Re: News System
« Reply #2, on July 14th, 2015, 05:00 PM »
Stop fuc***** post unusefull and copied snippet and this is already posted by Matheus

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: News System
« Reply #3, on July 14th, 2015, 05: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
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

[VSS]Shawn

  • Full Member
  • Posts: 210
Re: News System
« Reply #4, on July 14th, 2015, 05:36 PM »
nice try to fool players


MacTavish

  • Hero Member
  • Nicks( Kusanagi, Beztone, RATHORE )
  • Posts: 809
Re: News System
« Reply #5, on July 14th, 2015, 05:50 PM »Last edited on July 14th, 2015, 05:52 PM
to reducing lag cause of timer it must be improved

Code: [Select]
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

  • VC:MP Developer
  • oh god how did i get here im not good w computer
  • Posts: 1,127
Re: News System
« Reply #6, on July 14th, 2015, 07:28 PM »
Quote from Beztone on July 14th, 2015, 05:50 PM
to 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

  • Guest
Re: News System
« Reply #7, on July 14th, 2015, 07:48 PM »
Quote from Stormeus on July 14th, 2015, 07:28 PM
Quote from Beztone on July 14th, 2015, 05:50 PM
to 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

  • VC:MP Beta Tester
  • Posts: 1,688
Re: News System
« Reply #8, on July 14th, 2015, 08:24 PM »
Quote from Axel-Blaz on July 14th, 2015, 07:48 PM
Quote from Stormeus on July 14th, 2015, 07:28 PM
Quote from Beztone on July 14th, 2015, 05:50 PM
to 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

  • VC:MP Developer
  • oh god how did i get here im not good w computer
  • Posts: 1,127
Re: News System
« Reply #9, on July 14th, 2015, 08:32 PM »
Quote from Axel-Blaz on July 14th, 2015, 07:48 PM
Meh 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

  • Full Member
  • Posts: 210
Re: News System
« Reply #10, on July 15th, 2015, 09:39 AM »
UseLess Lock the Topic

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: News System
« Reply #11, on July 15th, 2015, 05:12 PM »
Yup, ur posts makes all the topics useless
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

Murdock

  • LU Beta Tester
  • Posts: 244

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN