Rehber - [Nasıl - Yapılır] Sunucu bildirim sistemi oluşturma

Fivem.com.tr

Fivem.com.tr
Katılım
1 Eki 2022
Mesajlar
5,891
Tepki
80
2012-478040536830922ed4ba702fc55a6af3.jpg



Merhaba, Fivem Türk Topluluğu. Size birkaç dakikada bir veya oyuncuların sohbetinde seçilen bildirimleri göstermek istediğinizde bir sunucu bildirim sisteminin nasıl oluşturulacağını göstereceğim.



?



Bir server.lua oluşturuyoruz





Kod:


Kod:
local notificationList = {
  'your first notification',
  'your second notification',
  'your third...',
  'etc'
}

local lastNotification = 0

Citizen.CreateThread(function()
    while true do
        local minute = 60 * 1000
        Wait(minute * 5) -- This sends a notification every 5 minutes.
        
        TriggerEvent("your_resource_notify:sendRandomNotification") -- We create this event in order to trigger it on the server-side for showing it on all the online players.
    end
end)

RegisterServerEvent("your_resource_notify:sendRandomNotification")
AddEventHandler("your_resource_notify:sendRandomNotification", function()
    local notificationsLength = #notificationList -- Returns the size / length of all the available notifications.

    if lastNotification == notificationsLength then -- Checking if the current notification is the last, if its the last, we start from beginning.
        lastNotification = 0
    end

    lastNotification = lastNotification + 1
    local msg = notificationList[lastNotification] -- Returns the message of the notification.

    TriggerClientEvent('chat:addMessage', -1, {
        template = '{0}: {1}',





Bu, sohbette renkli bir arka plan metni oluşturacaktır. Şablonun bulunduğu RGB renklerini her zaman değiştirebilirsiniz. . Bazı mesajlar ikiden fazla gönderilebilir veya bildirim sırası en iyisi olmazdı.







--



__Resource lua, isteyen herkes için basittir.






Kod:


Kod:
__Resource lua, isteyen herkes için basittir.

resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'

description 'Server Notify System'

version '1.0'

server_scripts {
    'server.lua'
}





2013-478040536830922ed4ba702fc55a6af3.jpg
















Bir lider, istese de istemese de yaptıklarıyla bir örnektir. -Anonim

Konu alıntıdır, yanlış veya hatalı bir bilgi/paylaşım var ise yanıtlayabilir veya bizimle iletişime geçebilirsiniz.
 

Şu anda bu konu'yu okuyan kullanıcılar

Benzer konular

Üst