Msypon Posted February 24, 2013 Share Posted February 24, 2013 hi guys i need help, so i have downloaded the resource "hud_messages" then my question is: how to make texts not be repeated? for example this image: http://img341.imageshack.us/img341/3117 ... 084031.png, i just want the same text one time ( not being repeated ), can you help me? Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 Client: https://wiki.multitheftauto.com/wiki/OnC ... ourceStart server: https://wiki.multitheftauto.com/wiki/OnPlayerJoin Link to comment
Msypon Posted February 24, 2013 Author Share Posted February 24, 2013 no men, i just want such text one time not being repeated Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 (edited) Well maybe then I should first check your export..... ("test", root,255,0,1000) local R,G,B = 255,0,0 --[[ is it: ]] ("test", root,R,G,B)--? (B can't be higher then 255) --or local time = 2000 local Repeated = 1 local R = 255 --[[ is it: ]] ("test", root,R,Repeated--[[(0= infinity, 1=1x, 2=2x, etc)]],time)--? You can't expect that I know how this hud export fits. Edited February 24, 2013 by Guest Link to comment
Msypon Posted February 24, 2013 Author Share Posted February 24, 2013 exports.hud_messages:showBox(text,colorred,colorgreen,colorblue,timetohide) this is the syntax men Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 Is root also in the syntrax? Link to comment
Msypon Posted February 24, 2013 Author Share Posted February 24, 2013 this is the code client local x, y = guiGetScreenSize() local boxes = {} local timers = {} local id = 1 function showBox(text, r, g, b, t) if not r or not g or not b then r, g, b = 255, 255, 255 end if not t then return end local color = tocolor(r, g, b, 255) or -1 if t > 100 then playSoundFrontEnd ( 13 ) boxes[id] = {text, color} timers[id] = setTimer(destroyBox,t,1,id) id = id + 1 end end function destroyBox(ids) boxes[ids] = nil end function drawBoxes() local nextx = 0 local nexty = 0 for i,tab in pairs(boxes) do nextx = x/2 - string.len(tab[1])*7.5/2 dxDrawRectangle(nextx, nexty,string.len(tab[1])*8.5, 17, tocolor(0, 0, 0, 85)) dxDrawText(tab[1], nextx + 5, nexty, nextx - 10, nexty, tab[2], 1.0, "sans", "left", "top") nextx = nextx nexty = nexty + 17 end end addEvent("showBox", true) addEventHandler("showBox", root, showBox) addEventHandler("onClientRender", root, drawBoxes) server function showBox(str, player, r, g, b, t) if isElement(player) then triggerClientEvent(player, "showBox", root, str, r, g, b, t) end end Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 Did you try to debug your code? /debugscript 3 and add some outputDebugString("....") it is much easier to find the bug. The code looks fine, try: function destroyBox(ids) boxes[ids] = nil outputDebugString(ids .. " is nil") end Link to comment
Msypon Posted February 24, 2013 Author Share Posted February 24, 2013 it says: 1 is nil Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 and it still does not stop? -- and this? local remove = boxes[ids] remove[1] = nil remove[2] = nil boxes[ids] = nil Link to comment
Moderators IIYAMA Posted February 24, 2013 Moderators Share Posted February 24, 2013 This should work... How many times does this function get executed? function showBox(text, r, g, b, t) if not r or not g or not b then r, g, b = 255, 255, 255 end if not t then return end local color = tocolor(r, g, b, 255) or -1 if t > 100 then playSoundFrontEnd ( 13 ) boxes[id] = {text, color} timers[id] = setTimer(destroyBox,t,1,id) id = id + 1 outputChatBox("executed!" ) end end Link to comment
Castillo Posted February 24, 2013 Share Posted February 24, 2013 local x, y = guiGetScreenSize() local boxes = {} local timers = {} local texts = { } local id = 1 function showBox(text, r, g, b, t) if not r or not g or not b then r, g, b = 255, 255, 255 end if not t then return end if ( texts [ text ] ) then return end local color = tocolor(r, g, b, 255) or -1 if t > 100 then playSoundFrontEnd ( 13 ) boxes[id] = {text, color} timers[id] = setTimer(destroyBox,t,1,id) texts [ text ] = true id = id + 1 end end function destroyBox(ids) local text = boxes[ids] [ 1 ] boxes[ids] = nil texts [ text ] = nil end function drawBoxes() local nextx = 0 local nexty = 0 for i,tab in pairs(boxes) do nextx = x/2 - string.len(tab[1])*7.5/2 dxDrawRectangle(nextx, nexty,string.len(tab[1])*8.5, 17, tocolor(0, 0, 0, 85)) dxDrawText(tab[1], nextx + 5, nexty, nextx - 10, nexty, tab[2], 1.0, "sans", "left", "top") nextx = nextx nexty = nexty + 17 end end addEvent("showBox", true) addEventHandler("showBox", root, showBox) addEventHandler("onClientRender", root, drawBoxes) Link to comment
Msypon Posted February 24, 2013 Author Share Posted February 24, 2013 thanks solidsneke is that what i wanted 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