Turbesz Posted August 28, 2016 Share Posted August 28, 2016 ERROR:xy\client.lua:13: attempt to call method 'gsub' (a nil value) --client local x, y = guiGetScreenSize() local font_os = (x/1600+y/900)/2 local font = font_os*1 local nSpaceY = dxGetFontHeight(font, "default-bold") local nSpaceYOld = dxGetFontHeight(2, "default-bold") local szovegek = {} for i=0, 4, 1 do szovegek[i] = "" end function itsRenderTime() for i = 0, 4, 1 do if szovegek[i] then local topSpaceX = dxGetTextWidth(szovegek[i]:gsub("#%x%x%x%x%x%x",""),font,"default-bold") local webX=topSpaceX+font_os*10 dxDrawRectangle ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 0, 0, 0, 155 ) ) dxDrawEmptyRec ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 255, 255, 255, 200 ), 2 ) dxDrawText ( szovegek[i], x-webX, nSpaceYOld*2+font_os*10+nSpaceY*(4-i)+font_os*(4-i), topSpaceX, nSpaceY, tocolor ( 255, 255, 255, 255 ), font, "default-bold", "left", "top",true,false,false,true ) end end end addEventHandler("onClientRender", getRootElement(), itsRenderTime) function infoServer2(szoveg) for i = 3, 0, -1 do szovegek[i+1] = szovegek[i] end szovegek[0] = szoveg end addEvent("infoServer2", true) addEventHandler("infoServer2",getRootElement(), infoServer2) function dxDrawEmptyRec(absX,absY,sizeX,sizeY,color,ancho) dxDrawRectangle ( absX,absY,sizeX,ancho,color ) dxDrawRectangle ( absX,absY+ancho,ancho,sizeY-ancho,color ) dxDrawRectangle ( absX+ancho,absY+sizeY-ancho,sizeX-ancho,ancho,color ) dxDrawRectangle ( absX+sizeX-ancho,absY+ancho,ancho,sizeY-ancho*2,color ) end local aValto = true function azEltunteto() if aValto then aValto = false removeEventHandler ( "onClientRender", root, itsRenderTime ) else aValto = true addEventHandler ( "onClientRender", root, itsRenderTime ) end end bindKey("delete","down",azEltunteto) --server local szovegek = {} local result = szovegek --outputChatBox(unpack(result)) addEventHandler('onPlayerChangeNick', root, function(oldNick, newNick) szovegek = { oldNick .. ' is now known as ' .. newNick, 255, 100, 100 } triggerClientEvent ( "infoServer2", getRootElement(), szovegek ) end ) Link to comment
Scripting Moderators thisdp Posted August 30, 2016 Scripting Moderators Share Posted August 30, 2016 You should use string.gsub Lua uses string library you can call functions with string.* Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 You should use string.gsubLua uses string library you can call functions with string.* function arguments expected near '.' wtf? Link to comment
JR10 Posted August 30, 2016 Share Posted August 30, 2016 You're sending a table, not a string. You need to retrieve the first element of that table, which is the string-type message. function infoServer2(szoveg) for i = 3, 0, -1 do szovegek[i+1] = szovegek[i] end szovegek[0] = szoveg[0] end addEvent("infoServer2", true) addEventHandler("infoServer2",getRootElement(), infoServer2) Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 You're sending a table, not a string. You need to retrieve the first element of that table, which is the string-type message. function infoServer2(szoveg) for i = 3, 0, -1 do szovegek[i+1] = szovegek[i] end szovegek[0] = szoveg[0] end addEvent("infoServer2", true) addEventHandler("infoServer2",getRootElement(), infoServer2) working, but doesn't show message Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Please add this line to -> function itsRenderTime() outputChatBox("works, until here...") It's just for debug. Add it and tell us if the message from the outputChatBox appears on the chat. Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 Please add this line to -> function itsRenderTime() outputChatBox("works, until here...") It's just for debug. Add it and tell us if the message from the outputChatBox appears on the chat. "works, until here..." Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Does it show that message on the chat? Link to comment
Turbesz Posted August 30, 2016 Author Share Posted August 30, 2016 Does it show that message on the chat? Yes! Link to comment
Simple0x47 Posted August 30, 2016 Share Posted August 30, 2016 Try this, and make sure that szovegek has values on its 1 - 4 indexes. function itsRenderTime() for i = 1, 4 do if szovegek[i] then -- It doesn't appear because it doesn't exist so please make sure that this table has into it values. local topSpaceX = dxGetTextWidth(szovegek[i]:gsub("#%x%x%x%x%x%x",""),font,"default-bold") local webX=topSpaceX+font_os*10 dxDrawRectangle ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 0, 0, 0, 155 ) ) dxDrawEmptyRec ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 255, 255, 255, 200 ), 2 ) dxDrawText ( szovegek[i], x-webX, nSpaceYOld*2+font_os*10+nSpaceY*(4-i)+font_os*(4-i), topSpaceX, nSpaceY, tocolor ( 255, 255, 255, 255 ), font, "default-bold", "left", "top",true,false,false,true ) end end end Link to comment
Turbesz Posted August 31, 2016 Author Share Posted August 31, 2016 Try this, and make sure that szovegek has values on its 1 - 4 indexes. function itsRenderTime() for i = 1, 4 do if szovegek[i] then -- It doesn't appear because it doesn't exist so please make sure that this table has into it values. local topSpaceX = dxGetTextWidth(szovegek[i]:gsub("#%x%x%x%x%x%x",""),font,"default-bold") local webX=topSpaceX+font_os*10 dxDrawRectangle ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 0, 0, 0, 155 ) ) dxDrawEmptyRec ( x-webX-font_os*5, nSpaceYOld*2+font_os*8+nSpaceY*(4-i)+font_os*(4-i), webX, nSpaceY+font_os*4, tocolor ( 255, 255, 255, 200 ), 2 ) dxDrawText ( szovegek[i], x-webX, nSpaceYOld*2+font_os*10+nSpaceY*(4-i)+font_os*(4-i), topSpaceX, nSpaceY, tocolor ( 255, 255, 255, 255 ), font, "default-bold", "left", "top",true,false,false,true ) end end end Doesn't working Link to comment
Simple0x47 Posted August 31, 2016 Share Posted August 31, 2016 That's because the table has no values into it. So try to add values into it and tell us if it works. Link to comment
Turbesz Posted August 31, 2016 Author Share Posted August 31, 2016 That's because the table has no values into it. So try to add values into it and tell us if it works. Doesn't working Link to comment
Simple0x47 Posted August 31, 2016 Share Posted August 31, 2016 Does the debugscript 3 say anything? Link to comment
Turbesz Posted August 31, 2016 Author Share Posted August 31, 2016 Does the debugscript 3 say anything? No, nothing. Link to comment
Simple0x47 Posted August 31, 2016 Share Posted August 31, 2016 Let's go again with the crazy debugging :v Add this: outputChatBox("Everything seems fine until here...") After this: if szovegek[i] then Link to comment
Turbesz Posted August 31, 2016 Author Share Posted August 31, 2016 Let's go again with the crazy debugging :v Add this: outputChatBox("Everything seems fine until here...") After this: if szovegek[i] then working:D Link to comment
Simple0x47 Posted August 31, 2016 Share Posted August 31, 2016 Maybe the position math's are wrong. Take a look at them and output them to see if they're right and they don't are outside the screen size. 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