Turbesz Posted August 30, 2016 Share Posted August 30, 2016 (edited) --client -- Notifications system local sx,sy = guiGetScreenSize() local r,g,b = 255, 60, 0 local lisrMSG = {} -- The same function as outputChatBoxing to make it more easier. function showText(message) if not (message and type(message) == "string") then error("Bad argument @ 'showText' [Expected player at argument 1, got "..type(message).."]") return false end return table.insert(lisrMSG, {message, getTickCount()}) end addEvent("onClientShowText",true) addEventHandler("onClientShowText", root, showText) alpha1 = 0; -- Rendering. addEventHandler("onClientRender", root, function () if (#lisrMSG > 0) then for i, messages in ipairs(lisrMSG) do text, started = unpack(messages) now = getTickCount() progress = (now-started)/1200 x, w, h = sx/2-(360/2), 360, 20 scale = 1 font = "default-bold" length = dxGetTextWidth(text, scale, font, true) _, y, alpha = interpolateBetween(0, sy, 0, 0, sy-(80+(h*i)), 255, progress, "OutBack") if (progress >= -- s8) --> then table.remove(lisrMSG, i) if alpha1 >= 255 then alpha1 = 255 end end alpha1 = alpha1 + 3; if alpha1 >= 255 then alpha1 = 255; end dxDrawRectangle((x-5)-(tonumber(length)/2)+180, y-1, tonumber(length)+8, h+2, tocolor(r, g, b, alpha1), false) dxDrawRectangle((x-4)-(tonumber(length)/2)+180, y, tonumber(length)+6, h, tocolor(22, 22, 22, alpha1), false) dxDrawText(tostring(text), x, y, w+x, h+y, tocolor(255, 255, 255, alpha1), scale, font, "center", "center", false, false, false, true, false) end end end) function text ( ) showText(getPlayerName(source).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) addEventHandler( "loginlogin", root, text ) addEventHandler('onClientPlayerJoin', root, function() showText("#00baff"..getPlayerName(source).." #FFffFFJött Kockulni#00baff!") end) addEventHandler('onClientPlayerQuit', root, function(reason) showText("#00baff"..getPlayerName(source).." #df6464Távozott! (Ok: "..reason..").") end) addEventHandler('onClientPlayerChangeNick', root, function(oldNick, newNick) showText("#00baff"..oldNick.." #ffffffnevet váltott:#00baff " ..newNick) end) --server function showText(message, sendtO) if not (message and type(message) == "string") then error("Bad argument @ 'showText' [Expected player at argument 1, got "..type(message).."]") return false end if not (sendtO) and (isElement(sendtO)) then error("Bad argument @ 'showText' [Expected player at argument 2, got "..type(sendtO).."]") return false end return triggerClientEvent(sendtO, "onClientShowText", root, message) end addEventHandler("onPlayerLogin", root, function () triggerClientEvent("loginlogin", root) end ) ERROR: xy/client.lua:49: attempt to concatenate a boolean value Edited August 30, 2016 by Guest Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 alpha1 is failing I guess. Could you copy again the script better lined? Because there's cut's which can provoke a lecture error. Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 alpha1 is failing I guess. Could you copy again the script better lined? Because there's cut's which can provoke a lecture error. -- Notifications system local sx,sy = guiGetScreenSize() local r,g,b = 255, 60, 0 local lisrMSG = {} -- The same function as outputChatBoxing to make it more easier. function showText(message) if not (message and type(message) == "string") then error("Bad argument @ 'showText' [Expected player at argument 1, got "..type(message).."]") return false end return table.insert(lisrMSG, {message, getTickCount()}) end addEvent("onClientShowText",true) addEventHandler("onClientShowText", root, showText) alpha1 = 0; -- Rendering. addEventHandler("onClientRender", root, function () if (#lisrMSG > 0) then for i, messages in ipairs(lisrMSG) do text, started = unpack(messages) now = getTickCount() progress = (now-started)/1200 x, w, h = sx/2-(360/2), 360, 20 scale = 1 font = "default-bold" length = dxGetTextWidth(text, scale, font, true) _, y, alpha = interpolateBetween(0, sy, 0, 0, sy-(80+(h*i)), 255, progress, "OutBack") if (progress >= -- s8) --> then table.remove(lisrMSG, i) if alpha1 >= 255 then alpha1 = 255 end end alpha1 = alpha1 + 3; if alpha1 >= 255 then alpha1 = 255; end dxDrawRectangle((x-5)-(tonumber(length)/2)+180, y-1, tonumber(length)+8, h+2, tocolor(r, g, b, alpha1), false) dxDrawRectangle((x-4)-(tonumber(length)/2)+180, y, tonumber(length)+6, h, tocolor(22, 22, 22, alpha1), false) dxDrawText(tostring(text), x, y, w+x, h+y, tocolor(255, 255, 255, alpha1), scale, font, "center", "center", false, false, false, true, false) end end end) -- Joing quit as a test, if you gonna use it out side this script you have to export, method exports.notif:showText("Text") -- carefully do NEVER change this resource name! function text ( ) showText(getPlayerName(source).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) addEventHandler( "loginlogin", root, text ) addEventHandler('onClientPlayerJoin', root, function() showText("#00baff"..getPlayerName(source).." #FFffFFJött Kockulni#00baff!") end) addEventHandler('onClientPlayerQuit', root, function(reason) showText("#00baff"..getPlayerName(source).." #df6464Távozott! (Ok: "..reason..").") end) addEventHandler('onClientPlayerChangeNick', root, function(oldNick, newNick) showText("#00baff"..oldNick.." #ffffffnevet váltott:#00baff " ..newNick) end) Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Change this lines: function text ( ) showText(getPlayerName(source).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) with: function text ( ) showText(getPlayerName( localPlayer ).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 Change this lines: function text ( ) showText(getPlayerName(source).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) with: function text ( ) showText(getPlayerName( localPlayer ).." #ffffffhas #00ff00bejel#ffffffentkezett.") end addEvent( "loginlogin", true ) doesn't working Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 What's the error in the one which I passed to you? Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 What's the error in the one which I passed to you? No errors, just doesn't show the message sorry for my bad english:c Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Try to remove alpha1 and put 255 on the dxDraw and see if it appears. Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 Try to remove alpha1 and put 255 on the dxDraw and see if it appears. THANKS!:DDD Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Removing alpha1 will remove your "animation", which is not correctly structured. If you need that animation just say it and I can make a better structured one. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now