Wysłany: 2018-06-16, 15:12
ProWhiteQ
Ucze sie LUA
Wiek: 45 Na forum: 4341 dni Posty: 38
Piwa : 6
Witam, mam problem ot?? za nic nie potrafi? po??czy? skryptu na notyfikacje z tym kodem:
Kod: addCommandHandler("noti", function(plr,cmd,tyr,...)
if getAdmin(plr,3) then
if not ... or not tyr then triggerClientEvent(plr,"showBox",root,"Wpisz /noti [error/success/warning/info] (tekst) ","error") return end
local text=table.concat({...}, " ")
for _, p in pairs(getElementsByType('player')) do
triggerClientEvent(p,"showBox",root,text,tyr)
end
end
end)
kod notyfikacji:
c
Kod: sx,sy = guiGetScreenSize ()
addEvent ("onNotificationWindowHide",false)
addEvent ("onNotificationWindowShow",false)
box = false
function showBox(value, str)
-- value 1 - Info
-- value 2 - Error
-- value 3 - warning
--if box == false then
if str and type(str) == "string" and string.len(str) > 0 then
box = true
if value == "info" then
showTipBox (str,"img/info.png")
outputConsole ("[INFO]" .. str)
elseif value == "error" then
showTipBox (str,"img/error.png")
outputConsole ("[ERROR]" .. str)
elseif value == "warning" then
showTipBox (str,"img/warning.png")
outputConsole ("[WARNING]" .. str)
end
end
--else
-- return false
--end
end
addEvent("CreateBox", true)
addEventHandler("CreateBox", getRootElement(), showBox)
addEventHandler ("onNotificationWindowHide",getRootElement(),
function ()
box = false
end
)
tipBox = {}
tipBox.path = ""
tipBox.show = false
tipBox.state = nil
tipBox.string = nil
tipBox.starTick = nil
tipBox.currentY = nil
tipBox.time = 800
tipBox.next = nil
tipBox.nextPath = ""
tipBox.timer = nil
tipBox.startY = -180
tipBox.stopY = 30
function showTipBox (str,path)
if str then
if path == nil then
path = "img/info.png"
end
if fileExists (path) then
if tipBox.show == true then
tipBox.next = str
tipBox.nextPath = path
else
local sound = playSound ("bip.mp3")
setSoundVolume (sound,0.5)
tipBox.path = path
tipBox.show = true
tipBox.state = "starting"
tipBox.string = str
tipBox.startTick = getTickCount()
triggerEvent ("onNotificationWindowShow",getRootElement())
end
end
end
end
addEvent("CreateTipBox", true)
addEventHandler("CreateTipBox", getRootElement(), showTipBox)
addEventHandler ("onClientRender", getRootElement(),
function ()
if tipBox.show == true and tipBox.string then
local width = dxGetTextWidth (tipBox.string, 1, "default-bold")
if width then
if tipBox.state == "starting" then
local progress = (getTickCount() - tipBox.startTick) / tipBox.time
local intY = interpolateBetween (
tipBox.startY,0,0,
tipBox.stopY,0,0,
progress,"OutElastic"
)
if intY then
tipBox.currentY = intY
else
tipBox.currentY = 100
end
if progress > 1 then
tipBox.state = "showing"
tipBox.timer = setTimer (
function ()
tipBox.startTick = getTickCount()
tipBox.state = "hiding"
end
,string.len(tipBox.string)*45+800,1)
end
elseif tipBox.state == "showing" then
tipBox.currentY = tipBox.stopY
elseif tipBox.state == "hiding" then
local progress = (getTickCount() - tipBox.startTick) / (tipBox.time)
local intY = interpolateBetween (
tipBox.stopY,0,0,
tipBox.startY,0,0,
progress,"Linear"
)
if intY then
tipBox.currentY = intY
else
tipBox.currentY = 100
end
if progress > 1 then
triggerEvent ("onNotificationWindowHide",getRootElement())
if tipBox.next then
if isTimer(tipBox.timer) then
killTimer(tipBox.timer)
end
tipBox.show = true
tipBox.state = "starting"
tipBox.string = tipBox.next
tipBox.startTick = getTickCount()
tipBox.next = nil
tipBox.path = tipBox.nextPath
return
else
tipBox.show = false
tipBox.state = nil
tipBox.string = nil
return
end
end
else
return
end
local width = 512
local x,y = sx/2 - width/2, tipBox.currentY
local textX,textY = x+128,tipBox.currentY+44
local textWidth,textHeight = 363,106
dxDrawImage (x,y,width,256,tipBox.path,0,0,0,tocolor(255,255,255),true)
dxDrawText (tipBox.string,textX,textY,textX+textWidth,textY+textHeight,tocolor(222,222,222),1,"default-bold","center","center",false,true,true)
end
end
end
)
s
Kod: function showBox(player, value, str)
if isElement(player) then
triggerClientEvent(player, "CreateBox", getRootElement(), value, str)
end
end
meta
Kod: <meta>
<script src="box_s.lua" type="server" />
<script src="box_c.lua" type="client" />
<file src="img/info.png" />
<file src="img/Error.png" />
<file src="img/Success.png" />
<file src="img/Warning.png" />
<file src="bip.mp3" />
<export function="showBox" />
<export function="showBox" type="client" />
</meta>
Nie jestem taki zielony w lua i wydaje mi si? ze wszystko jest dobrze ale mog? si? myli? i prosi? bym o pomoc z tym.
Wysłany: 2018-06-16, 18:10
PatryKK.
Emeryt LUA
Wiek: 26 Na forum: 3061 dni Posty: 1060
Nick w MP: PatryKK.
Piwa : 2322
Z tego co mi wiadomo Musisz zastosowa?
exports . nazwapliku : showBox ( element , "typ" , "tekst" )
Podpis
GG:75080675
- ✔
- ✔
- ✔
- ✔
Aktualny projekt: BRAK
Wysłany: 2018-06-16, 21:02
ProWhiteQ
Ucze sie LUA
Wiek: 45 Na forum: 4341 dni Posty: 38
Piwa : 6
No niezbyt to dzia?a i o ile si? orientuj? no to exports u?ywa si? kiedy chc? aby te notyfikacje wy?wietla?y si? kiedy np. rozpoczyna si? prace lub ko?czy, a mi chodzi o to ze wpisuj? komend? z notyfikacj? tak jak mam w kodzie wy?ej czyli /noti error [TEKST]
Tagi: wyświetlanie :: notyfikacji
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: