Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2025-07-28, 19:20


Toasty2000







Wiek: 25
Na forum: 1558 dni
Posty: 18
Nick w MP: Toasty2000

Piwa: 1

Respekt: 50

Cześć! mam skrypt na notyfikacje, jednak żeby je przetestować starałem się lekko edytować kod i dopisać tak żeby notyfikacja się wyświetliła po napisaniu na chacie NP: /testnoti car lecz jedynie co to na chacie wyświetla mi się coś takiego: Otrzymane argumenty:
Użyj: /testnoti <typ> gdzie typ to: success/error/info/warning/lspd/pb/car

Co bym nie próbował nadal się nie chce wyświetlić notyfikacja i grafika więc postanowiłem napisać tutaj na dole przesyłam cały kod:

Kod:

c.notifications:

--[[
Author: R35 (DSC: R35#5507)
Permissions for use code have author and server Project San Andreas
All rights reserved!
]]

local notifications = {};
local screen = {guiGetScreenSize()};

local textures = {
['success'] = dxCreateTexture('files/success.png', 'argb', false, 'clamp'),
['error'] = dxCreateTexture('files/error.png', 'argb', false, 'clamp'),
['info'] = dxCreateTexture('files/info.png', 'argb', false, 'clamp'),
['warning'] = dxCreateTexture('files/warning.png', 'argb', false, 'clamp'),
['lspd'] = dxCreateTexture('files/lspd.png', 'argb', false, 'clamp'),
['pb'] = dxCreateTexture('files/pb.png', 'argb', false, 'clamp'),
['car'] = dxCreateTexture('files/car.png', 'argb', false, 'clamp'),
['door'] = dxCreateTexture('files/door.png', 'argb', false, 'clamp'),
['voice'] = dxCreateTexture('files/voice.png', 'argb', false, 'clamp'),
['postac'] = dxCreateTexture('files/postac.png', 'argb', false, 'clamp'),
['dress'] = dxCreateTexture('files/dress.png', 'argb', false, 'clamp'),
['fuel2'] = dxCreateTexture('files/fuel2.png', 'argb', false, 'clamp'),
['fuel1'] = dxCreateTexture('files/fuel1.png', 'argb', false, 'clamp'),
};

local fonts = {
dxCreateFont('files/Roboto-Regular.ttf', 10 / 1680 * screen[1]);
};

function drawNotifications()
for i, v in pairs(notifications) do
local add_y = 85 / 1050 * screen[2] * ( i - 1 );
if v.anim_type == 'enter' then
alpha = interpolateBetween(0, 0, 0, 255, 0, 0, ( getTickCount() - v.tick ) / 500, 'Linear');
anim_x = interpolateBetween(387, 0, 0, 0, 0, 0, ( getTickCount() - v.tick ) / 500, 'OutQuad');
elseif v.anim_type == 'exit' then
alpha = interpolateBetween(255, 0, 0, 0, 0, 0, ( getTickCount() - v.tick ) / 500, 'Linear');
anim_x = interpolateBetween(0, 0, 0, 387, 0, 0, ( getTickCount() - v.tick ) / 500, 'OutQuad');
end
if getTickCount() - v.tick >= v.time + 500 then
v.anim_type = 'exit';
v.tick = getTickCount();
setTimer(function()
table.remove(notifications, 1);
if #notifications == 0 then
removeEventHandler('onClientRender', root, drawNotifications);
end
end, 500, 1);
end
if getPedOccupiedVehicle(localPlayer) then
if getElementData(localPlayer, "hide_hud") == "1" then
dxDrawImage(25 / 1680 * screen[1], 792 / 1050 * screen[2] + add_y, 416 / 2650 * screen[1], 60 / 1500 * screen[2], textures[v.type], 0, 0, 0, tocolor(255, 255, 255, alpha));
dxDrawText(v.text, 65 / 1680 * screen[1], 1490 / 1050 * screen[2] + add_y, screen[1], 142 / 1050 * screen[2] + add_y, tocolor(255, 255, 255, alpha), 1, "default-font", 'left', 'center', false, true);
else
dxDrawImage(25 / 1680 * screen[1], 980 / 1050 * screen[2] + add_y, 416 / 2650 * screen[1], 60 / 1500 * screen[2], textures[v.type], 0, 0, 0, tocolor(255, 255, 255, alpha));
dxDrawText(v.text, 65 / 1680 * screen[1], 1810 / 1050 * screen[2] + add_y, screen[1], 195 / 1050 * screen[2] + add_y, tocolor(255, 255, 255, alpha), 1, "default-font", 'left', 'center', false, true);
end
else
dxDrawImage(25 / 1680 * screen[1], 980 / 1050 * screen[2] + add_y, 416 / 2650 * screen[1], 60 / 1500 * screen[2], textures[v.type], 0, 0, 0, tocolor(255, 255, 255, alpha));
dxDrawText(v.text, 65 / 1680 * screen[1], 1810 / 1050 * screen[2] + add_y, screen[1], 195 / 1050 * screen[2] + add_y, tocolor(255, 255, 255, alpha), 1, "default-font", 'left', 'center', false, true);
end
end
end


local tick = getTickCount();
function createAlert(type, text)
if not type then type='info' end

table.insert(notifications, {type=type, text=text, time=5000, tick=getTickCount(), anim_type='enter'})
outputConsole('['..type..'] '..text);
playSound('sounds/'..type..'.wav');
if #notifications > 1 then
table.remove(notifications, 1);
end
if #notifications == 1 then
addEventHandler('onClientRender', root, drawNotifications)
end
end
addEvent('createAlert', true);
addEventHandler('createAlert', resourceRoot, createAlert)

-- https://wiki.multitheftauto.com/wiki/CreateAnimation
-- poprawiona

local anims, animID = { }, 0
local rendering = false

local function renderAnimations( )
local now = getTickCount( )
for k,v in ipairs(anims) do
v.onChange(interpolateBetween(v.from, 0, 0, v.to, 0, 0, (now - v.start) / v.duration, v.easing))
if now >= v.start+v.duration then
table.remove(anims, k)
if type(v.onEnd) == "function" then
v.onEnd( )
end
if #anims == 0 then
rendering = false
removeEventHandler("onClientRender", root, renderAnimations)
end
end
end
end

function createAnimation(f, t, easing, duration, onChange, onEnd)
assert(type(f) == "number", "Bad argument @ 'createAnimation' [expected number at argument 1, got "..type(f).."]")
assert(type(t) == "number", "Bad argument @ 'createAnimation' [expected number at argument 2, got "..type(t).."]")
assert(type(easing) == "string", "Bad argument @ 'createAnimation' [Invalid easing at argument 3]")
assert(type(duration) == "number", "Bad argument @ 'createAnimation' [expected number at argument 4, got "..type(duration).."]")
assert(type(onChange) == "function", "Bad argument @ 'createAnimation' [expected function at argument 5, got "..type(onChange).."]")
animID = animID+1
table.insert(anims, {id=animID, from = f, to = t, easing = easing, duration = duration, start = getTickCount( ), onChange = onChange, onEnd = onEnd})
if #anims >= 1 and not rendering then
addEventHandler("onClientRender", root, renderAnimations)
rendering = true
end
return animID
end

function finishAnimation(anim)
for k, v in ipairs(anims) do
if v.id == anim then
v.onChange(v.to)
if v.onEnd then v.onEnd() end
v.start = 0
return true
end
end
end

function deleteAnimation(anim)
for k, v in ipairs(anims) do
if v.id == anim then
table.remove(anims, k)
break
end
end
end

function handleAdvancedTestNotification(command, player, ...)
local args = {...}
local type = args[1]

outputChatBox("Otrzymane argumenty:")
for i, arg in ipairs(args) do
outputChatBox(tostring(arg))
end

if not type then
outputChatBox("Użyj: /testnoti <typ> gdzie typ to: success/error/info/warning/lspd/pb/car")
return
end

-- Konwertujemy typ na małe litery dla spójności
type = type:lower()

local types = {
success = "Powiadomienie o sukcesie",
error = "Powiadomienie o błędzie",
info = "Informacyjne powiadomienie",
warning = "Powiadomienie ostrzegawcze",
lspd = "Wiadomość od LSPD",
pb = "Wiadomość z PB",
car = "Wiadomość o pojeździe"
}

if types[type] then
createAlert(type, types[type])
else
outputChatBox("Nieprawidłowy typ powiadomienia!")
end
end
addCommandHandler("testnoti", handleAdvancedTestNotification)


Kod:

s.notifications:

--[[
Author: R35 (DSC: R35#5507)
Permissions for use code have author and server Project San Andreas
All rights reserved!
]]


function createAlert(player, type, message)
triggerClientEvent(player, 'createAlert', resourceRoot, type, message)
end


Pamiętam że kiedyś już z tym miałem problem i albo musiałem coś zmieniać z player na ThePlayer albo coś z rootem nie jestem dokładnie pewny ale proszę o pomoc, próbuję to odpalić na paczce OWL Gaming

Ostatnio zmieniony przez Jellonek 2025-07-28, 23:44, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2025-07-28, 23:43


Jellonek







Wiek: 20
Na forum: 1006 dni
Posty: 41
Nick w MP: Jellonek

Piwa: 7

Respekt: 100
Respekt: 100


   Moderator: Cześć, pamiętaj, aby Twoje posty zawierały argumentację zgodną z regulaminem.

Temat został przeniesiony do prawidłowego działu.





Postaw piwo autorowi tego posta
 

 
Wysłany: 2025-07-29, 22:42


MlodyRafonix







Wiek: 26
Na forum: 1899 dni
Posty: 103

Piwa: 954

Respekt: 60

a sprobuj wpisac komende w ten sposob:

/testnoti <type> <type>


+ tu masz poprawiona wersje funkcji 'renderAnimations' (zla spojnosc znakow)

local function renderAnimations( )
    local now getTickCount( )
    for kv in ipairs(anims) do
        v.onChange(interpolateBetween(v.from00v.to00, (now v.start) / v.durationv.easing))
        if now >= v.start v.duration then
            table.remove(animsk)
        end
        if type(v.onEnd) == "function" then
            v.onEnd( )
        end
        if #anims == 0 then
            rendering false
        end
    end
    if (not renderingthen
         removeEventHandler("onClientRender"rootrenderAnimations)
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2025-07-30, 18:49


Toasty2000







Wiek: 25
Na forum: 1558 dni
Posty: 18
Nick w MP: Toasty2000

Piwa: 1

Respekt: 50

"MlodyRafonix" napisał/a:

a sprobuj wpisac komende w ten sposob:

/testnoti <type> <type>


+ tu masz poprawiona wersje funkcji 'renderAnimations' (zla spojnosc znakow)

local function renderAnimations( )
    local now getTickCount( )
    for kv in ipairs(anims) do
        v.onChange(interpolateBetween(v.from00v.to00, (now v.start) / v.durationv.easing))
        if now >= v.start v.duration then
            table.remove(animsk)
        end
        if type(v.onEnd) == "function" then
            v.onEnd( )
        end
        if #anims == 0 then
            rendering false
        end
    end
    if (not renderingthen
         removeEventHandler("onClientRender"rootrenderAnimations)
    end
end


Dzięki wielki! miałeś racje źle wpisywałem komende głupi błąd

Postaw piwo autorowi tego posta
 

 
Tagi: notyfikacje :: się :: nie :: wyśw
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku