[CLIENT-SNIPPET]Scrollable Memobox With Multiple Pages & Backgrounds

Started by !, Aug 31, 2017, 12:50 PM

Previous topic - Next topic

!

Credits: Elite Killerz | Estate City Server for give me an idea. ;D

Features
>Syncronised with scroll bar.
>Multiple pages which allow us to write many words.
>Everything is done in clientside.
>Different background pictures.

Installation
1.Copy and paste everything from replaceable snippte in correct place in Svr_Dir/store/script/main.nut file.
2.Copy & paste everything from copy & pasteable snippet at the beginning of Svr_Dir/store/script/main.nut file.
3.Create a file in Svr_Dir/store/script/ with name messages.nut or simply copy and paste the messages.nut file from this topic to script directory.

Pictures
Link
[spoiler=Pics]



[/spoiler]

Downloadable Stuff
1.Sample file for messages.nut


2.Sample Pictures(copy and paste them in Svr_Dir/store/sprites)


Snippets
[spoiler=Replaceable-Snippet]
Replace every thing in the correct place in Svr_Dir/store/script/main.nut file
[noae][noae][noae]/*
<?php */keyBIND_F1 <- KeyBind( 0x70 );COLOR_BLUE   <- Colour( 0, 0, 255 );function Script::ScriptLoad( ){dofile( "messages.nut" );  //This is the file from which we are going to read memobox data.}function GUI::ScrollbarScroll( scrollbar, position, change ){GUI_ServerLogs.ScrollbarScroll( scrollbar, position );}function GUI::ElementClick(element, mousex, mousey){GUI_ServerLogs.ElementClick( element );}function KeyBind::OnDown( keyBind ){if ( keyBind == keyBIND_F1 ) GUI_ServerLogs.Decide( );}function GUI::ElementRelease(element, mouseX, mouseY){GUI_ServerLogs.ElementRelease( element );}function GUI::GameResize( width, height ){GUI_ServerLogs.GameResize( );}
[/noae][/noae][/noae]
[/spoiler]

[spoiler=Copy&Pasteable-Snippet]
Copy & paste this snippet at the beginning of Svr_Dir/store/script/main.nut file
[noae][noae][noae]/*
<?php */GUI_ServerLogs <- {	LogsW = null,   //Logs Window (leve it as it is)	LogsB = null,   //Logs Board (leve it as it is)	LogsS = null,   //Logs Scroll (leve it as it is)	LogsE = null,   //Logs Exit (leve it as it is)	LogsN = null,   //Logs Next (leve it as it is)	LogsP = null,   //Logs Previous (leve it as it is)	PageID = 1,   //Current Page (leve it as it is)		MaxPages = 3,   //Max NO. Of Pages (set it according to your need)	Pics = 3,   //Background Pictures (set it according to your need)		ShowGUI = 0,   //Showing GUI  (leve it as it is)	function Create( )	{	//Credits: EK.IceFlake for sample script + idea	local cScreenSize = GUI.GetScreenSize();	local Pic_No = rand()%Pics;		//Set the bellow pics names starting with car_...	if ( Pic_No == 0 ) LogsW = ::GUISprite( "car_1.jpg", VectorScreen( 0, 0 ) );	if ( Pic_No == 1 ) LogsW = ::GUISprite( "car_2.jpg", VectorScreen( 0, 0 ) );	if ( Pic_No == 2 ) LogsW = ::GUISprite( "car_3.jpg", VectorScreen( 0, 0 ) );		LogsW.Size = cScreenSize;	LogsB = ::GUIMemobox( VectorScreen( 32, 32 ), VectorScreen( cScreenSize.X - 80, cScreenSize.Y - 64 ), Colour( 255, 255, 255, 128 ), GUI_FLAG_TEXT_TAGS );	LogsB.HistorySize = 255;	LogsS = ::GUIScrollbar( VectorScreen( cScreenSize.X - 48, 32 ), VectorScreen( 16, cScreenSize.Y - 64 ) );	LogsE = ::GUILabel(VectorScreen( cScreenSize.X - 28, cScreenSize.Y / 2 - 10 ), Colour( 179, 0, 0 ), "Exit" );	DecidePage( );	LogsE.TextAlignment = GUI_ALIGN_LEFT;	LogsE.FontName = "Corbel";	LogsE.FontSize = 13;	LogsE.AddFlags( GUI_FLAG_MOUSECTRL );	::GUI.SetMouseEnabled( );	}function DecidePageButtons( )	{	if ( ShowGUI == 0 ) return;		if ( ( LogsS.BarPosition != 0 && LogsP != null ) || ( LogsS.BarPosition != 1 && LogsN != null ) ) RemovePageButtons( );		if ( LogsS.BarPosition != 0 && LogsS.BarPosition != 1 ) return;		if ( LogsS.BarPosition == 0 && LogsP == null && PageID != 1 )		{		RemovePageButtons( );		local cScreenSize = GUI.GetScreenSize();		LogsP = GUIButton( VectorScreen( cScreenSize.X - 130, 7 ), VectorScreen( 85, 20 ), Colour( 140, 140, 140 ), "Previous Page", ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE ) );		LogsP.TextColour  = COLOR_BLUE;		return;		}			if ( LogsS.BarPosition == 1 && LogsN == null && PageID != MaxPages )		{		RemovePageButtons( );		local cScreenSize = GUI.GetScreenSize();		LogsN = GUIButton( VectorScreen( cScreenSize.X - 130, cScreenSize.Y - 27 ), VectorScreen( 65, 20 ), Colour( 140, 140, 140 ), "Next Page", ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE ) );		LogsN.Alpha = 200;		LogsN.TextColour  = COLOR_BLUE;		return;		}	}function ScrollbarScroll( scrollbar, position )	{	if ( !ShowGUI ) return;		switch( scrollbar )		{		case LogsS:			GUI_ServerLogs.DecidePageButtons( );			GUI_ServerLogs.LogsB.DisplayPos = 1 - position;		break;		}	}function ElementClick( element )	{	if ( !ShowGUI ) return;		switch( element )		{		case LogsE:			Close( );		break;		}	}function ElementRelease( element )	{	if ( !ShowGUI ) return;		switch( element )		{		case LogsN:			PageID++;			DecidePage( );		break;		case LogsP:			PageID--;			DecidePage( );		break;		}	}function GameResize( )	{	if ( !ShowGUI ) return;		Close( );	}	function RemovePageButtons( )	{	if ( !ShowGUI ) return;		if ( LogsN != null ) LogsN = null;	if ( LogsP != null ) LogsP = null;	}function DecidePage( )	{	if ( !ShowGUI ) return;		local NPageID = PageID + 1;	RemovePageButtons( );	LogsB.Clear();	LogsB.AddLine( "", Colour( 64, 64, 64 ) );	LogsB.AddLine( "Grand Theft Auto Asian City ChangeLogs Page: "+PageID, Colour( 150, 0, 50 ) );	if ( PageID == 1 ) foreach ( lr in ::split( SvrLogs3, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );	else if ( PageID == 2 ) foreach ( lr in ::split( SvrLogs2, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );	else if ( PageID == 3 ) foreach ( lr in ::split( SvrLogs1, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );		if ( PageID == MaxPages ) LogsB.AddLine( "End of server changelogs.", Colour( 150, 0, 50 ) );	else LogsB.AddLine( "Click on next page button for page: "+NPageID, Colour( 150, 0, 50 ) );		LogsS.BarPosition = 0;	LogsB.DisplayPos = 1;	}function Close( )	{	if ( !ShowGUI ) return;		LogsW = null;	LogsB = null;	LogsS = null;	LogsE = null;	LogsN = null;	LogsP = null;	::GUI.SetMouseEnabled(false);		ShowGUI = 0;	}function Show( )	{	if ( ShowGUI ) return;	ShowGUI = 1;	Create( );	}function Decide( )	{	if ( ShowGUI ) Close( );	else Show( );	}}
[/noae][/noae][/noae]
[/spoiler]

Note:
Press F1 key to open and close the memobox.

[spoiler=Sample_Store_File]

[/spoiler]

Discord: zeus#5155

MatheuS

if( !sucess ) tryAgain();

=RK=MarineForce

https://privateladyescorts.com - Secret Dating Site - No Verify - Anonymous Sex Dating -   Local Singles Chat



!

Quote from: KrooB on Jul 06, 2018, 05:25 PMbro where is the link :D
Fixed
PS: You don't need linked files just copy and paste the snippets in their correct locations and do correct configuration for img names and news etc.

Discord: zeus#5155

KrOoB_

bro i try but not worked your code , sprites & message.nut everything right loc

serv.dir/store/script/main.nut
[noae][noae]GUI_ServerLogs <- {
 LogsW = null,   //Logs Window (leve it as it is)
 LogsB = null,   //Logs Board (leve it as it is)
 LogsS = null,   //Logs Scroll (leve it as it is)
 LogsE = null,   //Logs Exit (leve it as it is)
 LogsN = null,   //Logs Next (leve it as it is)
 LogsP = null,   //Logs Previous (leve it as it is)
 PageID = 1,   //Current Page (leve it as it is)
 
 MaxPages = 3,   //Max NO. Of Pages (set it according to your need)
 Pics = 3,   //Background Pictures (set it according to your need)
 
 ShowGUI = 0,   //Showing GUI  (leve it as it is)
 
function Create( )
 {
 //Credits: EK.IceFlake for sample script + idea
 local cScreenSize = GUI.GetScreenSize();
 local Pic_No = rand()%Pics;
 
 //Set the bellow pics names starting with car_...
 if ( Pic_No == 0 ) LogsW = ::GUISprite( "car_1.jpg", VectorScreen( 0, 0 ) );
 if ( Pic_No == 1 ) LogsW = ::GUISprite( "car_2.jpg", VectorScreen( 0, 0 ) );
 if ( Pic_No == 2 ) LogsW = ::GUISprite( "car_3.jpg", VectorScreen( 0, 0 ) );
 
 LogsW.Size = cScreenSize;
 LogsB = ::GUIMemobox( VectorScreen( 32, 32 ), VectorScreen( cScreenSize.X - 80, cScreenSize.Y - 64 ), Colour( 255, 255, 255, 128 ), GUI_FLAG_TEXT_TAGS );
 LogsB.HistorySize = 255;
 LogsS = ::GUIScrollbar( VectorScreen( cScreenSize.X - 48, 32 ), VectorScreen( 16, cScreenSize.Y - 64 ) );
 LogsE = ::GUILabel(VectorScreen( cScreenSize.X - 28, cScreenSize.Y / 2 - 10 ), Colour( 179, 0, 0 ), "Exit" );
 DecidePage( );
 LogsE.TextAlignment = GUI_ALIGN_LEFT;
 LogsE.FontName = "Corbel";
 LogsE.FontSize = 13;
 LogsE.AddFlags( GUI_FLAG_MOUSECTRL );
 ::GUI.SetMouseEnabled( );
 }

function DecidePageButtons( )
 {
 if ( ShowGUI == 0 ) return;
 
 if ( ( LogsS.BarPosition != 0 && LogsP != null ) || ( LogsS.BarPosition != 1 && LogsN != null ) ) RemovePageButtons( );
 
 if ( LogsS.BarPosition != 0 && LogsS.BarPosition != 1 ) return;
 
 if ( LogsS.BarPosition == 0 && LogsP == null && PageID != 1 )
  {
  RemovePageButtons( );
  local cScreenSize = GUI.GetScreenSize();
  LogsP = GUIButton( VectorScreen( cScreenSize.X - 130, 7 ), VectorScreen( 85, 20 ), Colour( 140, 140, 140 ), "Previous Page", ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE ) );
  LogsP.TextColour  = COLOR_BLUE;
  return;
  }
 
 if ( LogsS.BarPosition == 1 && LogsN == null && PageID != MaxPages )
  {
  RemovePageButtons( );
  local cScreenSize = GUI.GetScreenSize();
  LogsN = GUIButton( VectorScreen( cScreenSize.X - 130, cScreenSize.Y - 27 ), VectorScreen( 65, 20 ), Colour( 140, 140, 140 ), "Next Page", ( GUI_FFLAG_BOLD | GUI_FFLAG_ULINE ) );
  LogsN.Alpha = 200;
  LogsN.TextColour  = COLOR_BLUE;
  return;
  }
 }

function ScrollbarScroll( scrollbar, position )
 {
 if ( !ShowGUI ) return;
 
 switch( scrollbar )
  {
  case LogsS:
   GUI_ServerLogs.DecidePageButtons( );
   GUI_ServerLogs.LogsB.DisplayPos = 1 - position;
  break;
  }
 }

function ElementClick( element )
 {
 if ( !ShowGUI ) return;
 
 switch( element )
  {
  case LogsE:
   Close( );
  break;
  }
 }

function ElementRelease( element )
 {
 if ( !ShowGUI ) return;
 
 switch( element )
  {
  case LogsN:
   PageID++;
   DecidePage( );
  break;
  case LogsP:
   PageID--;
   DecidePage( );
  break;
  }
 }

function GameResize( )
 {
 if ( !ShowGUI ) return;
 
 Close( );
 }
 
function RemovePageButtons( )
 {
 if ( !ShowGUI ) return;
 
 if ( LogsN != null ) LogsN = null;
 if ( LogsP != null ) LogsP = null;
 }

function DecidePage( )
 {
 if ( !ShowGUI ) return;
 
 local NPageID = PageID + 1;
 RemovePageButtons( );
 LogsB.Clear();
 LogsB.AddLine( "", Colour( 64, 64, 64 ) );
 LogsB.AddLine( "Grand Theft Auto Asian City ChangeLogs Page: "+PageID, Colour( 150, 0, 50 ) );
 if ( PageID == 1 ) foreach ( lr in ::split( SvrLogs3, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );
 else if ( PageID == 2 ) foreach ( lr in ::split( SvrLogs2, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );
 else if ( PageID == 3 ) foreach ( lr in ::split( SvrLogs1, "\n" ) ) LogsB.AddLine( lr, Colour( 64, 64, 64 ) );
 
 if ( PageID == MaxPages ) LogsB.AddLine( "End of server changelogs.", Colour( 150, 0, 50 ) );
 else LogsB.AddLine( "Click on next page button for page: "+NPageID, Colour( 150, 0, 50 ) );
 
 LogsS.BarPosition = 0;
 LogsB.DisplayPos = 1;
 }

function Close( )
 {
 if ( !ShowGUI ) return;
 
 LogsW = null;
 LogsB = null;
 LogsS = null;
 LogsE = null;
 LogsN = null;
 LogsP = null;
 ::GUI.SetMouseEnabled(false);
 
 ShowGUI = 0;
 }

function Show( )
 {
 if ( ShowGUI ) return;
 ShowGUI = 1;
 Create( );
 }

function Decide( )
 {
 if ( ShowGUI ) Close( );
 else Show( );
 }
}

function Script::ScriptLoad( )
{
keyBIND_F1 <- KeyBind( 0x70 );
dofile( "messages.nut" );  //This is the file from which we are going to read memobox data.
}

function GUI::ScrollbarScroll( scrollbar, position, change )
{
GUI_ServerLogs.ScrollbarScroll( scrollbar, position );
}

function GUI::ElementClick(element, mousex, mousey)
{
GUI_ServerLogs.ElementClick( element );
}

function KeyBind::OnDown( keyBind )
{
if ( keyBind == keyBIND_F1 ) GUI_ServerLogs.Decide( );
}

function GUI::ElementRelease(element, mouseX, mouseY)
{
GUI_ServerLogs.ElementRelease( element );
}

function GUI::GameResize( width, height )
{
GUI_ServerLogs.GameResize( );
}
[/noae][/noae]


!

Quote from: KrooB on Jul 07, 2018, 07:58 PMbro i try but not worked your code , sprites & message.nut everything right loc

Take these two lines out of your Script::ScriptLoad( ) to the top.
keyBIND_F1 <- KeyBind( 0x70 );
COLOR_BLUE   <- Colour( 0, 0, 255 );

Here's the sample file.

Quote from: ! on Aug 31, 2017, 12:50 PM[spoiler=Sample_Store_File]

[/spoiler]

Discord: zeus#5155