[YARDIM] Araç Özel Korna Nasıl Yaparım

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı kastamonu02

  • Yeni Üye
  • *
    • İleti: 7
: 04 Kasım 2018, 13:31:31
Merhaba. Sizlerden bir ricam var şöle bi sc yapmak istiyorum araca binince bi tuşa bascan korna gibi o çalıcak nasıl yaparım?
« Son Düzenleme: 07 Kasım 2018, 23:28:40 Gönderen: Narkoz »
 


MTASATURK

[YARDIM] Araç Özel Korna Nasıl Yaparım
« : 04 Kasım 2018, 13:31:31 »

Çevrimdışı Violent

  • Yeni Üye
  • *
    • İleti: 42
Yanıtla #1 : 04 Kasım 2018, 14:10:21
Kod: lua
-- Server-side
local function seslikorna ( thePlayer, key, keyState )
    local theVehicle = getPedOccupiedVehicle ( thePlayer )
    if ( not theVehicle ) then
       return
    end
     
    if ( getElementModel ( theVehicle ) == 579 ) or ( getElementModel( theVehicle ) == 507 ) or ( getElementModel( theVehicle ) == 560 ) then -- Hangi araçlarda çalmasını istiyorsan buraya or .... şeklinde ekle.
        triggerClientEvent ( "AracKorna", root, ( keyState == "down" and true or false ), theVehicle )
    end
end

addEventHandler ( "onResourceStart", resourceRoot,
    function ( )
        for _, player in ipairs ( getElementsByType ( "player" ) ) do
            bindKey ( player, "H", "down", seslikorna )
            bindKey ( player, "H", "up", seslikorna )
        end
    end
    )
     
addEventHandler ( "onPlayerJoin", root,
    function ( )
        bindKey ( source, "H", "down", seslikorna )
        bindKey ( source, "H", "up", seslikorna )
    end
)
Kod: lua
-- Client-side
addEvent ( "AracKorna", true )
addEventHandler ( "AracKorna", root,
    function ( state, theVehicle )
        if isElement ( AracKornaSesi ) and ( state ) then
        if isTimer(decrease) then
        killTimer(decrease)
        end
        destroyElement(AracKornaSesi)
        end

        if not ( state ) then
        decrease = setTimer(function()
        local time, final = getTimerDetails(decrease)
        if isElement(AracKornaSesi) then
        if final ~= 1 then
        local volume = getSoundVolume(AracKornaSesi);
        setSoundVolume(AracKornaSesi, volume-1);
        else
        destroyElement(AracKornaSesi)
        end
        end

        end, 300, 1)
        end
            --stopSound ( AracKornaSesi )
        if ( state ) then
            local x, y, z = getElementPosition ( theVehicle )
            AracKornaSesi = playSound3D ( 'sesler.mp3', x, y, z )
            setSoundVolume ( AracKornaSesi, 5.0 )
            setSoundMaxDistance ( AracKornaSesi, 100 )
            attachElements ( AracKornaSesi, theVehicle )
        end
    end
)
Sesler.mp3 dosyasını ayarlar, meta.xml'ye eklersin. Çalışmazsa özel veya konu altı ileti olarak beni bilgilendir yardımcı olurum.