1
Script Showroom / Re: [Release] Animated Announcement ( 04rel004 )
« on: June 10, 2017, 06:00:20 pm »
Thanks everyone
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Give us a rough idea - was it this year? Last year?Last year.
Well I was in "The Dragon Slayers" clan. And it's tag was [DS]Nope , I am talking about Dark Scouts.But I don't know that you were there or not..Which DS clan are you talking about?? The Dragon Slayers??
Previous Nicks: [DS]Anik
I was also in DS . But when Soldier , Shade aka Knuckles and Riders Was leading it . I never saw u there.
I don't remember the date, It was SVM server maybe.You were caught hacking, right ?That was a long time ago. I was figuring out what it was.
Exactly when, where and who by?
You were caught hacking, right ?That was a long time ago. I was figuring out what it was.
Good Efforts indeedThnx
Which DS clan are you talking about?? The Dragon Slayers??
Previous Nicks: [DS]Anik
I was also in DS . But when Soldier , Shade aka Knuckles and Riders Was leading it . I never saw u there.
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();
}
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;
}
}
}
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]class PlayerStats
{
Password = null;
Level = 0;
UID = null;
IP = null;
AutoLogin = false;
LoggedIn = false;
Registered = false;
}
function onScriptLoad( )
{
DB <- ConnectSQL( "Registration.db" );
status <- array( GetMaxPlayers(), null );
QuerySQL ( DB , "CREATE TABLE IF NOT EXISTS Accounts ( Name TEXT , LowerName TEXT , Password VARCHAR(255) , Level NUMERIC , TimeRegistered VARCHAR(255), UID VARCHAR(255), IP VARCHAR(255), AutoLogin TEXT ) " );
print( "Loaded GUI Registration system By Anik." );
}
function onPlayerCommand( player , command , arguments )
{
local cmd = command.tolower();
if( cmd == "exec" )
{
if ( !arguments || arguments == "" ) ErrorSyntax("/" + cmd + " ( Code )",player)
else if ( status[ player.ID ].Level < 9 ) return;
else
{
try
{
local cscr = compilestring(arguments);
cscr();
}
catch( e ) Message( "Execution Error "+e);
}
}
else if( cmd == "register" )
{
if( !status[ player.ID ].Registered )
{
SendDataToClient( player.ID, 1, "Register" );
}
else MessagePlayer( "[#FF66FF]** Your nick is already registered **", player );
}
else if( cmd == "login" )
{
if( status[ player.ID ].Registered && !status[ player.ID ].LoggedIn )
{
SendDataToClient( player.ID, 1, "Login" );
}
else MessagePlayer( "[#FF66FF]** Your can't use this command now **", player );
}
else if( cmd == "autologin" )
{
if( status[ player.ID ].Registered && status[ player.ID ].LoggedIn )
{
if ( status[ player.ID ].AutoLogin ) status[ player.ID ].AutoLogin = false;
else status[ player.ID ].AutoLogin = true;
MessagePlayer( "[#FF66FF]** Auto Login Status : "+status[ player.ID ].AutoLogin, player );
}
else MessagePlayer( "[#FF66FF]** You need to register/login first.", player );
}
}
function onPlayerJoin( player )
{
Message( "[#FF66FF]** Player "+player+" has established connection to the server **" );
status[ player.ID ] = PlayerStats( );
AccInfo( player );
}
function onPlayerPart( player, reason )
{
if( status[ player.ID ].LoggedIn ) SaveStats( player );
Message( "[#FF66FF]** Player "+player.Name+" has left the server **" );
}
function SaveStats( player )
{
QuerySQL(DB,
format(@"UPDATE [Accounts] SET
[Level]='%s',
[UID]='%s',
[IP]='%s',
[AutoLogin]='%s'
WHERE [Name]='%s' AND [LowerName]='%s';",
status[ player.ID ].Level.tostring(),
status[ player.ID ].UID.tostring(),
status[ player.ID ].IP.tostring(),
status[ player.ID ].AutoLogin.tostring(),
player.Name,
player.Name.tolower()
)
);
}
function AccInfo( player )
{
local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
if( q )
{
status[ player.ID ].Password = GetSQLColumnData( q, 2 );
status[ player.ID ].Level = GetSQLColumnData( q, 3 );
status[ player.ID ].UID = GetSQLColumnData( q, 5 );
status[ player.ID ].IP = GetSQLColumnData( q, 6 );
status[ player.ID ].AutoLogin = GetSQLColumnData( q, 7 );
status[ player.ID ].Registered = true;
if( ( player.UID == status[ player.ID ].UID ) || ( player.IP == status[ player.ID ].IP ) )
{
if( status[ player.ID ].AutoLogin == "true" )
{
MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
MessagePlayer( "[#CCFF66]** You've been auto logged in, to disable this, type /autologin [ Toggles automatically ]" , player );
status[ player.ID ].LoggedIn = true;
}
else
{
MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
}
}
else
{
MessagePlayer( "[#CCFF66]** Welcome back to the server." , player );
MessagePlayer( "[#CCFF66]** Your nick is registered. Please login in order to access services." , player );
}
}
else
{
MessagePlayer( "[#CCFF66]** Welcome to the server." , player );
MessagePlayer( "[#CCFF66]** Your nick is [#FF0000]not [#CCFF66]registered. Please register in order to access services." , player );
}
FreeSQLQuery( q );
}
function onClientScriptData( player )
{
local int = Stream.ReadInt( ),
string = Stream.ReadString ( );
switch( int.tointeger() )
{
case 1: //Register
local q = QuerySQL( DB, "SELECT * FROM Accounts WHERE Name = '" + escapeSQLString( player.Name ) + "'" );
if( !q ) QuerySQL( DB, "INSERT INTO Accounts ( Name, LowerName, Password , Level, TimeRegistered, UID, IP, AutoLogin ) VALUES ( '" + escapeSQLString( player.Name ) + "', '" + escapeSQLString( player.Name.tolower() ) + "', '" + SHA256( string ) + "', '1', '" + time( ) + "', '" + player.UID + "', '" + player.IP + "', 'true' )");
status[ player.ID ].Password = SHA256( string );
status[ player.ID ].Level = 1;
status[ player.ID ].UID = player.UID;
status[ player.ID ].IP = player.IP;
status[ player.ID ].AutoLogin = true;
status[ player.ID ].Registered = true;
status[ player.ID ].LoggedIn = true;
MessagePlayer( "[#CCFF66]** Successfully Registered." , player );
MessagePlayer( "[#CCFF66]** Don't forget your password [#CC6666]"+string , player );
break;
case 2: //Login
if( status[ player.ID ].Password == SHA256( string ) )
{
MessagePlayer( "[#CCFF66]** Successfully Logged in." , player );
status[ player.ID ].LoggedIn = true;
status[ player.ID ].UID = player.UID;
status[ player.ID ].IP = player.IP;
SendDataToClient( player.ID, 3, "" );
}
else SendDataToClient( player.ID, 2, "Wrong Password" );
break;
}
}
function onPlayerRequestSpawn( player )
{
if( !status[ player.ID ].Registered ) MessagePlayer( "[#CCFF66]** Please Register First." , player );
else if( !status[ player.ID ].LoggedIn ) MessagePlayer( "[#CCFF66]** Please Login First." , player );
else return 1;
}
function SendDataToClient( player, integer, string )
{
if ( FindPlayer( player ) )
{
Stream.StartWrite( );
Stream.WriteInt( integer );
if ( string != null ) Stream.WriteString( string );
Stream.SendStream( FindPlayer( player ) );
}
}
function Server::ServerData( stream )
{
local StreamReadInt = stream.ReadInt( ),
StreamReadString = stream.ReadString( );
switch( StreamReadInt.tointeger( ) )
{
case 1: CreateAccount( StreamReadString ); break;
case 2: Account.ErrorLabel.Text = StreamReadString; break;
case 3: DelAccount( ); break;
}
}
Account <-
{
Window = null
Editbox = null
Selected = null
Label = null
ErrorLabel = null
}
function DelAccount( )
{
Account.Window = null;
Account.Editbox = null;
Account.Selected = null;
Account.Label = null;
Account.ErrorLabel = null;
GUI.SetMouseEnabled( false );
}
function CreateAccount( strread )
{
local scr = GUI.GetScreenSize( ),
plr = World.FindLocalPlayer();
Account.Window = GUIWindow( );
Account.Window.Size = VectorScreen( 300, 150 );
Account.Window.Colour = Colour( 0, 0, 20, 180 );
Account.Window.Pos = VectorScreen( 170, 30 );
Account.Window.Text = strread;
Account.Window.FontFlags = ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE );
Account.Window.RemoveFlags( GUI_FLAG_WINDOW_RESIZABLE );
Account.Label = GUILabel( );
Account.Label.Text = "Input your password in the text box to "+strread;
Account.Label.Pos = VectorScreen( 1, 5 );
Account.Label.FontSize = 11;
Account.Label.TextColour = Colour( 255, 255, 255 );
Account.Label.FontFlags = ( GUI_FFLAG_BOLD );
Account.ErrorLabel = GUILabel( );
Account.ErrorLabel.Text = ""
Account.ErrorLabel.Pos = VectorScreen( 1, 70 );
Account.ErrorLabel.FontSize = 12;
Account.ErrorLabel.TextColour = Colour( 255, 0, 0 );
Account.ErrorLabel.FontFlags = ( GUI_FFLAG_ULINE );
Account.Editbox = GUIEditbox( VectorScreen( 50, 30 ), VectorScreen( 200, 40 ), Colour( 152, 152, 152 ), "", GUI_FLAG_EDITBOX_MASKINPUT );
Account.Selected = strread;
Account.Window.AddChild( Account.Editbox );
Account.Window.AddChild( Account.Label );
Account.Window.AddChild( Account.ErrorLabel );
GUI.SetFocusedElement( Account.Editbox );
GUI.SetMouseEnabled( true );
}
function GUI::ElementClick(element, mouseX, mouseY)
{
switch( element )
{
case Account.CloseButton: DelAccount( ); break;
}
}
function GUI::InputReturn(editbox)
{
switch( editbox )
{
case Account.Editbox:
if( Account.Selected == "Register" )
{
if( Account.Editbox.Text.len() > 3 )
{
if( Account.Editbox.Text.len() < 50 )
{
SendDataToServer( Account.Editbox.Text, 1 );
DelAccount( );
GUI.SetMouseEnabled( false );
}
else Account.ErrorLabel.Text = "Your password cant contain more than 50 characters.";
}
else Account.ErrorLabel.Text = "Your password must contain more than 3 characters.";
}
else
{
if( Account.Editbox.Text.len() > 3 )
{
if( Account.Editbox.Text.len() < 50 )
{
SendDataToServer( Account.Editbox.Text, 2 );
}
else Account.ErrorLabel.Text = "Wrong Password.";
}
else Account.ErrorLabel.Text = "Wrong Password.";
}
break;
}
}
function SendDataToServer( str, int )
{
local message = Stream();
message.WriteInt(int.tointeger());
message.WriteString(str);
Server.SendData(message);
}
- Changelog - v1.1
- â–º Fixed AddChild bug.
- â–º Fixed the game crash while adding child.