Jump to content

LOADINGSCREEN CARREGANDO EM LOOP


Recommended Posts

Olá, estou com um loadingscreen que quando o player entra no sv baixando os arquivos a loading aparece. porem quando o download acaba ela continua carregando ifinitamente e não para

 

--Client

local sx, sy = guiGetScreenSize()
local x, y = (sx/1366), (sy/768)
local resourceRoot = getResourceRootElement(getThisResource())
local screenWidth, screenHeight = guiGetScreenSize()
local myScreenSource = dxCreateScreenSource(screenWidth, screenHeight)
local root = getRootElement()
local rote = 0
local musica = true
local Tipo = nil
local pLife = {}
local AlphaAB = 0

function pLife.iniciarLoadingScreen()
    PlayMusicLoandig = playSound("olds/sound/music.mp3", true)
    Tipo = "Play"
	setSoundVolume(PlayMusicLoandig,1.0)
	showCursor(true)
	showChat(false)
	addEventHandler("onClientRender", root, pLife.MenuDxLoad)
end
addEventHandler("onClientResourceStart", resourceRoot, pLife.iniciarLoadingScreen)

function pLife.fimLoandingScreen()    
    if isTransferBoxActive() == true then
        setTimer(pLife.fimLoandingScreen, 2000, 1)
    else 
        removeEventHandler("onClientRender", root, pLife.MenuDxLoad)
		destroyElement(PlayMusicLoandig)
		showCursor(false)
		showChat(true)
		musica = false
    end
end
setTimer(pLife.fimLoandingScreen, 2000, 1)

pLife = {}
pLife["img"] = 1
pLife["timer"] = setTimer(function()
	pLife["img"] = 1 and 2
end, 40000, 0)

function pLife.MenuDxLoad()
	rote = rote +12/8
    local seconds = getTickCount() / 6000
    local scale = math.sin(seconds) * 1
    local seconds2 = getTickCount() / 4000
    local scale2 = math.sin(seconds2) * 1
	local rotation2 = 0
	local AnimStouro = getSoundFFTData(PlayMusicLoandig, 2048, 2)
	for i,v in pairs(AnimStouro) do
		rotation1 = math.round((v*530),0)
		rotation2 = math.round((v*430),0) + 7
	end

	AlphaAB = AlphaAB + 0.4
    if AlphaAB >= 255 then 
    	AlphaAB = 255
    end

		dxDrawImage(x*0, y*0, x*1366, y*768, "olds/images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
		dxDrawImage(x*0, y*0, x*1366, y*768, "olds/images/lights.png", 0, 0, 0, tocolor(255, 255, 255, 0*rotation1+rotation2), false)

        dxDrawImage(x*630/scale, y*280, x*94, y*160, "olds/images/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*580, y*240/scale, x*117, y*90, "olds/images/coroa.png", 330, 0, 0, tocolor(255, 255, 255, 255), false)

        dxDrawImage(x*30, y*205, x*17, y*34, "olds/images/pausa.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(x*72, y*205, x*32, y*34, "olds/images/play.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)

        if Tipo == "Pausa" then
        	dxDrawImage(x*30, y*205, x*17, y*34, "olds/images/pausa.png", 0, 0, 0, tocolor(0, 111, 255, 255), false)
        elseif Tipo == "Play" then
        	dxDrawImage(x*72, y*205, x*32, y*34, "olds/images/play.png", 0, 0, 0, tocolor(0, 111, 255, 255), false)
    	end

    	dxDrawImage(x*-24/scale2, y*163, x*441, y*636, "olds/images/"..pLife["img"]..".png", 0, 0, 0, tocolor(255, 255, 255, AlphaAB), false)
        
        dxDrawImage(x*623, y*627, x*100, y*100, "olds/images/load.png", rote, 0, 0, tocolor(255, 255, 255, 255), false)
end

addEventHandler('onClientClick', root, function(button, state, _, _, _, _, _, element)
	if button == 'left' and state == 'down' and musica then 
		if cursorPosition(x*30, y*205, x*17, y*34) then
			setSoundPaused(PlayMusicLoandig, true)
			Tipo = "Pausa"
		elseif cursorPosition(x*72, y*205, x*32, y*34) then
			setSoundPaused(PlayMusicLoandig, false)
			Tipo = "Play"
		end
	end
end)

function pLife.OnStop ()
    setPlayerHudComponentVisible("armour", true)
    setPlayerHudComponentVisible("wanted", true)
    setPlayerHudComponentVisible("weapon", true)
    setPlayerHudComponentVisible("money", true)
    setPlayerHudComponentVisible("health", true)
    setPlayerHudComponentVisible("clock", true)
    setPlayerHudComponentVisible("breath", true)
    setPlayerHudComponentVisible("ammo", true)
    setPlayerHudComponentVisible("radar", true)
end
addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), pLife.OnStop)
function pLife.OnStart ()
    setPlayerHudComponentVisible("armour", false)
    setPlayerHudComponentVisible("wanted", false)
    setPlayerHudComponentVisible("weapon", false)
    setPlayerHudComponentVisible("money", false)
    setPlayerHudComponentVisible("health", false)
    setPlayerHudComponentVisible("clock", false)
    setPlayerHudComponentVisible("breath", false)
    setPlayerHudComponentVisible("ammo", false)
    setPlayerHudComponentVisible("radar", false)
end
addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), pLife.OnStart )

 

 

--Shared

function cursorPosition(x, y, width, height)
	if(not isCursorShowing()) then
		return false
	end
	local sx, sy = guiGetScreenSize()
	local cx, cy = getCursorPosition()
	local cx, cy =(cx*sx),(cy*sy)
	if(cx >= x and cx <= x + width) and(cy >= y and cy <= y + height) then
		return true
	else
		return false
	end
end

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if(method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

 

-- META

<meta>
	<script src="loadC.lua" type="client"/>
	<script src="loadG.lua" type="shared"/>

	<file src="olds/images/1.png"/>
	<file src="olds/images/2.png"/>
	<file src="olds/images/bg.png"/>
	<file src="olds/images/load.png"/>

	<file src="olds/images/logo.png"/>
	<file src="olds/images/pausa.png"/>
	<file src="olds/images/play.png"/>
	<file src="olds/images/coroa.png"/>
	<file src="olds/images/lights.png"/>

	<file src="olds/sound/music.mp3"/>
	
	<download_priority_group>1</download_priority_group>
</meta>

 

Link to comment
4 hours ago, Boechat said:

Tenta colocar isso no mod que executa quando o server estiver "pronto", como na tela de login por exemplo


removeEventHandler("onClientRender", root, pLife.MenuDxLoad)

 

Não entendi, que mod? o RemoveEvent ja esta no client. 

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...