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

Wysłany: 2016-08-21, 21:37


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

Witam!

Mam b??d ze skryptem "notices" oraz z kodem kt?ry powoduje pokazanie si? informacji (chyba wiecie o co chodzi)
Wyskakuje taki b??d:


Oto kod na "notices":

local displayWidthdisplayHeight guiGetScreenSize();

local notificationData = {};

local notificationFont dxCreateFont('files/fonts/roboto.ttf'12 2false);
local iconsFont dxCreateFont('files/fonts/icons.ttf'12 2false);

addEventHandler('onClientRender'root,
    function()
        for kv in pairs(notificationData) do
            if (v.State == 'fadeIn'then
                local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
                local alphaAnimation interpolateBetween(00025500alphaProgress'Linear');
                
                if (alphaAnimationthen
                    v.Alpha alphaAnimation;
                else
                    v.Alpha 255;
                end
                
                if (alphaProgress 1then
                    v.Tick getTickCount();
                    v.State 'openTile';
                end
            elseif (v.State == 'fadeOut'then
                local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
                local alphaAnimation interpolateBetween(25500000alphaProgress'Linear');
                
                if (alphaAnimationthen
                    v.Alpha alphaAnimation;
                else
                    v.Alpha 0;
                end
                
                if (alphaProgress 1then
                    notificationData = {};
                end
            elseif (v.State == 'openTile'then
                local tileProgress = (getTickCount() - v.Tick) / 350;
                local tilePosition interpolateBetween(v.StartX00v.EndX00tileProgress'Linear');
                local tileWidth interpolateBetween(000v.Width00tileProgress'Linear');
                
                if (tilePosition and tileWidththen
                    v.CurrentX tilePosition;
                    v.CurrentWidth tileWidth;
                else
                    v.CurrentX v.EndX;
                    v.CurrentWidth v.Width;
                end
                
                if (tileProgress 1then
                    v.State 'fixTile';
                    
                    setTimer(function()
                        v.Tick getTickCount();
                        v.State 'closeTile';
                    endstring.len(v.Text) * 45 50001);
                end
            elseif (v.State == 'closeTile'then
                local tileProgress = (getTickCount() - v.Tick) / 350;
                local tilePosition interpolateBetween(v.EndX00v.StartX00tileProgress'Linear');
                local tileWidth interpolateBetween(v.Width00000tileProgress'Linear');
                
                if (tilePosition and tileWidththen
                    v.CurrentX tilePosition;
                    v.CurrentWidth tileWidth;
                else
                    v.CurrentX v.StartX;
                    v.CurrentWidth 0;
                end
                
                if (tileProgress 1then
                    v.AlphaTick getTickCount();
                    v.State 'fadeOut';
                end
            elseif (v.State == 'fixTile'then
                v.Alpha 255;
                v.CurrentX v.EndX;
                v.CurrentWidth v.Width;
            end
            
            roundedRectangle(v.CurrentX2025 v.CurrentWidth25tocolor(000150 v.Alpha 255), _true);
            dxDrawRectangle(v.CurrentX202525tocolor(000255 v.Alpha 255), true);
            
            if (v.Alpha == 255then
                dxDrawText(v.Textv.CurrentX 25 1020v.CurrentX 25 10 v.CurrentWidth 2020 25tocolor(255255255255), 0.40notificationFont'center''center'truefalsetrue);
            end
            
            if (v.Type == 'error'then
                dxDrawText(''v.CurrentX 520v.CurrentX 25 1020 25tocolor(2159090v.Alpha), 0.50iconsFont'center''center'falsefalsetrue);
            elseif (v.Type == 'warning'then
                dxDrawText(''v.CurrentX 520v.CurrentX 25 1020 25tocolor(22018080v.Alpha), 0.50iconsFont'center''center'falsefalsetrue);
            elseif (v.Type == 'info'then
                dxDrawText(''v.CurrentX 520v.CurrentX 25 1020 25tocolor(85180245v.Alpha), 0.50iconsFont'center''center'falsefalsetrue);
            elseif (v.Type == 'success'then
                dxDrawText(''v.CurrentX 520v.CurrentX 25 1020 25tocolor(80205105v.Alpha), 0.50iconsFont'center''center'falsefalsetrue);
            end
        end
    end
)

function addNotification(texttype)
    if (text and typethen
        if (notificationData ~= nilthen
            table.remove(notificationData#notificationData);
        end
        
        table.insert(notificationData,
            {
                StartX = (displayWidth 2) - (25 2),
                EndX = (displayWidth 2) - ((dxGetTextWidth(text0.40notificationFont) + 20 25) / 2),
                Text text,
                Width dxGetTextWidth(text0.40notificationFont) + 20,
                Alpha 0,
                State 'fadeIn',
                Tick 0,
                AlphaTick getTickCount(),
                CurrentX = (displayWidth 2) - (25 2),
                CurrentWidth 0,
                Type type or 'info'
            }
        );
        
        playSoundFrontEnd(11);
    end
end

function roundedRectangle(xywhborderColorbgColorpostGUI)
    if (and and and hthen
        if (not borderColorthen
            borderColor tocolor(000200);
        end
        
        if (not bgColorthen
            bgColor borderColor;
        end
        
        --> Background
        dxDrawRectangle(xywhbgColorpostGUI);
        
        --> Border
        dxDrawRectangle(2141borderColorpostGUI); -- top
        dxDrawRectangle(2h41borderColorpostGUI); -- bottom
        dxDrawRectangle(1214borderColorpostGUI); -- left
        dxDrawRectangle(w214borderColorpostGUI); -- right
    end
end


A oto kod na pokazywanie informacji (ka?dy z nich testowa?em ale nic nie dzia?a):

addCommandHandler("hinfo", function(plr,cmd,...)
        local account getPlayerAccount(plr)
    local accname getAccountName(account)
    if isObjectInACLGroup("user."..accnameaclGetGroup("RCON")) then
        if not ... then triggerClientEvent(plr,"powiadomienie",root,"Wpisz /hinfo (tekst) ") return end
        local text=table.concat({...}, " ")
        for _p in pairs(getElementsByType('player')) do
        triggerClientEvent(p,"powiadomienie",root,text)
        end
    end
end)
addCommandHandler("notification", function(plr,cmd,tyr,...)
            local account getPlayerAccount(plr)
    local accname getAccountName(account)
    if isObjectInACLGroup("user."..accnameaclGetGroup("RCON")) then
        if not ... or not tyr then triggerClientEvent(plr,"addNotification",root,"Wpisz /notification [error/success/warning/info] (tekst) ","error") return end
        local text=table.concat({...}, " ")
        for _p in pairs(getElementsByType('player')) do
        triggerClientEvent(p,"addNotificatione",root,text,tyr)
        end
    end
end)
addCommandHandler("ninfo", function(plr,cmd,...)
            local account getPlayerAccount(plr)
    local accname getAccountName(account)
    if isObjectInACLGroup("user."..accnameaclGetGroup("RCON")) then
        if not ... then triggerClientEvent(plr,"addNotification",root,"Wpisz /ninfo (tekst) ","error") return end
        local text=table.concat({...}, " ")
        for _p in pairs(getElementsByType('player')) do
        triggerClientEvent(p,"addNotificatione",root,text,"info")
        end
    end
end)


Prosz? o edycj? kodu - stawiam respekt i piwo

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-21, 22:03


CzarnaKobra







Wiek: 30
Na forum: 4183 dni
Posty: 59
Nick w MP: CzarnaKobra

Piwa: 1

Respekt: 45,3


        triggerClientEvent(p,"addNotificatione",root,text,tyr)
na 
        triggerClientEvent(p,"addNotification",root,text,tyr)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-21, 22:26


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

CzarnaKobra, za? wyst?puje b??d:
ERROR: Server triggered clienside event addNotification, but event is not added clientside.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 00:58


CzarnaKobra







Wiek: 30
Na forum: 4183 dni
Posty: 59
Nick w MP: CzarnaKobra

Piwa: 1

Respekt: 45,3

[lua]
function addNotification(player, text, type)
if (player and text and type) then
triggerClientEvent(player, 'addNotification', player, text, type);
end
end
/[lua]

Wklej to po stronie servera

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 09:01


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

CzarnaKobra, nadal ten sam b??d, mo?e co? jest z met?:

<meta>
    <info name="Simple Notifications" author="Jayceon" version="1.0.1" type="script" />

    <script src="sourceC.lua" type="client" />

    <script src="sourceS.lua" type="server" />
    
    <file src="files/fonts/roboto.ttf" />
    <file src="files/fonts/icons.ttf" />
    
    <export function="addNotification" type="client" />
</meta>


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 09:35


DJglizdek

Uczeń LUA






Wiek: 24
Na forum: 4168 dni
Posty: 75
Nick w MP: DJglizdek

Piwa: 5

Respekt: 60

Po stronie clienta na samej g?rze kodu dodaj
 addEvent("addNotificatione"true


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 10:23


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

DJglizdek, nadal ten sam b??d:
ERROR: Server triggered clienside event addNotification, but event is not added clientside.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 10:47


DJglizdek

Uczeń LUA






Wiek: 24
Na forum: 4168 dni
Posty: 75
Nick w MP: DJglizdek

Piwa: 5

Respekt: 60

Wybacz, m?j b?ad. Zr?b to samo co napisa?em tylko zamiast "addNotificatione" daj "addNotification"

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 11:26


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

DJglizdek, nie ma DB3 nic si? nie dzieje po wpisaniu /notification lub /ninfo

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 11:52


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

Przecie? jak w?? pisze w mecie, ?e addNotification nie jest event'em, tylko funkcj?, wi?c nie wywo?uje jej si? trigger'em.
export.notices:addNotification()


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 19:25


Kalizman







Wiek: 23
Na forum: 3651 dni
Posty: 1394

Piwa: 4619

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8

GabWas, ...czyli?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-08-22, 21:11


GabWas







Wiek: 24
Na forum: 3881 dni
Posty: 289
Nick w MP: GabWas

Piwa: 65

Respekt: 231,5
Respekt: 231,5Respekt: 231,5

No to? poda?em Ci jak masz tego u?y?. W nawiasie tylko wpisz swoje argumenty, kt?re dawa?e? do trigger'a i tyle. Chyba nie takie trudne mi si? wydaje.

Postaw piwo autorowi tego posta
 

 
Tagi: notifications
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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