Dimos7 Posted December 17, 2016 Share Posted December 17, 2016 (edited) function sendClientMessage(message, r, g, b, colorCode) local x, y = guiGetScreenSize() local message = string.gsub(message, "") if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end dxDrawRectangle(x/2, 0, 200, 200, tocolor(0, 0, 0, 220), false, false) dxDrawText(message,0, 0, x, y, tocolor(r, g, b, 220), 1, "default", "center", "center", false, false, true) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) it draw the rectangle but for very few seconds why? Edited December 17, 2016 by Dimos7 Link to comment
KariiiM Posted December 17, 2016 Share Posted December 17, 2016 Where is the timing part ? Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 (edited) i try it like this function sendClientMessage(message, r, g, b, colorCode) local x, y = guiGetScreenSize() local message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end if getTickCount() <= 5000 then dxDrawRectangle(x/2, 0, 200, 100, tocolor(0, 0, 0, 220), false, false) dxDrawText(message,x/2, 0, x, y, tocolor(r, g, b, 220), 1, "default", "left", "top", false, false, true) end end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) but didn't show up nothing Edited December 17, 2016 by Dimos7 Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 You need to run this onClientRender Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 but i want be only for some time not for every frame Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 41 minutes ago, Dimos7 said: but i want be only for some time not for every frame onClientRender > setTimer > removeEventHandler (onClientRender) Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 (edited) function sendClientMessage(message, r, g, b, colorCode) local x, y = guiGetScreenSize() local message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end addEventHandler("onClientRender", root, function() dxDrawRectangle(x/2-800/2, 0, 800, 50, tocolor(0, 0, 0, 220), false, false) dxDrawText(message, 0, 15, x, y, tocolor(r, g, b, 220), 1, "default", "center", "top", false, false, true) end ) setTimer(removeEventHandler, 5000, 1, "onClientRender", root, sendClientMessage) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) i try it like that but in time need function and put the functionstart function say take nill Edited December 17, 2016 by Dimos7 Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 Example: function whatever() addEventHandler("onClientRender", getRootElement(), example) setTimer(function() removeEventHandler("onClientRender", getRootElement(), example) end, 5000, 1) end function example() --dxdrawstuff end The function needs a name so the removeEventHandler knows where to find the function to be removed Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 in this case like i have it what i can do? Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 Did you read the example cause it's really that simple: function dxDrawStuff() dxDrawRectangle(x/2-800/2, 0, 800, 50, tocolor(0, 0, 0, 220), false, false) dxDrawText(message, 0, 15, x, y, tocolor(r, g, b, 220), 1, "default", "center", "top", false, false, true) end function sendClientMessage(message, r, g, b, colorCode) local x, y = guiGetScreenSize() local message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end addEventHandler("onClientRender", root, dxDrawStuff) setTimer(function() removeEventHandler("onClientRender", root, dxDrawStuff) end, 5000, 1) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) You might look at setTimer cause that one was quite messed up Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 Like that will be apear many erroy x ,y message etc not take them from one to other function function sendClientMessage(message, r, g, b, colorCode) local x, y = guiGetScreenSize() local message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end dxDrawRectangle(x/2-800/2, 0, 800, 50, tocolor(0, 0, 0, 220), false, false) dxDrawText(message, 0, 15, x, y, tocolor(r, g, b, 220), 1, "default", "center", "top", false, false, true) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) function Notifactions() sendClientMessage() addEventHandler("onClientRender", root, Notifactions) setTimer( function() removeEventHandler("onClientRender", root, Notifactions) end, 15000, 1) end i try it like this but again in few seconds dissapear Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 That's not what I wrote tho? Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 that you wrote it wont work bro Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 alots x nill values not messa not string etc Link to comment
ViRuZGamiing Posted December 17, 2016 Share Posted December 17, 2016 21 minutes ago, Dimos7 said: alots x nill values not messa not string etc Can you copy the error cause I don't really understand your error? I suppose expect string but got nil value? Link to comment
Dimos7 Posted December 17, 2016 Author Share Posted December 17, 2016 i mean x not take from guiGetScreenSize neither message Link to comment
ViRuZGamiing Posted December 18, 2016 Share Posted December 18, 2016 (edited) 54 minutes ago, Dimos7 said: i mean x not take from guiGetScreenSize neither message oh yeah my bad didn't notice. I see what you mean. local x, y = guiGetScreenSize() --can be at the top since your screensize won't change during runtime local message = false local r, g, b function notification() dxDrawRectangle(x/2-800/2, 0, 800, 50, tocolor(0, 0, 0, 220), false, false) dxDrawText(message, 0, 15, x, y, tocolor(r, g, b, 220), 1, "default", "center", "top", false, false, true) end function sendClientMessage(message, r, g, b, colorCode) message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end addEventHandler("onClientRender", root, notification) setTimer(function() removeEventHandler("onClientRender", root, notification) message = false end, 5000, 1) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) Try this Edited December 18, 2016 by ViRuZGamiing Link to comment
Dimos7 Posted December 18, 2016 Author Share Posted December 18, 2016 local x, y = guiGetScreenSize() local message = false local r, g, b function Notifactions() dxDrawRectangle(x/2-800/2, 0, 800, 50, tocolor(0, 0, 0, 220), false, false) dxDrawText(message, 0, 15, x, y, tocolor(r, g, b, 220), 1, "default", "center", "top", false, false, true) end function sendClientMessage(message, r, g, b, colorCode) message = tostring(message) if not message then return end r,g ,b = tonumber(r), tonumber(g), tonumber(b) if not colorCode then colorCode = false else colorCode = true r,g,b = getColorFromString(message) end addEventHandler("onClientRender", root, Notifactions) setTimer(function() removeEventHandler("onClientRender", root, Notifactions) message = false end, 5000, 1) end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) dxDrawText expect string argument 1 got boolean 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