login
March 28, 2024, 10:11:39 am

Author Topic: [Release] Animated Announcement ( 04rel004 )  (Read 3768 times)

0 Members and 1 Guest are viewing this topic.

Anik

  • Newbie
  • *
  • Posts: 18
  • Country: bd
    • View Profile
[Release] Animated Announcement ( 04rel004 )
« on: May 08, 2017, 09:44:09 am »
Credits :-
  • ysc3839 - Timer function of client side.
  • Anik

Animated Announcement

This is a new kind of announcement which is better than the boring one.

Check the code here :-
[spoiler]
Server Side :-
Code: [Select]
function AnimatedAnnounce( plr, text )
{
Stream.StartWrite();
Stream.WriteInt( 1 );
Stream.WriteString( text );
Stream.SendStream( plr );
}

function AnimatedAnnounceAll( text )
{
Stream.StartWrite();
Stream.WriteInt( 1 );
Stream.WriteString( text );
Stream.SendStream( null );
}

function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
  tokenized = split(string, separator),
  text = "";

if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}

function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
}

Now this goes to Client side:-

Code: [Select]
Timer <- {
Timers = {}

function Create(environment, listener, interval, repeat, ...)
{
// Prepare the arguments pack
vargv.insert(0, environment);

// Store timer information into a table
local TimerInfo = {
Environment = environment,
Listener = listener,
Interval = interval,
Repeat = repeat,
Args = vargv,
LastCall = Script.GetTicks(),
CallCount = 0
};

local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);

// Store the timer information
Timers.rawset(hash, TimerInfo);

// Return the hash that identifies this timer
return hash;
}

function Destroy(hash)
{
// See if the specified timer exists
if (Timers.rawin(hash))
{
// Remove the timer information
Timers.rawdelete(hash);
}
}

function Exists(hash)
{
// See if the specified timer exists
return Timers.rawin(hash);
}

function Fetch(hash)
{
// Return the timer information
return Timers.rawget(hash);
}

function Clear()
{
// Clear existing timers
Timers.clear();
}

function Process()
{
local CurrTime = Script.GetTicks();
foreach (hash, tm in Timers)
{
if (tm != null)
{
if (CurrTime - tm.LastCall >= tm.Interval)
{
tm.CallCount++;
tm.LastCall = CurrTime;

tm.Listener.pacall(tm.Args);

if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
Timers.rawdelete(hash);
}
}
}
}
};

ThreeD <-
{
text = null
Label = null
style = null
R = null
G = null
B = null
Timer = null
}

function VScreen( pos_x, pos_y )//Credits goes to Doom_Kill3R for this function
{
local
    screenSize = GUI.GetScreenSize( ),
    x = floor( pos_x * screenSize.X / 1920 ),
    y = floor( pos_y * screenSize.Y / 1080 );

return VectorScreen( x, y );
}

function Server::ServerData( stream )
{
local StreamReadInt = stream.ReadInt( ),
StreamReadString = stream.ReadString( );
switch( StreamReadInt.tointeger( ) )
{
case 1: Create3DAnnouncement( StreamReadString ); break;
}
}

function Script::ScriptProcess( )
{
Timer.Process();
}

function Create3DAnnouncement( strread )
{
if ( ThreeD.Label ) Timer.Destroy( ThreeD.Timer );

ThreeD.text = strread;
ThreeD.style = rand()%10;

ThreeD.R = rand()%255;
ThreeD.G = rand()%255;
ThreeD.B = rand()%255;

ThreeD.Label = GUILabel( VScreen(800,500),Colour( ThreeD.R, ThreeD.G, ThreeD.B ), ThreeD.text );
ThreeD.Label.TextAlignment = GUI_ALIGN_CENTER;
ThreeD.Label.FontFlags = GUI_FFLAG_BOLD | GUI_FFLAG_OUTLINE;
ThreeD.Label.FontSize = 18;

ThreeD.Timer = Timer.Create( this, Update3DAnnouncement, 0.1, 128);
}

function Update3DAnnouncement( )
{
if ( ThreeD.Label )
{
switch( ThreeD.style )
{
case 1:
ThreeD.Label.Pos.X -= 1;
ThreeD.Label.Pos.Y -= 1;
break;
case 2:
ThreeD.Label.Pos.X += 1;
ThreeD.Label.Pos.Y += 1;
break;
case 3:
ThreeD.Label.Pos.X -= 1;
ThreeD.Label.Pos.Y += 1;
break;
case 4:
ThreeD.Label.Pos.X += 1;
ThreeD.Label.Pos.Y -= 1;
break;
case 5:
ThreeD.Label.Pos.X -= 1;
break;
case 6:
ThreeD.Label.Pos.Y -= 1;
break;
case 7:
ThreeD.Label.Pos.X += 1;
break;
case 8:
ThreeD.Label.Pos.Y += 1;
break;
default:
ThreeD.Label.Pos.X -= 2;
ThreeD.Label.Pos.Y += 1;
break;
}
ThreeD.Label.Alpha -=2;
if ( ThreeD.Label.Alpha < 2 )
{
Timer.Destroy( ThreeD.Timer );
ThreeD.Label = null;
}
}
}

Example :-

Code: [Select]
function onPlayerCommand( player , command , arguments )
{
local cmd = command.tolower();
if ( cmd == "ann" )
{
if ( arguments )
{
local plr = GetTok( arguments, " ", 1), text = GetTok( arguments, " ", 2 , NumTok ( arguments , " " ) );
if ( arguments.len() > 50 ) return MessagePlayer("[#00EE00]( ERROR ) [#FFFFFF]You announcement is too long." , player);
else
{
if( plr.tolower() == "all" ) AnimatedAnnounceAll( text );
else
{
local p = FindPlayer( plr );
if( p ) AnimatedAnnounce( p, text );
else MessagePlayer("[#00EE00]( ERROR ) [#FFFFFF] Unknown Player." , player);
}
}
}
else MessagePlayer("[#00EE00]( SYNTAX ) [#FFFFFF]/"+cmd+" <plr/all> <text>" , player);
}
}
[/spoiler]

This is how it looks


NOTE : I have made the style and color random. There are 8 styles. You can modify it according to your choice.
Winner Winner x 1 Useful Useful x 4 Optimistic Optimistic x 2 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


rickyy

  • Vice Underdog Trainee (Inactive)
  • Fanatic
  • *
  • Posts: 173
  • Country: in
  • GAMERS DON'T DIE
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #1 on: May 08, 2017, 11:18:04 am »
Good Efforts indeed ;)
Friendly Friendly x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Anik

  • Newbie
  • *
  • Posts: 18
  • Country: bd
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #2 on: May 08, 2017, 11:34:21 am »
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


klein.

  • Crazy Man
  • *****
  • Posts: 564
  • Country: 00
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #3 on: May 08, 2017, 11:48:31 pm »
Good Job!
Friendly Friendly x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Dagger

  • Newbie
  • *
  • Posts: 17
  • Country: in
  • Hmm..An unknown player
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #4 on: May 28, 2017, 06:10:37 am »
Interesting.
Friendly Friendly x 1 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

Hello, i'm just passing by..

Mubashir^

  • Fanatic
  • ****
  • Posts: 133
  • Country: pk
  • RisK Is MY BuSiNeSs.
    • View Profile
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Anik

  • Newbie
  • *
  • Posts: 18
  • Country: bd
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #6 on: June 10, 2017, 06:00:20 pm »
Thanks everyone :)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


Legend

  • Fanatic
  • ****
  • Posts: 239
  • Country: tr
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #7 on: June 10, 2017, 07:00:22 pm »
give me spam script pls  :) ;) :D ;D >:( :o 8) ??? ??? >:D >:D :police: ^-^ O0 O0 :thumbsup: :thumbsup:
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


www.Game-State.com" style="border-style: none;

krystianoo

  • Crazy Man
  • *****
  • Posts: 1203
  • Country: pl
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #8 on: June 11, 2017, 10:34:22 am »
give me spam script pls  :) ;) :D ;D >:( :o 8) ??? ??? >:D >:D :police: ^-^ O0 O0 :thumbsup: :thumbsup:

onPlayerJoin().SpamScript = true;
Funny Funny x 3 (list)
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


PunkNoodle

  • Vice Underdog
  • Crazy Man
  • *
  • *
  • *
  • *
  • *
  • *
  • *
  • Posts: 957
  • Country: it
    • View Profile
Re: [Release] Animated Announcement ( 04rel004 )
« Reply #9 on: June 11, 2017, 09:58:35 pm »
give me spam script pls  :) ;) :D ;D >:( :o 8) ??? ??? >:D >:D :police: ^-^ O0 O0 :thumbsup: :thumbsup:
Code: [Select]
for(;;)
{
    print("spam");
}
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor


FulToN_619

  • Crazy Man
  • *****
  • Posts: 719
  • Country: pk
  • Give Respect Get Respect
    • View Profile
Agree Disagree Funny Winner Pwnt Informative Friendly Useful Optimistic Artistic Late Brain Donor

fulton (the hardest lagger on vcmp, I can't touch him)