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

Wysłany: 2017-09-06, 17:06


Krzemo1234







Wiek: 27
Na forum: 3892 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Witam gdy naciskam rozpocznij nie ma ?adnych powiadomie? zrobi?em to samo co na autobusach tylko tam dzia?a

ss: https://imgur.com/a/vZL3X


Kod:

local function hit_marker(el,md)
    if getElementType(el) ~= "player" or not md then return end
    if getElementData(source,"start_job") then
    
            if getElementData(el,"player:license:pjC") ~= 1 then
        triggerEvent("onClientAddNotification", el, "Aby tu pracowa? musisz mie? zdane prawo jazdy kat. C!", "error")        
        return
    end        
    
        if getElementData(el,"player:srp") < 250 then
        triggerEvent("onClientAddNotification", el, "Aby tu pracowa? musisz mie? 250SP!", "error")            
        return
    end        
    
        if getPedOccupiedVehicle(el) then return end
        triggerClientEvent(el,"show_gui",resourceRoot,source)
    elseif getElementData(source,"get_vehicles") then
        if not getElementData(el,"packer_job") then return end
        local veh = getPedOccupiedVehicle(el)
        if veh then
            if getElementData(veh,"loaded") or getElementModel(veh) ~= 578 then exports["1"]:outputNotificationBox (el, "Jed? do punktu oznaczonego blipem 'C'", 255, 255, 255) exports["1"]:outputNotificationBox (el, "Pojazdy zosta?y ju? za?adowane!", 255, 0, 0) return end
            setElementFrozen(veh,true)
            toggleControl(el,"enter_exit",false)
            triggerEvent("onClientAddNotification", el, "Trwa ?adowanie pojazd?w", "error")
            setTimer(function(plr,veh)
                local x,y,z = getElementPosition(veh)
                local rx,ry,rz = getElementRotation(veh)
                load_vehicles(veh,x,y,z,rx,ry,rz)
                triggerEvent("onClientAddNotification", el, "Ruszaj do punktu oznaczonego blipem", "error")
                triggerEvent("onClientAddNotification", el, "Pojazdy za?adowane!", "error")
                setElementFrozen(veh,false)
                setElementData(veh,"loaded",true)
                toggleControl(plr,"enter_exit",true)
                triggerClientEvent(plr,"transport_started",resourceRoot)
            end,5000,1,el,veh)
        end
    end
end
addEventHandler("onMarkerHit",resourceRoot,hit_marker)


Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-09-06, 18:17


Kalizman







Wiek: 24
Na forum: 3792 dni
Posty: 1394

Piwa: 4624

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

Pokaz kod powiadomie?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-09-06, 22:33


Krzemo1234







Wiek: 27
Na forum: 3892 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40


local cFunc={}
local cSetting={}

NTSClient={}
NTSClient.__index=NTSClient

--
addEvent('onClientAddNotification', true)
--

-- send to client - triggerClientEvent(player, 'onClientAddNotification', player, text, 'type')
-- send to all clients - triggerClientEvent(root, 'onClientAddNotification', root, text, 'type')

function NTSClient:new(...)
    local obj=setmetatable({}, {__index=self})
    if obj.constructor then
        obj:constructor(...)
    end
    return obj
end

function NTSClient:render()
    local now = getTickCount() 
    if now >= self.tick then 
        self.tick = getTickCount()+10
        self.count = self.count-2
    end 
    
    local bg_x, bg_y=937, 186
    local x=self.sx/2-(bg_x/self.zoom)/2
    
    if self.count==20 and self.nts[1] then
        self.fadeOut=self.nts[1]
        table.remove(self.nts, 1)
    end
    if self.count<=20 and self.count>0 then
        self.pos_y=6/self.zoom+self.count/self.zoom
        self.posTXT_y=4/self.zoom+self.count/self.zoom
    elseif self.count==0 then
        self.pos_y=6/self.zoom
        self.posTXT_y=4/self.zoom
        self.count=280
    end
    
    if self.fadeOut then
        self.fadeOut.alpha=math.max(self.fadeOut.alpha-0.05, 0)
        dxDrawImage(x, self.pos_y, bg_x/self.zoom, bg_y/self.zoom, self.textures[tostring(self.fadeOut.type)], 0, 0, 0, tocolor(255, 255, 255, 255*self.fadeOut.alpha), true)
        dxDrawText(self.fadeOut.msg, x+(bg_x/6.25/self.zoom), self.posTXT_y, x+(bg_x/7/self.zoom)+bg_x/self.zoom-bg_x/5/self.zoom, self.posTXT_y+(bg_y/self.zoom), tocolor(255, 255, 255, 255*self.fadeOut.alpha), 0.5, self.font1, 'center', 'center', true, true, true)
        if self.fadeOut.alpha==0 then
            self.fadeOut=nil
        end
    end
    
    for i,v in pairs(self.nts) do
        if i>2 then return end
        
        v.alpha=math.min(v.alpha+0.05, 1)
        dxDrawImage(x, self.pos_y+((i-1)*150)/self.zoom, bg_x/self.zoom, bg_y/self.zoom, self.textures[tostring(v.type)], 0, 0, 0, tocolor(255, 255, 255, 255*v.alpha), true)
        dxDrawText(v.msg, x+(bg_x/6.25/self.zoom), self.posTXT_y+((i-1)*150)/self.zoom, x+(bg_x/7/self.zoom)+bg_x/self.zoom-bg_x/5/self.zoom, self.posTXT_y+(bg_y/self.zoom)+((i-1)*150)/self.zoom, tocolor(255, 255, 255, 255*v.alpha), 0.5, self.font1, 'center', 'center', true, true, true)
    end
end

function NTSClient:add(msg, type)
    if #self.nts==0 then
        self.count=280
    end
    
    outputConsole("["..string.upper(type).."] "..msg)
    table.insert(self.nts, {
        msg=msg, 
        type=type,
        alpha=0,
        tick=getTickCount()
    })
    -- ZAKOMENTOWANO DO STARTU SERWERA!
    local snd=playSound('s/' ..type.. '.mp3')
    setSoundVolume(snd, 0.3)
end

function NTSClient:onAddNTS(data, type)
    if not data then return end
    if not type then return end
    
    NTSClass:add(data, type)
end

-- wywolywanie klasy
function NTSClient:constructor(...)
    self.count=280
    self.fadeOut=nil
    self.nts={}
    
    local sx,sy=guiGetScreenSize()
    self.sx, self.sy=sx, sy
    self.zoom=2.4

    self.lu_start=getTickCount()
    self.pos_y, self.posTXT_y=6/self.zoom, 4/self.zoom
    
    -- notifications textures
    self.textures={
        ['warning']=dxCreateTexture('i/nts_warning.png', 'dxt5', false, 'wrap'),
        ['error']=dxCreateTexture('i/nts_error.png', 'dxt5', false, 'wrap'),
        ['success']=dxCreateTexture('i/nts_success.png', 'dxt5', false, 'wrap'),
        ['info']=dxCreateTexture('i/nts_info.png', 'dxt5', false, 'wrap'),
    }
    --
    
    -- font
    self.font=dxCreateFont('f/myriad_prop.ttf', 20)
    self.font1=dxCreateFont('f/archivo_narrow.ttf', 20) 
    --
    
    self.funcAddNTS=function(data, type) self:onAddNTS(data, type) end
    addEventHandler('onClientAddNotification', root, self.funcAddNTS)
    
    self.renderFunc=function() self:render() end
    addEventHandler('onClientRender', root, self.renderFunc)

    self.tick = 10 
    --outputDebugString('[calling] NTSClient: constructor')
end
NTSClass=NTSClient:new()


Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-09-06, 22:35


Cjalis







Wiek: 35
Na forum: 3684 dni
Posty: 26
Nick w MP: Cejot

Piwa: 36

Respekt: 70

Je?eli si? nie myl? to widz? tutaj kod na prac? po stronie "client",
     triggerEvent("onClientAddNotification","Aby tu pracowa? musisz mie? zdane prawo jazdy kat. C!", "error")  



spr?buj tak ( usu? po prostu "el")

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-09-06, 22:45


.RiV







Wiek: 26
Na forum: 3729 dni
Posty: 554
Nick w MP: Split

Piwa: 2598

Respekt: 597,8
Respekt: 597,8

"Cjalis" napisał/a:

Je?eli si? nie myl? to widz? tutaj kod na prac? po stronie "client",
     triggerEvent("onClientAddNotification","Aby tu pracowa? musisz mie? zdane prawo jazdy kat. C!", "error")  



spr?buj tak ( usu? po prostu "el")


Nie wypisuj bzdur. Przeczytaj warto?ci jakie musz? si? znale??.

Required Arguments
eventName: The name of the event you wish to trigger
baseElement: The element you wish to trigger the event on. See event system for information on how this works.

Optional Arguments
argument1: The first argument that the event handler expects should be added after the baseElement variable.


Czyli jako baseElement dajesz
"Aby tu pracowa? musisz mie? zdane prawo jazdy kat. C!"


I to nie jest klient, wi?c trigger si? nie wykona.

A co do autora tematu. Na pocz?tku kodu zamie? to:
if getElementType(el) ~= "player" or not md then return end


na
if getElementType(el) ~= "player" then return end


Nie jestem pewny w 100% czy to zadzia?a, gdy? trzy miesi?ce temu mia?em styczno?? z LUA.

Podpis

Autor OGRPG, na scenie MTA od 2012 roku.




Użytkownik: 08.08.2016
GTAO Member: 06.02.2017
Support-Team: 17.06.2017 & 01.06.2019 - 18.11.2019
Moderator: 14.01.2018 - 09.08.2018

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-09-08, 16:18


Krzemo1234







Wiek: 27
Na forum: 3892 dni
Posty: 387
Nick w MP: Krzemo

Piwa: 16

Respekt: 40

Nie dzia?a og?lnie te powiadomienia s? po stronie server jak co?

Podpis
Jeśli ci pomogłem zostaw zimne :piwo:
Postaw piwo autorowi tego posta
 

 
Tagi: nie :: działają :: powiadomienia
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