'~DaLesTe^' Posted June 19, 2019 Share Posted June 19, 2019 (edited) I can not make a DxText that displays the player's account name in screen My code (CLIENT SIDE) CHECK LINE 109 Spoiler function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText( cap, ax, ay, ax + w, by, color, scale, font ) ax = ax + w color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end last = e + 1 s, e, cap, col = str:find( pat, last ) end if last <= #str then cap = str:sub( last ) local w = dxGetTextWidth( cap, scale, font ) dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI ) end end local messageJoin = "" local messageQuit = "" local x,y = guiGetScreenSize() function renderPlayerJoined ( ) dxDrawRectangle( x/1980, y/2.82, x/3.6, y/34.1, tocolor ( 0, 0, 0, 50 )) dxDrawColorText("*".. messageJoin,x/100, y/2.80, x/1.0, y/1.1,tocolor(255,255,255,100),0.9,"clear","left","top",false,false,false) end function renderPlayerLeft ( ) dxDrawRectangle( x/1980, y/2.15, x/3.6, y/34.1, tocolor ( 0, 0, 0, 50 )) dxDrawColorText("*".. messageQuit,x/100, y/2.17, x/1.0, y/1.1,tocolor(255,255,255,100),0.9,"clear","left","top",false,false,false) end function renderPlayerName ( ) dxDrawRectangle( x/1980, y/1.82, x/3.6, y/34.1, tocolor ( 0, 0, 0, 50 )) dxDrawColorText("*".. messageNick,x/100, y/1.80, x/1.0, y/1.1,tocolor(255,255,255,100),0.9,"clear","left","top",false,false,false) end function renderPlayerLogin ( ) dxDrawRectangle( x/1980, y/1.82, x/3.6, y/34.1, tocolor ( 0, 0, 0, 50 )) dxDrawColorText("*".. messageLogin,x/100, y/1.80, x/1.0, y/1.1,tocolor(255,255,255,100),0.9,"clear","left","top",false,false,false) end ---join addEventHandler('onClientPlayerJoin', root, function() messageJoin = getPlayerName(source) .. "(ID:" .. (getPlayerID(source) or "?") .. ") #ffffffentrou no Servidor" addEventHandler ( "onClientRender", root, renderPlayerJoined ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerJoined ) end ,6000,1 ) end ) --- quit addEventHandler('onClientPlayerQuit', root, function(reason) messageQuit = getPlayerName(source) .. "(ID:" .. (getPlayerID(source) or "?") .. ") #ffffffsaiu do Servidor #ff0000[" .. reason .. "]" addEventHandler ( "onClientRender", root, renderPlayerLeft ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerLeft ) end ,6000,1 ) end ) g_Root = getRootElement() --- nick addEventHandler('onClientPlayerChangeNick', g_Root, function(oldNick, newNick) messageNick ="#ffffff " .. oldNick .. "(ID:" .. (getPlayerID(source) or "?") .. ") #ffffffmudou seu nick parar " .. newNick .. "" addEventHandler ( "onClientRender", root, renderPlayerName ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerName ) end ,6000,1 ) end ) function getPlayerFromID(id) return call(getResourceFromName("game_id2"), "getPlayerFromID", tonumber(id)) end function getPlayerID(player) return getElementData(player,"id") end --- login account ------- THE PROBLEM IS HERE addEventHandler('onPlayerLogin', root, function() if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Everyone")) then messageLogin = getPlayerName(source) .. "(ID:" .. (getPlayerID(source) or "?") .. ") #ffffffhas logged:[" .. getAccountName(getPlayerAccount(source)) .. "] " addEventHandler ( "onClientRender", root, renderPlayerLogin ) setTimer ( function ( ) removeEventHandler ( "onClientRender", root, renderPlayerLogin ) end ,6000,1 ) end end ) I wanted it to work this way: no one debugscript error example image Edited June 19, 2019 by '~DaLesTe^' I forgout the "client side" Link to comment
MTA Team 0xCiBeR Posted June 19, 2019 MTA Team Share Posted June 19, 2019 (edited) You are using Server-Side only events and functions on a client side file. You should make 2 files, one client-side and one server-side and trigger events or use elementDatas. ServerSide:getAccountNameonPlayerLoginisObjectInACLGroupgetAccountNamegetPlayerAccountaclGetGroup Edited June 19, 2019 by .:CiBeR:. Link to comment
'~DaLesTe^' Posted June 19, 2019 Author Share Posted June 19, 2019 Yes i tried to make in client side and server side but dont work, how? Link to comment
MTA Team 0xCiBeR Posted June 19, 2019 MTA Team Share Posted June 19, 2019 I have told you how to do it. Use triggers.triggerClientEvent 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