Jump to content

stopSond


Recommended Posts

Olá, pq a musica não para quando finaliza o download? Já tentei fazer que parasse com o "stopSound" mas não funcionou da forma que fiz :(

 

client:

if getElementData(root, "player:uid") then return end

local screenW, screenH = guiGetScreenSize()
local startTicking = getTickCount()
local rotation = 0
local wFont = dxCreateFont("czcionka.ttf", 12)
local wFont2 = dxCreateFont("czcionka.ttf", 10)

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
	if 
		type( sEventName ) == 'string' and 
		isElement( pElementAttachedTo ) and 
		type( func ) == 'function' 
	then
		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
			for i, v in ipairs( aAttachedFunctions ) do
				if v == func then
					return true
				end
			end
		end
	end
	return false
end

function loadingDownload()
  
	local hype = interpolateBetween(0, 0, 0, -15, 100, 0, ((getTickCount() - startTicking) / 2500), "SineCurve")
	local hype2 = interpolateBetween(0, 0, 0, -35, 300, 0, ((getTickCount() - startTicking) / 2500), "SineCurve")

	rotation = rotation - 2 > 360 and 0 or rotation - 2
  
	dxDrawImage(screenW * 0.0000, screenH * 0.0000, screenW, screenH, "images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true)
  
	dxDrawText("Baixando...", screenW * 0.0400, screenH * 1.8500, screenW * 0.9846, screenH * 0.0898, tocolor(255, 255, 255, 225), 1, wFont, "left", "center", false, false, false, false, false)
 
end
addEventHandler("onClientRender", root, loadingDownload)

function loadingObjects()
  
	local hype = interpolateBetween(0, 0, 0, -15, 100, 0, ((getTickCount() - startTicking) / 2500), "SineCurve")
	local hype2 = interpolateBetween(0, 0, 0, -35, 300, 0, ((getTickCount() - startTicking) / 2500), "SineCurve")

	rotation = rotation - 2 > 360 and 0 or rotation - 2
  
	dxDrawImage(screenW * 0.0000, screenH * 0.0000, screenW, screenH, "images/bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	--dxDrawImage(screenW * 0.4253, screenH * 0.3400 + hype, screenW * 0.1799, screenH * 0.3085, "images/logo.png", 0, 0, 0, tocolor(255, 255, 255, 220), false)
                dxDrawImage(x*694, y*519, x*181, y*46, "Img/bg.png", 0, 0, 0, corRetirar, true)
  
	dxDrawText("Baixando...", screenW * 0.0400, screenH * 1.8500, screenW * 0.9846, screenH * 0.0898, tocolor(255, 255, 255, 225), 1, wFont, "left", "center", false, false, false, false, false)
	dxDrawText("", screenW * 0.0550, screenH * 1.2010 + hype2, screenW * 0.9846, screenH * 0.0898, tocolor(255, 255, 255, 225), 1, wFont2, "center", "center", false, false, false, false, false)
 
end

function iniciarMusica()
    sound = playSound( "images/soung.mp3", true )
end
addEventHandler( "onClientResourceStart", resourceRoot, iniciarMusica )


function checkingIsDownload()
	if getElementData(root, "player:uid") then return end
	if isTransferBoxActive() == true then
		addEventHandler("onClientRender", root, loadingDownload)
		addEventHandler("onClientResourceStart", root, resourceRoot)
		showCursor(true)
		showChat(false)
	else
		if isEventHandlerAdded("onClientRender", root, loadingDownload) then
			removeEventHandler("onClientRender", root, loadingDownload)
			removeEventHandler("onClientResourceStart", root, resourceRoot)
			showCursor(false)
			showChat(true)
			stopSound(piosenka)
		end
	end
end
setTimer(checkingIsDownload, 500, 0)

function checkingIsComingObject()
	if getElementData(root, "load:objects") then
		addEventHandler("onClientRender", root, loadingObjects)
		addEventHandler("onClientResourceStart", root, resourceRoot)
		showCursor(true)
		showChat(false)
	else
		if isEventHandlerAdded("onClientRender", root, loadingObjects) then
			removeEventHandler("onClientRender", root, loadingObjects)
			removeEventHandler("onClientResourceStart", root, resourceRoot)
			showCursor(false)
			showChat(true)
		end
	end
end
setTimer(checkingIsComingObject, 500, 0)

function filedelet ()
if fileExists("loading_c.Lua") then
   fileDelete("loading_c.Lua")
 end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), filedelet)

 

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...