Notes
Notes - notes.io |
Author: Blaawee
]]--
Arenas =
{
[ 1 ] = { name = 'Freeroam', new = false, state = 'closed', img = 'images/freeroam.png', maxplayers = 100, parent = 'freeroam', rooms = 0, roomsName = {} },
[ 2 ] = { name = 'Deathmatch', new = true, state = 'open', img = 'images/deathmatch.png', maxplayers = 20, parent = 'deathmatch', rooms = 4, roomsName = { 'Team DeatMatch', 'DeathMatch', 'Fight', 'GunGame' } },
[ 3 ] = { name = 'Race', new = false, state = 'closed', img = 'images/race.png', maxplayers = 30, parent = 'race', rooms = 4, roomsName = { 'Derbby', 'Hunter', 'Test1', 'Test2' } }
};
selection = { };
screenSize = { guiGetScreenSize( ) };
selectionSetting =
{
selected = 1,
roomSelected = 1,
state = 'starting',
phase = 0,
lastTick = getTickCount( ),
title = { Text = 'Choose a gamdemode', font = dxCreateFont( 'fonts/kimberley.ttf', 30 ) },
};
local loading = false;
function selection.setSettings( state, phase )
selectionSetting.state = state or 'starting';
selectionSetting.phase = phase or 0;
selectionSetting.lastTick = getTickCount( );
end
function selection.getProgress( addTick )
local now = getTickCount( );
local elapsedTime = now - selectionSetting.lastTick;
local duration = selectionSetting.lastTick + addTick - selectionSetting.lastTick;
local progress = elapsedTime / duration;
return progress;
end
function selection.choseGameMode( Key )
if selectionSetting.state ~= 'ready' then
return
end
if ( Key == 'arrow_r' ) then
if ( selectionSetting.selected == #Arenas ) then
selectionSetting.selected = 1;
selection.setSettings( 'toRight', 0 );
else
selectionSetting.selected = selectionSetting.selected + 1;
selection.setSettings( 'toRight', 0 );
end
selectionSetting.roomSelected = 1;
else
if ( selectionSetting.selected == 1 ) then
selectionSetting.selected = #Arenas;
selection.setSettings( 'toLeft', 0 );
else
selectionSetting.selected = selectionSetting.selected - 1;
selection.setSettings( 'toLeft', 0 );
end
selectionSetting.roomSelected = 1;
end
playSound( 'sounds/click.wav' );
end
function selection.choseGameModeRoom( Key )
if ( selectionSetting.state ~= 'ready' ) then
return
end
if ( not Arenas[ selectionSetting.selected ].rooms ) then
return
end
if ( Arenas[ selectionSetting.selected ].state == 'closed' ) then
return
end
if ( Key == 'arrow_d' ) then
if ( selectionSetting.roomSelected == Arenas[ selectionSetting.selected ].rooms ) then
selectionSetting.roomSelected = 1;
else
selectionSetting.roomSelected = selectionSetting.roomSelected + 1;
end
else
if ( selectionSetting.roomSelected == 1 ) then
selectionSetting.roomSelected = Arenas[ selectionSetting.selected ].rooms;
else
selectionSetting.roomSelected = selectionSetting.roomSelected - 1;
end
end
playSound( 'sounds/click.wav' );
end
function selection.selectGameMode( Key )
if selectionSetting.state ~= 'ready' then
return
end
if ( Key == 'enter' ) then
if Arenas[ selectionSetting.selected ].state ~= 'closed' then
triggerEvent( 'onClientArenaJoin', localPlayer, localPlayer, Arenas[ selectionSetting.selected ].name )
selection.loadArena( selectionSetting.selected )
end
playSound( 'sounds/click.wav' );
end
end
function selection.loadArena( theID )
if ( theID ) then
selection.setSelectionMode( false )
if ( getElementData( localPlayer, 'Arena' ) ~= theID ) then
selection.unloadArena( );
setElementData( localPlayer, 'Arena', theID );
-- For testing..
if ( theID == 1 ) then
--fadeCamera( false );
triggerServerEvent( 'onClientJoinFreeroam', localPlayer );
elseif ( theID == 2 ) then
triggerServerEvent( 'onClientJoinDeathmatch', localPlayer );
end
end
end
end
function selection.unloadArena( )
local playerArena = getElementData( localPlayer, 'Arena' )
if ( playerArena ) then
unloadMap();
if ( playerArena == 1 ) then
triggerServerEvent( 'onClientQuitFreeroam', localPlayer );
elseif ( playerArena == 2 ) then
triggerServerEvent( 'onClientQuitDeathmatch', localPlayer );
end
end
end
function selection.render( )
-- Starting.
if ( selectionSetting.state == 'starting' ) then
local textY, textAlpha = interpolateBetween( 0, 0, 0, 50, 255, 0, selection.getProgress( 2000 ), 'Linear' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, textY, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, textAlpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
if ( selectionSetting.lastTick + 2300 <= getTickCount( ) ) then
selection.setSettings( 'animation', 1 );
end
elseif ( selectionSetting.state == 'animation' ) then
-- Anim [ 1 ].
if ( selectionSetting.phase == 1 ) then
local width, higth = interpolateBetween( 512, 512, 0, 256, 256, 0, selection.getProgress( 2000 ), 'InOutBack' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, 255 ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
dxDrawImage( screenSize[ 1 ] / 2 - 256 / 2, screenSize[ 2 ] / 2 - 256 / 2, width, higth, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, 255 ), false );
if ( selectionSetting.lastTick + 3000 <= getTickCount( ) ) then
selection.setSettings( 'animation', 2 );
end
--Anim [ 2 ].
elseif ( selectionSetting.phase == 2 ) then
local textAlpha = interpolateBetween( 0, 0, 0, 255, 0, 0, selection.getProgress( 2000 ), 'Linear' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, 255 ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
dxDrawImage( screenSize[ 1 ] / 2 - 256 / 2, screenSize[ 2 ] / 2 - 256 / 2, 256, 256, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, 255 ), false );
dxDrawText( Arenas[ selectionSetting.selected ].name, screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].name, 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 - 128 - dxGetFontHeight( 1, selectionSetting.title.font ) - 5, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, textAlpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
if ( selectionSetting.lastTick + 2000 <= getTickCount( ) ) then
selection.setSettings( 'ready', 0 );
end
end
-- To right.
elseif ( selectionSetting.state == 'toRight' ) then
local right, alpha = interpolateBetween( 0, 0, 0, screenSize[ 1 ] / 2 - 256 / 2, 255, 0, selection.getProgress( 1000 ), 'Linear' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, alpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
dxDrawImage( right, screenSize[ 2 ] / 2 - 256 / 2, 256, 256, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, alpha ), false );
dxDrawText( Arenas[ selectionSetting.selected ].name, screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].name, 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 - 128 - dxGetFontHeight( 1, selectionSetting.title.font ) - 5, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, alpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
if ( selectionSetting.lastTick + 1000 <= getTickCount( ) ) then
selection.setSettings( 'ready', 0 );
end
-- To left.
elseif ( selectionSetting.state == 'toLeft' ) then
local left, alpha = interpolateBetween( screenSize[ 1 ] / 2 + 900 / 2, 0, 0, screenSize[ 1 ] / 2 - 256 / 2, 255, 0, selection.getProgress( 1000 ), 'Linear' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, alpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
dxDrawImage( left, screenSize[ 2 ] / 2 - 256 / 2, 256, 256, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, alpha ), false );
dxDrawText( Arenas[ selectionSetting.selected ].name, screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].name, 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 - 128 - dxGetFontHeight( 1, selectionSetting.title.font ) - 5, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, alpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
if ( selectionSetting.lastTick + 1000 <= getTickCount( ) ) then
selection.setSettings( 'ready', 0 );
end
-- Ready.
elseif ( selectionSetting.state == 'ready' ) then
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, 255 ), 1, selectionSetting.title.font, 'left', 'top', false, true, false, true );
dxDrawImage( screenSize[ 1 ] / 2 - 256 / 2, screenSize[ 2 ] / 2 - 256 / 2, 256, 256, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, 255 ), false );
dxDrawText( Arenas[ selectionSetting.selected ].name, screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].name, 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 - 128 - dxGetFontHeight( 1, selectionSetting.title.font ) - 5, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, 255 ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
------------------------------------------------------
-- The Rooms part.
if ( Arenas[ selectionSetting.selected ].rooms and Arenas[ selectionSetting.selected ].state ~= 'closed' ) then
for i = 1, Arenas[ selectionSetting.selected ].rooms do
Arenas[ selectionSetting.selected ].roomsPosX = screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].roomsName[ i ], 1, selectionSetting.title.font ) / 2 + 5
Arenas[ selectionSetting.selected ].roomsPosY = screenSize[ 2 ] / 2 + 128 - 20 + ( i + 1 ) * 33
dxDrawText( Arenas[ selectionSetting.selected ].roomsName[ i ], Arenas[ selectionSetting.selected ].roomsPosX , Arenas[ selectionSetting.selected ].roomsPosY , screenSize[ 1 ], screenSize[ 2 ], tocolor(255,255,255,255), 1, selectionSetting.title.font, 'left', 'top', false, true, false, true)
end
-- The Highlighted part
if Arenas[ selectionSetting.selected ].roomsName[ selectionSetting.roomSelected ] then
local roomName = Arenas[ selectionSetting.selected ].roomsName[ selectionSetting.roomSelected ]
local roomPosX = Arenas[ selectionSetting.roomSelected ].roomsPosX
local roomPosY = Arenas[ selectionSetting.roomSelected ].roomsPosY
dxDrawText( roomName, roomPosX, roomPosY, screenSize[ 1 ], screenSize[ 2 ], tocolor(255,255,0,255), 1, selectionSetting.title.font, 'left', 'top', false, true, false, true)
end
end
---------------------------------------------------------
if ( Arenas[ selectionSetting.selected ].state == 'closed' ) then
dxDrawText( 'Closed', screenSize[ 1 ] / 2 - dxGetTextWidth( 'Closed', 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 + 128 - 20, screenSize[ 1 ], screenSize[ 2 ], tocolor( 225, 10, 0, 255 ), 1, selectionSetting.title.font, "left", "top", false, false, false, false );
end
if ( Arenas[ selectionSetting.selected ].new ) then
dxDrawText( 'New', screenSize[ 1 ] / 2 - dxGetTextWidth( 'New', 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 + 128 - 20, screenSize[ 1 ], screenSize[ 2 ], tocolor( 10, 225, 0, 255 ), 1, selectionSetting.title.font, "left", "top", false, false, false, true );
end
-- Finished.
elseif ( selectionSetting.state == 'finished' ) then
local textAlpha = interpolateBetween( 255, 0, 0, 0, 0, 0, selection.getProgress( 1000 ), 'Linear' );
local width, higth = interpolateBetween( 256, 256, 0, 0, 0, 0, selection.getProgress( 2000 ), 'InOutBack' );
dxDrawText( selectionSetting.title.Text, screenSize[ 1 ] / 2 - dxGetTextWidth( selectionSetting.title.Text, 1, selectionSetting.title.font ) / 2, 50, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, textAlpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
dxDrawImage( screenSize[ 1 ] / 2 - 256 / 2, screenSize[ 2 ] / 2 - 256 / 2, width, higth, Arenas[ selectionSetting.selected ].img, 0, 0, 0, tocolor( 255, 255, 255, textAlpha ), false );
dxDrawText( Arenas[ selectionSetting.selected ].name, screenSize[ 1 ] / 2 - dxGetTextWidth( Arenas[ selectionSetting.selected ].name, 1, selectionSetting.title.font ) / 2, screenSize[ 2 ] / 2 - 128 - dxGetFontHeight( 1, selectionSetting.title.font ) - 5, screenSize[ 1 ], screenSize[ 2 ], tocolor( 255, 255, 255, textAlpha ), 1, selectionSetting.title.font, 'left', 'top', false, false, false, true );
if ( selectionSetting.lastTick + 1200 <= getTickCount( ) ) then
removeEventHandler( 'onClientPreRender', root, selection.render );
selection.setSettings( 'starting', 0 );
end
end
end
addEvent( 'setSelectionMode', true )
function selection.setSelectionMode( bool )
if bool then
addEventHandler( 'onClientPreRender', root, selection.render );
bindKey ( 'arrow_l', 'down', selection.choseGameMode );
bindKey ( 'arrow_r', 'down', selection.choseGameMode );
bindKey ( 'arrow_u', 'down', selection.choseGameModeRoom );
bindKey ( 'arrow_d', 'down', selection.choseGameModeRoom );
bindKey ( 'enter', 'down', selection.selectGameMode );
else
selection.setSettings( 'finished', 0 );
unbindKey ( 'arrow_l', 'down', selection.choseGameMode );
unbindKey ( 'arrow_r', 'down', selection.choseGameMode );
unbindKey ( 'arrow_u', 'down', selection.choseGameModeRoom );
unbindKey ( 'arrow_d', 'down', selection.choseGameModeRoom );
unbindKey ( 'enter', 'down', selection.selectGameMode );
end
end
addEventHandler( 'setSelectionMode', root, selection.setSelectionMode );
addEventHandler( 'onClientResourceStart', resourceRoot,
function()
selectionSetting.title.font = 'arial';
selection.setSelectionMode( true ) ;
end
)
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team