[YARDIM] Çalacak Sesin Saniyesini Ayarlama

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı cenk11

  • Yeni Üye
  • *
    • İleti: 47
: 18 Kasım 2018, 14:24:27
selamlar
ekrana gelen mesaja playsound ekledim ve ses çalıyor fakat mesaj 10 saniye gösterilirken ses 1 saniye seside 10 saniye çalıyor ve kötü sesler çıkıyor.kod uzun oldugu için ortasından paylaşıcam.playSound eklediğim satır için zaman ekleyemedim setTimer denedim wikiden fakat yapamadım yardımcı olurmusunuz.
Kod: lua
		messages_top[i+1][6] = y
local lColor = tocolor ( 0, 0, 0, 255 )
dxDrawRectangle ( (sx/2-width/2), rsy*y, width, rsy*25, tocolor ( 0, 0, 0, 100 ) )
dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2)+width, rsy*y, lColor )
dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2), rsy*(y+25), lColor )
dxDrawLine ( (sx/2+width/2), rsy*y, (sx/2+width/2), rsy*(y+25), lColor )
dxDrawLine ( (sx/2+width/2)-width, rsy*(y+25), (sx/2+width/2), rsy*(y+25), lColor )

if ( v[8] and v[8] ~= "" ) then
dxDrawImage ( (sx/2-width/2)+3, (rsy*y)+2, rsx*21, rsy*21, v[8] );
dxDrawImage ( (sx/2-width/2)+(width-25), (rsy*y)+2, rsx*21, rsy*21, v[8] );
end

dxDrawText ( v[1], 0, rsy*y, sx, rsy*(y+25), tocolor ( 220,220,200, 255 ), rsx*1, "sans", "center", "center", true, false, false, true )
                playSound ("mesajsesi.wav")


if ( not continue ) then
table.insert ( doRemove, i+1 )
end
end

if ( #doRemove > 0 ) then
for i, v in ipairs ( doRemove ) do
if ( messages_top [ v ] ) then
table.remove ( messages_top, v )
end
end
end
end
addEventHandler ( "onClientRender", root, dxDrawNotificationBar )
« Son Düzenleme: 05 Aralık 2018, 15:05:07 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Çalacak Sesin Saniyesini Ayarlama
« : 18 Kasım 2018, 14:24:27 »

Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #1 : 18 Kasım 2018, 14:44:03
"onClientRender" bu event sürekli gerçekleştiği için sürekli olarak sesi başlatır buda senin kötü ses diye tabir ettiğin şeydir. "playSound" fonksiyonunu farklı bir yere koyman gerekli onun içinde kodun tamamını atabilirsen yardımcı olurum.
 


Çevrimdışı cenk11

  • Yeni Üye
  • *
    • İleti: 47
Yanıtla #2 : 18 Kasım 2018, 15:09:52
tamamdır bütün clienti paylasıyorum.en altta olan join quit mesajlarında ses düzgün çalışıyor diğer dx mesaj çalısmıyordu.

Kod: lua
local useTopbar = true
local joinquit = true
local namechanges = true
local sx, sy  = guiGetScreenSize ( )
local rsx, rsy = sx / 1280, sy / 1024

addEvent ( "onClientPlayerLogin", true )
addEventHandler ( "onClientPlayerLogin", root, function ( )
if not useTopbar then
useTopbar = false
removeEventHandler ( "onClientRender", root, dxDrawNotificationBar )
end
end )

addEvent ( "onClientUserSettingChange", true )
addEventHandler ( "onClientUserSettingChange", root, function ( g, v )
if ( g == "usersettings_usetopbar" ) then
if not tobool ( v ) and useTopbar then
useTopbar = false
removeEventHandler ( "onClientRender", root, dxDrawNotificationBar )
elseif tobool ( v ) and not useTopbar then
useTopbar = true
addEventHandler ( "onClientRender", root, dxDrawNotificationBar )
end
elseif ( g == "usersetting_notification_joinquitmessages" ) then
joinquit = v
elseif ( g == "usersetting_notification_nickchangemessages" ) then
namechanges = v
end
end )

local maxMessages = 5;
local DefaultTime = 8;
local moveSpeed = 2;
local sx, sy = guiGetScreenSize ( )
local DefaultPos = true;
local messages_top = { }
local toDo = { }
local messageDelay = 500
local TheResourceName = getResourceName ( getThisResource ( ) )
local lastAutoMessage = 1
local t = 0

function sendClientMessage ( msg, r, g, b, img, checkImgPath )

if ( checkImgPath == nil ) then checkImgPath = true; end

if ( img and sourceResource and checkImgPath ) then
img = ":"..tostring(getResourceName(sourceResource)).."/"..img;
end

return _sendClientMessage ( msg, r, g, b, img );
end


function _sendClientMessage ( msg, r, g, b, img )

if ( useTopbar ) then
--if ( not exports.NGLogin:isClientLoggedin ( ) ) then return end
local msg, r, g, b = tostring ( msg ), tonumber ( r ) or 255, tonumber ( g ) or 255, tonumber ( b ) or 255

local img = img or "";

if ( img ~= "" and not fileExists ( img ) ) then
img = ""
end

local data = {
msg,
r,
g,
b,
getTickCount ( ) + DefaultTime*1000,
-25,
true,
img
}


if ( getTickCount ( ) - t >= messageDelay ) then
table.insert ( messages_top, data )
t = getTickCount ( )
else
table.insert ( toDo, data )
end
else
outputChatBox ( msg, r, g, b )
end
end
addEvent ( TheResourceName..":sendClientMessage", true )
addEventHandler ( TheResourceName..":sendClientMessage", root, _sendClientMessage )

local width = (sx/1.95)
local t2 = getTickCount ( )

--[[
.:Table Format:.
[1] = message,
[2] = red count,
[3] = green count,
[4] = blue count,
[5] = Remove Time,
[6] = Y Axis,
[7] = Is Locked,
[8] = Image icon path
]]

function dxDrawNotificationBar ( )
if ( #toDo > 0 and getTickCount ( ) -t >= messageDelay ) then
local d = toDo[1]
d[5] = getTickCount ( ) + DefaultTime*1000
table.insert ( messages_top, d )
table.remove ( toDo, 1 )
t = getTickCount ( )
end

local doRemove = { }
for i, v in pairs ( messages_top ) do
local i = i - 1
local msg, r, g, b, rTime, y = unpack ( v )
local continue = true
if ( rTime < getTickCount ( ) and v[7] ) then
messages_top[i+1][7] = false
end
if ( v[7] ) then
if ( messages_top[i] ) then
toY = messages_top[i][6] + 25
else
toY = 0
end
if ( y ~= toY ) then
if ( y < toY ) then
y = y + moveSpeed
if ( y > toY ) then
y = toY
end
else
y = y - moveSpeed
if ( y < toY ) then
y = toY
end
end
else
if ( #messages_top > maxMessages ) then
messages_top[1][5] = 0
messages_top[1][7] = false
end
end
else
y = y - moveSpeed
if ( y < -25 ) then
continue = false
end
end
messages_top[i+1][6] = y
local lColor = tocolor ( 0, 0, 0, 255 )
dxDrawRectangle ( (sx/2-width/2), rsy*y, width, rsy*25, tocolor ( 0, 0, 0, 100 ) )
dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2)+width, rsy*y, lColor )
dxDrawLine ( (sx/2-width/2), rsy*y, (sx/2-width/2), rsy*(y+25), lColor )
dxDrawLine ( (sx/2+width/2), rsy*y, (sx/2+width/2), rsy*(y+25), lColor )
dxDrawLine ( (sx/2+width/2)-width, rsy*(y+25), (sx/2+width/2), rsy*(y+25), lColor )

if ( v[8] and v[8] ~= "" ) then
dxDrawImage ( (sx/2-width/2)+3, (rsy*y)+2, rsx*21, rsy*21, v[8] );
dxDrawImage ( (sx/2-width/2)+(width-25), (rsy*y)+2, rsx*21, rsy*21, v[8] );
playSound ("notif.wav")
end

dxDrawText ( v[1], 0, rsy*y, sx, rsy*(y+25), tocolor ( 220,220,200, 255 ), rsx*1, "sans", "center", "center", true, false, false, true )


if ( not continue ) then
table.insert ( doRemove, i+1 )
end
end

if ( #doRemove > 0 ) then
for i, v in ipairs ( doRemove ) do
if ( messages_top [ v ] ) then
table.remove ( messages_top, v )
end
end
end
end
addEventHandler ( "onClientRender", root, dxDrawNotificationBar )

function tobool ( input )
local input = tostring ( input ):lower ( )
if ( input == "true" ) then
return true
elseif ( input == "false" ) then
return false
else
return nil
end
end

--[[
addCommandHandler ( 'rt', function ( )
for i=1,5 do
sendClientMessage ( tostring ( i ), 255, 255, 0 )
end
end )
]]

-- join/quit messages
addEventHandler ( "onClientPlayerJoin", root, function ( )
if joinquit then
sendClientMessage ( "* "..getPlayerName(source).." sunucuya giriş yaptı!", 255, 150, 150 )
    playSound ("notif.wav")
end
end ) addEventHandler ( "onClientPlayerQuit", root, function ( r )
if ( joinquit ) then
sendClientMessage ( "* "..getPlayerName(source).." sunucudan çıkış yaptı. ("..r..")", 255, 150, 150 )
playSound ("mesajsesi.wav")
end
end )

-- Nickname changes
addEventHandler ( "onClientPlayerChangeNick", root, function ( o, n )
sendClientMessage ( "* "..o.." artık şu isimle tanınıyor : "..n, 255, 150, 150 )
playSound ("notif.wav")
end )
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #3 : 18 Kasım 2018, 15:22:58
Diğer dx mesajlar nerde playSound fonksiyonunu oraya koymak gerekli.
 


Çevrimdışı cenk11

  • Yeni Üye
  • *
    • İleti: 47
Yanıtla #4 : 18 Kasım 2018, 15:38:32
server side ta onlar ;

Kod: lua
local messages = { 
"mesajı buraya yazınız.",
"mesajı buraya yazınız. ",
"mesajı buraya yazınız. ",
   }

local lastI = 0
function sendNextAutomatedMessage (  )
lastI = lastI + 1
if ( lastI > #messages ) then
lastI = 1
end

sendClientMessage ( messages [ lastI ], root, math.random ( 150, 255 ), math.random ( 150, 255 ), math.random ( 150, 255 ) )
setTimer ( sendNextAutomatedMessage, 250000, 1 )
end
setTimer ( sendNextAutomatedMessage, 200, 1 )
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #5 : 18 Kasım 2018, 16:18:28
Server
Kod: lua
local messages = { 
        "mesajı buraya yazınız.",
        "mesajı buraya yazınız. ",
        "mesajı buraya yazınız. ",   
   }
 
local lastI = 0
function sendNextAutomatedMessage (  )
        lastI = lastI + 1
        if ( lastI > #messages ) then
                lastI = 1
        end
        triggerClientEvent (resourceRoot, "soundgonder", resourceRoot)
        sendClientMessage ( messages [ lastI ], root, math.random ( 150, 255 ), math.random ( 150, 255 ), math.random ( 150, 255 ) )
        setTimer ( sendNextAutomatedMessage, 250000, 1 )
end
setTimer ( sendNextAutomatedMessage, 200, 1 )

Client'e bu kodu ekle.
Kod: lua
function soundgonder()
    playSound ("mesajsesi.wav")
end
addEvent( "soundgonder", true )
addEventHandler( "soundgonder", getRootElement(getThisResource()), soundgonder)
 


MTASATURK

Ynt: çalacak sesin saniyesini ayarlama (playSound)
« Yanıtla #5 : 18 Kasım 2018, 16:18:28 »

Çevrimdışı cenk11

  • Yeni Üye
  • *
    • İleti: 47
Yanıtla #6 : 18 Kasım 2018, 16:33:30
olmadı abi eksiksiz yaptım deliriyorum sağol ilgilendiğin için :/
 


Çevrimdışı Paradox

  • Kurucu
  • *
    • İleti: 684
  • SH Gaming
Yanıtla #7 : 18 Kasım 2018, 16:45:18
Kod: lua
local messages = { 
        "mesajı buraya yazınız.",
        "mesajı buraya yazınız. ",
        "mesajı buraya yazınız. ",   
   }
 
local lastI = 0
function sendNextAutomatedMessage (  )
        lastI = lastI + 1
        if ( lastI > #messages ) then
                lastI = 1
        end
        triggerClientEvent (root, "soundgonder", root)
        sendClientMessage ( messages [ lastI ], root, math.random ( 150, 255 ), math.random ( 150, 255 ), math.random ( 150, 255 ) )
        setTimer ( sendNextAutomatedMessage, 250000, 1 )
end
setTimer ( sendNextAutomatedMessage, 200, 1 )
Bu şekilde dene birde.
« Son Düzenleme: 18 Kasım 2018, 17:07:42 Gönderen: Paradox »
 


Çevrimdışı cenk11

  • Yeni Üye
  • *
    • İleti: 47
Yanıtla #8 : 18 Kasım 2018, 17:20:06
sorun çözüldü yardım için çok teşekkürler :)