Jump to content

Chaos

Members
  • Posts

    300
  • Joined

  • Last visited

Everything posted by Chaos

  1. hi, i have problem with freeroam can you help me to fix it ? g_gridListContents = {} -- info about binded gridlists g_openedWindows = {} -- {window1table = true, window2table = true, ...} GRIDLIST_UPDATE_CHUNK_SIZE = 10 classInfo = { wnd = {className = 'Window', padding = {25, 10, 10, 10}, isContainer = true}, tbp = {className = 'TabPanel'}, tab = {className = 'Tab', padding = 10, isContainer = true}, lbl = {className = 'Label', height = 20}, btn = {className = 'Button', height = 20, padding = {0, 4}}, chk = {className = 'CheckBox', height = 20, padding = {0, 6}}, rad = {className = 'RadioButton', height = 20, padding = {0, 10}}, txt = {className = 'Edit', width=100, height = 24}, lst = {className = 'GridList', width = 250, height = 400}, img = {className = 'StaticImage'} } function getTextWidth(text) return 8*text:len() end function createWindow(wnd, rebuild) if wnd.element then if rebuild then destroyElement(wnd.element) else guiSetVisible(wnd.element, true) guiBringToFront(wnd.element) g_openedWindows[wnd] = true if wnd.oncreate then wnd.oncreate() end return end end _planWindow(wnd) _buildWindow(wnd) end function _planWindow(wnd, baseWnd, parentWnd, x, y, maxHeightInLine) -- simulate building a window to get the proper height local wndClass = wnd[1] if not maxHeightInLine then maxHeightInLine = LINE_HEIGHT end local text, padding, parentPadding if wndClass ~= 'br' then padding = classInfo[wndClass].padding if type(padding) == 'number' then padding = table.rep(padding, 4) classInfo[wndClass].padding = padding elseif type(padding) == 'table' then if #padding == 1 then padding = table.rep(padding[1], 4) classInfo[wndClass].padding = padding elseif #padding == 2 then padding = table.flatten(table.rep(padding, 2)) classInfo[wndClass].padding = padding elseif #padding == 3 then table.insert(padding, padding[2]) classInfo[wndClass].padding = padding end elseif not padding then padding = table.rep(0, 4) classInfo[wndClass].padding = padding end text = wnd.text or wnd.id or '' if not wnd.width then wnd.width = (classInfo[wndClass].width or getTextWidth(text)) + (not classInfo[wndClass].isContainer and (padding[2] + padding[4]) or 0) end if not wnd.height and not classInfo[wndClass].isContainer then wnd.height = (classInfo[wndClass].height or LINE_HEIGHT) + padding[1] + padding[3] end end parentPadding = parentWnd and classInfo[parentWnd[1]].padding if wndClass == 'br' or (not classInfo[wndClass].isContainer and x + wnd.width > parentWnd.width - parentPadding[2]) then -- line wrap x = parentPadding[4] y = y + maxHeightInLine + LINE_MARGIN maxHeightInLine = LINE_HEIGHT if wndClass == 'br' then return nil, x, y, maxHeightInLine end end if not wnd.x then wnd.x = x end if not wnd.y then wnd.y = y end wnd.parent = parentWnd if wnd.controls then local childX, childY = padding[4], padding[1] local childMaxHeightInLine = LINE_HEIGHT local control for id, controlwnd in pairs(wnd.controls) do control, childX, childY, childMaxHeightInLine = _planWindow(controlwnd, baseWnd or wnd, wnd, childX, childY, childMaxHeightInLine) end if classInfo[wndClass].isContainer then wnd.height = childY + childMaxHeightInLine + padding[3] end end if wnd.tabs then local maxTabHeight = 0 for id, tab in pairs(wnd.tabs) do tab[1] = 'tab' tab.width = wnd.width _planWindow(tab, baseWnd, wnd) if tab.height > maxTabHeight then maxTabHeight = tab.height end end wnd.height = maxTabHeight end if classInfo[wndClass].isContainer then return elem else if wnd.height > maxHeightInLine then maxHeightInLine = wnd.height end return elem, x + wnd.width + CONTROL_MARGIN_RIGHT, y, maxHeightInLine end end function _buildWindow(wnd, baseWnd, parentWnd) local wndClass = wnd[1] if wndClass == 'br' then return end local relX, relY, relWidth, relHeight if parentWnd then if wnd.x and wnd.y then relX = wnd.x/parentWnd.width relY = wnd.y/parentWnd.height end relWidth = wnd.width / parentWnd.width relHeight = wnd.height / parentWnd.height end local elem if wndClass == 'wnd' then local screenWidth, screenHeight = guiGetScreenSize() if not wnd.x then wnd.x = screenWidth/2 - wnd.width/2 else local i, f = math.modf(wnd.x) if f ~= 0 then wnd.x = screenWidth * wnd.x end if wnd.x < 0 then wnd.x = screenWidth - math.abs(wnd.x) - wnd.width end end if not wnd.y then wnd.y = screenHeight/2 - wnd.height/2 else local i, f = math.modf(wnd.y) if f ~= 0 then wnd.y = screenHeight * wnd.y end if wnd.y < 0 then wnd.y = screenHeight - math.abs(wnd.y) - wnd.height end end elem = guiCreateWindow(wnd.x, wnd.y, wnd.width, wnd.height, wnd.text, false) guiWindowSetSizable(elem, false) guiBringToFront(elem) g_openedWindows[wnd] = true elseif wndClass == 'chk' then elem = guiCreateCheckBox(relX, relY, relWidth, relHeight, wnd.text or wnd.id or '', false, true, parentWnd.element) elseif wndClass == 'tbp' then elem = guiCreateTabPanel(relX, relY, relWidth, relHeight, true, parentWnd.element) elseif wndClass == 'tab' then elem = guiCreateTab(text, parentWnd.element) elseif wndClass == 'lst' then elem = guiCreateGridList(relX, relY, relWidth, relHeight, true, parentWnd.element) if wnd.columns then guiGridListSetSortingEnabled(elem, false) for i, column in ipairs(wnd.columns) do guiGridListAddColumn(elem, column.text or column.attr or '', column.width or 0.9) end end elseif wndClass == 'img' then elem = guiCreateStaticImage(relX, relY, relWidth, relHeight, wnd.src or '', true, parentWnd.element) else elem = _G['guiCreate' .. classInfo[wndClass].className](relX, relY, relWidth, relHeight, wnd.text or wnd.id or '', true, parentWnd.element) if wnd.align and wndClass == 'lbl' then guiLabelSetHorizontalAlign(elem, wnd.align, true) end end wnd.element = elem if wnd.controls then for id, controlwnd in pairs(wnd.controls) do _buildWindow(controlwnd, baseWnd or wnd, wnd) end end if wnd.tabs then for id, tab in pairs(wnd.tabs) do _buildWindow(tab, baseWnd, wnd) end end if wnd.rows then if wnd.rows.xml then -- get rows from xml bindGridListToTable(wnd, not gridListHasCache(wnd) and xmlToTable(wnd.rows.xml, wnd.rows.attrs) or false, wnd.expandlastlevel or wnd.expandlastlevel == nil) else -- rows hardcoded in window definition bindGridListToTable(wnd, not gridListHasCache(wnd) and wnd.rows or false, false) end end local clickhandler = nil if wnd.onclick then if wndClass == 'img' then clickhandler = function(btn, state, x, y) local imgX, imgY = getControlScreenPos(wnd) wnd.onclick((x - imgX)/wnd.width, (y - imgY)/wnd.height, btn) end else clickhandler = function() wnd.onclick() end end elseif wnd.window then clickhandler = function() toggleWindow(wnd.window) end elseif wnd.inputbox then clickhandler = function() wndInput = { 'wnd', width = 170, height = 60, controls = { {'txt', id='input', text='', width=60}, {'btn', id='ok', onclick=function() wnd.inputbox.callback(getControlText(wndInput, 'input')) closeWindow(wndInput) end}, {'btn', id='cancel', closeswindow=true} } }
  2. finally it's worked thanks mcer
  3. the label not appear oh god D: i just used guieditor to change it to absolute xR = { } xR[1],xR[2],xR[3],xR[4] = screenWidth*534/screenWidth,screenHeight*510/screenHeight,screenWidth*240/screenWidth,screenHeight*600/screenHeight expLabel = guiCreateLabel( xR[1],xR[2],xR[3],xR[4],"EXP gained: ??\nTotal EXP: ??\nLevel: Unknown",true )
  4. i have already read this before and now i did what you told me and still same thing
  5. you mean like this? GUIEditor = { window = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0.78, 0.82, 0.21, 0.18, "", true) expLabel = guiCreateLabel(0.668,0.85,0.30,5,"EXP gained: ??\nTotal EXP: ??\nLevel: Unknown",true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetAlpha(GUIEditor.window[1], 0.00) end )
  6. can i replace this guilabel to dxdrawtext ? function clientsetupstarter(startedresource) if startedresource == getThisResource() then setTimer ( clientsetup, 1234, 1) MainClientTimer1 = setTimer ( zombie_check, 1000, 0) --STARTS THE TIMER TO CHECK FOR ZOMBIES ----this expLabel = guiCreateLabel(0.668,0.85,0.3000,5,"EXP gained: ??\nTotal EXP: ??\nLevel: Unknown",true) -- Start EXP and level system guiLabelSetColor(expLabel,255,0,0) guiLabelSetVerticalAlign(expLabel,"top") guiLabelSetHorizontalAlign(expLabel,"right",false) end end local ttlgnd = 0 function expChange(expr,gained) ttlgnd = ttlgnd+gained guiSetText(expLabel,"") local level,levelnum = "#0-Beginner",0 if expr >= 30 then level = "#1-Average" levelnum = 1 end if expr >= 70 then level = "#2-Good" levelnum = 2 end if expr >= 100 then level = "#3-Killer" levelnum = 3 end if expr >= 249 then level = "#4-Assassin" levelnum = 4 end if expr >= 600 then level = "#5-Blooder" levelnum = 5 end if expr >= 1499 then level = "#6-Skilled" levelnum = 6 end if expr >= 1999 then level = "#7-Elite" levelnum = 7 end if expr >= 2999 then level = "#8-Senior" levelnum = 8 end if expr >= 3999 then level = "#9-Amazing" levelnum = 9 end if expr >= 4999 then level = "#10-Predator" levelnum = 10 end if expr >= 5999 then level = "#11-ZombieKiller" levelnum = 11 end if expr >= 6999 then level = "#12-Hacker" levelnum = 12 end if expr >= 7999 then level = "#13-Psychopath" levelnum = 13 end if expr >= 8999 then level = "#14-Professional" levelnum = 14 end if expr >= 9999 then level = "#15-Godlike" levelnum = 15 end if expr >= 10000000 then level = "#16-God" levelnum = 16 end guiSetText(expLabel,"EXP gained: "..ttlgnd.." (+"..gained..")\nTotal EXP: "..expr.."\nLevel: "..level) setElementData(getLocalPlayer(),"Level",level) setElementData(getLocalPlayer(),"levelnum",levelnum) end addEvent( "expOnChange", true ) addEventHandler( "expOnChange", getRootElement(), expChange ) addEventHandler("onClientResourceStart", getRootElement(), clientsetupstarter)
  7. so why dxdrawtext works fine and only guillabel don't work ?
  8. i just changed the resolution
  9. work but not staying on the same place when i change the resolution
  10. hi, i want to make guicreatelabel on the same place in all resolutions. guiCreateLabel(0.668,0.85,0.30,5,"Level: Unknown",true) can you help me with that please?
  11. function getPlayersZombiekills for index, player in ipairs (getElementsByType "player" ) do setElementData ( player, "zombiekills", getPlayerzombiekills ( player ) ) table.sort End end is that true?
  12. Can u plz give me simple example cuz im newbie
  13. Hi, is there a way to make best player zombie kills score with dxdrawtext?
×
×
  • Create New...