iiv03 Posted December 5, 2019 Share Posted December 5, 2019 hey, how do i make the table all the name on the right? i use: local nameTable = {"test1","test2"} ---- ---- local offsetX = 0 for i ,v in pairs(nameTable) do dxDrawText(v, referee.x*1.17, referee.y+20, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "left","top",false) end offsetX = offsetX + referee.x i tried to move it on some coordinates and it didn't work Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 ipairs instead of pairs at line 9. 1 Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 (edited) 44 minutes ago, stPatrick said: ipairs instead of pairs at line 9. -- local nameTable = {"test1","test2"} -- -- in function local textmoveX = sX*0.3 local offsetX = 0 for i ,v in ipairs(nameTable) do dxDrawText(v, referee.x + textmoveX, referee.y, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) end offsetX = referee.x + textmoveX --end hey stPatrick, there is no difference when i'm put iparis EDIT:: okay i did something wrong and I fixed it i put offsetX = etc. out loop so that's why not work Edited December 6, 2019 by xFabel Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 1 minute ago, xFabel said: -- local nameTable = {"test1","test2"} -- -- in function local textmoveX = sX*0.3 local offsetX = 0 for i ,v in ipairs(nameTable) do dxDrawText(v, referee.x + textmoveX, referee.y, sizeX+offsetX, sizeY ,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) end offsetX = referee.x + textmoveX --end hey stPatrick, there is no difference when i'm put iparis I don't know whats the problem because I don't know the full code and I don't really understand what you want to do. Maybe the offsetX, put it inside the for loop, after dxDrawText. Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 1 hour ago, stPatrick said: I don't know whats the problem because I don't know the full code and I don't really understand what you want to do. Maybe the offsetX, put it inside the for loop, after dxDrawText. i make other table but here in debugscript tell me table is nil local offsetY = 0 -- table with column local referees = { ["Status"] = { columns = { {"Running", "test"}, {"Free Round", "test"}, {"Waiting", "test"}, {"Paused", "test"}, {"Training", "test"}, } } -- to make loop of table for i, v in pairs(referees) do for i, column in pairs(v.columns) do column.height = referee.y * (tonumber(column[3]) or 0) end end -- render column when panel showing function referee.renderColumns(columns, offsetY) for i, column in ipairs (columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end to 'iparis' (table expected, got nil) at line 20 (render column) where wrong? Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 (edited) 3 minutes ago, xFabel said: i make other table but here in debugscript tell me table is nil local offsetY = 0 -- table with column local referees = { ["Status"] = { columns = { {"Running", "test"}, {"Free Round", "test"}, {"Waiting", "test"}, {"Paused", "test"}, {"Training", "test"}, } } -- to make loop of table for i, v in pairs(referees) do for i, column in pairs(v.columns) do column.height = referee.y * (tonumber(column[3]) or 0) end end -- render column when panel showing function referee.renderColumns(columns, offsetY) for i, column in ipairs (columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end to 'iparis' (table expected, got nil) at line 20 (render column) Where you call renderColumns? Edited December 6, 2019 by stPatrick Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 6 minutes ago, stPatrick said: referees["status"].columns instead of columns I don't understand much in the table. this is the first time i use it could u tell me where wrong? Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 Where you call renderColumns? Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 Just now, stPatrick said: Where you call renderColumns? function Opendx() referee.ShowDxPanel = not referee.ShowDxPanel if referee.ShowDxPanel then referee.tick = getTickCount() removeEventHandler("onClientRender", root, referee.renderColumns) showCursor(true) addEventHandler("onClientRender", root, referee.renderColumns) --addEventHandler("onClientClick", root, onClick) else --removeEventHandler("onClientClick", root, onClick) showCursor(false) referee.tick = getTickCount() end end bindKey("f2", "down", Opendx) Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 Just now, xFabel said: function Opendx() referee.ShowDxPanel = not referee.ShowDxPanel if referee.ShowDxPanel then referee.tick = getTickCount() removeEventHandler("onClientRender", root, referee.renderColumns) showCursor(true) addEventHandler("onClientRender", root, referee.renderColumns) --addEventHandler("onClientClick", root, onClick) else --removeEventHandler("onClientClick", root, onClick) showCursor(false) referee.tick = getTickCount() end end bindKey("f2", "down", Opendx) Use like this -- render column when panel showing function referee.renderColumns() local offsetY = 0 for i, column in ipairs (referee["status"].columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 in first, i'm test dxdrawtext like this function referee.renderColumns() --for i, column in ipairs (columns) do dxDrawText("test", referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) -- offsetY = offsetY + column.height --end end and work but when put table give me error Just now, stPatrick said: Use like this -- render column when panel showing function referee.renderColumns() local offsetY = 0 for i, column in ipairs (referee["status"].columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end hm does not work attempt to index field 'status' (a nil value) Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 (edited) 3 minutes ago, xFabel said: in first, i'm test dxdrawtext like this and work but when put table give me error hm does not work attempt to index field 'status' (a nil value) uppercase letter S, I missed Edited December 6, 2019 by stPatrick Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 (edited) 34 minutes ago, stPatrick said: uppercase letter S, I missed have question when i moved the coordinates and they do not move why? dxDrawText(column[1], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + offsetY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + referee.y it's not move like this Running Waiting etc.. Edited December 6, 2019 by xFabel Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 10 minutes ago, xFabel said: have question when i moved the coordinates and they do not move why? dxDrawText(column[1], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + offsetY,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + referee.y it's not move like this Running Waiting etc.. -- render column when panel showing function referee.renderColumns() for i, column in ipairs (referee["Status"].columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end Remove local offsetY = 0 Link to comment
iiv03 Posted December 6, 2019 Author Share Posted December 6, 2019 31 minutes ago, stPatrick said: -- render column when panel showing function referee.renderColumns() for i, column in ipairs (referee["Status"].columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(255,255,255,255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end Remove local offsetY = 0 other question ^^ how make color in table like "Running" i wanna give color green and "Waiting" give color orange etc... is there a way? Link to comment
Moderators Patrick Posted December 6, 2019 Moderators Share Posted December 6, 2019 32 minutes ago, xFabel said: other question ^^ how make color in table like "Running" i wanna give color green and "Waiting" give color orange etc... is there a way? First, define colors in the table: local referees = { ["Status"] = { columns = { {"Running", "test", {255,0,0}}, {"Free Round", "test", {255,0,0}}, {"Waiting", "test", {255,0,0}}, {"Paused", "test", {255,0,0}}, {"Training", "test", {255,0,0}}, } } And use like this in render: -- render column when panel showing function referee.renderColumns() for i, column in ipairs (referee["Status"].columns) do dxDrawText(column[2], referee.x + textmoveX + moveSide, referee.y + positionY, sizeX, sizeY + column.height,tocolor(column[3][1],column[3][2],column[3][3],255*referee.getPanelAlpha), referee.fontSize, referee.font, "center","top",false) offsetY = offsetY + column.height end end 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