Turbe$Z Posted October 16, 2016 Share Posted October 16, 2016 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 = {} local lp = getPlayerName(getLocalPlayer()) for i=0, 0, 1 do szovegeki = "" end function itsRenderTime() for i = 0, 0, 1 do if szovegeki then local topSpaceX = dxGetTextWidth(szovegeki: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 ( szovegeki, 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] = szovegeki 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) this is client (^) --- this is server (v) addEventHandler("onPlayerChangeNick", root, function(lastNick, newNick) local pName = getPlayerName(source) table.insert(szovegeki, lastNick.." change nick: "..newNick) triggerClientEvent("infoServer2", szovegeki) end) what wrong? how to fix ? thanks the help Link to comment
Dimos7 Posted October 16, 2016 Share Posted October 16, 2016 any error or warning in /debuscript 3? Link to comment
Turbe$Z Posted October 16, 2016 Author Share Posted October 16, 2016 (edited) 6 minutes ago, Dimos7 said: any error or warning in /debuscript 3? ERROR: xy\server.lua:3: bad argument #1 to 'insert' (table expected, got nil) Edited October 16, 2016 by Turbo777 Link to comment
iPrestege Posted October 16, 2016 Share Posted October 16, 2016 For sure it will be table isn't defined in server side use 'onClientPlayerChangeNick' insted. Also you are using table.insert with wrong way it should be table.insert ( table,{ Value } ) Link to comment
Turbe$Z Posted October 16, 2016 Author Share Posted October 16, 2016 3 minutes ago, FaHaD said: For sure it will be table isn't defined in server side use 'onClientPlayerChangeNick' insted. 'onClientPlayerChangeNick' in server side? o__O Link to comment
iPrestege Posted October 16, 2016 Share Posted October 16, 2016 No use it in client or make a trigger. Link to comment
Turbe$Z Posted October 16, 2016 Author Share Posted October 16, 2016 8 minutes ago, FaHaD said: No use it in client or make a trigger. i added this addEventHandler("onClientPlayerChangeNick", root, function(lastNick, newNick) table.insert(szovegek, lastNick.." change nick to "..newNick) end) to client side, but doesn't working. Why? What's the problem? Link to comment
iPrestege Posted October 16, 2016 Share Posted October 16, 2016 Try something like this: addEventHandler('onClientPlayerChangeNick',root, function ( lastNick, newNick ) local pText = ''..lastNick..' Change nick: '..newNick'' if ( pText ) then table.insert( szovegek,{pText}) else outputDebugString( 'Error getting info of player',1 ) end end ) Link to comment
Gravestone Posted October 16, 2016 Share Posted October 16, 2016 Do you only want to insert the player new name in the table or insert this full sentence? 5 minutes ago, Turbo777 said: lastNick.." change nick to "..newNick Link to comment
Turbe$Z Posted October 16, 2016 Author Share Posted October 16, 2016 4 minutes ago, FaHaD said: Try something like this: addEventHandler('onClientPlayerChangeNick',root, function ( lastNick, newNick ) local pText = ''..lastNick..' Change nick: '..newNick'' if ( pText ) then table.insert( szovegek,{pText}) else outputDebugString( 'Error getting info of player',1 ) end end ) addEventHandler('onClientPlayerChangeNick',root, function (lastNick, newNick) szovegeki = "ddd" end) this is working, but i have 5 line, and all change to 'ddd', instead of 1, how to fix this? Link to comment
iPrestege Posted October 16, 2016 Share Posted October 16, 2016 What you mean by you have five lines instead of one the same message apper 5 times? is there any errors? Post the hole new code. Link to comment
Turbe$Z Posted October 16, 2016 Author Share Posted October 16, 2016 Just now, FaHaD said: What you mean by you have five lines instead of one the same message apper 5 times? is there any errors? Post the hole new code. No errors. http://imgur.com/9xpfMBn this 5 lines -- Magyar DDC Szerver 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 = {} local lp = getPlayerName(getLocalPlayer()) for i=0, 0, 1 do szovegeki = "" end function itsRenderTime() for i = -4, 0, 1 do if szovegeki then local topSpaceX = dxGetTextWidth(szovegeki: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 ( szovegeki, 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) addEventHandler('onClientPlayerChangeNick',root, function (lastNick, newNick) szovegeki = "ddd" end) function infoServer2(szoveg) for i = 3, 0, -1 do szovegek[i+1] = szovegeki 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) Link to comment
Gravestone Posted October 16, 2016 Share Posted October 16, 2016 Isn't this topic same as this one? Link to comment
Gravestone Posted October 16, 2016 Share Posted October 16, 2016 Double posting is against rules. 1 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