dima3367 Posted January 14, 2017 Share Posted January 14, 2017 Hello! Since my server players often make photos they need to quickly remove all the excess from the screen. For this I use here is the script: local x, y = guiGetScreenSize() function PlayerNameTags() local players = getElementsByType("player") for k,v in ipairs(players) do if v == getLocalPlayer() then else setPlayerNametagShowing ( v, false ) local r, g, b = getPlayerNametagColor(v) local x1,y1,z1 = getElementPosition (getLocalPlayer()) local x2,y2,z2 = getElementPosition (v) local visibleto = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) if visibleto > 75 then else local sx,sy = getScreenFromWorldPosition ( x2,y2,z2+1.05 ) if not sx and not sy then else dxDrawText ( getPlayerName ( v ), sx,sy-15,sx,sy, tocolor(r,g,b,255), 1.1-visibleto/50, "default-bold", "center","top",false, false, false, true, false ) end end end end end addEventHandler("onClientRender",getRootElement(),PlayerNameTags) local screenWidth,screenHeight = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function() myScreenSource = dxCreateScreenSource ( screenWidth, screenHeight ) end ) function cleanmyscreen() if myScreenSource then dxUpdateScreenSource( myScreenSource ) dxDrawImage( screenWidth - screenWidth, screenHeight - screenHeight, screenWidth, screenHeight, myScreenSource, 0, 0, 0, tocolor (255, 255, 255, 255), true) end end function tooglecleanmyscreen () enabled = not enabled if enabled then addEventHandler( "onClientRender", root, cleanmyscreen) else removeEventHandler( "onClientRender", root, cleanmyscreen) end end bindKey ("i", "down", tooglecleanmyscreen) It hides absolutely everything: chat, hud, nicks. But I would like that to the screenshots players could see my server's logo, which is in my top right corner (There is a separate resource). How can I possibly do this in my life clean the screen? Thanks in advance for your reply and sorry for my bad english! Link to comment
myonlake Posted January 14, 2017 Share Posted January 14, 2017 Use addEventHandler's priority parameter on your onClientRender events. That way you'll be able to render the images from different resources in the right order. Link to comment
dima3367 Posted January 14, 2017 Author Share Posted January 14, 2017 48 minutes ago, myonlake said: Use addEventHandler's priority parameter on your onClientRender events. That way you'll be able to render the images from different resources in the right order. you could make an example could not? Link to comment
myonlake Posted January 14, 2017 Share Posted January 14, 2017 (edited) 58 minutes ago, dima3367 said: you could make an example could not? Right. addEventHandler( "onClientRender", root, myFunction, true, "low" ) -- For your logo Edited January 14, 2017 by myonlake Link to comment
dima3367 Posted January 14, 2017 Author Share Posted January 14, 2017 1 minute ago, myonlake said: Right. addEventHandler( "onClientRender", root, myFunction, true, "low" ) -- For your logo This, I must add the resource to the cleaning or in the logo resource? Link to comment
myonlake Posted January 14, 2017 Share Posted January 14, 2017 1 hour ago, dima3367 said: This, I must add the resource to the cleaning or in the logo resource? Logo resource, as you want it to have lower priority than the background images. Link to comment
dima3367 Posted January 17, 2017 Author Share Posted January 17, 2017 gRoot = getRootElement() gResRoot = getResourceRootElement( getThisResource() ) addEventHandler( "onClientRender", root, gResRoot, true, "low", addEventHandler( "onClientResourceStart", gResRoot, function () serverlogo = guiCreateStaticImage ( 0.87, 0.015, 0.15, 0.13, "logocris.png", true ) end )) I put this addEventHandler logo in the server resource code, but for some reason he still breaks. Link to comment
Moderators IIYAMA Posted January 18, 2017 Moderators Share Posted January 18, 2017 On 17-1-2017 at 14:18, dima3367 said: gRoot = getRootElement() gResRoot = getResourceRootElement( getThisResource() ) addEventHandler( "onClientRender", root, gResRoot, true, "low", addEventHandler( "onClientResourceStart", gResRoot, function () serverlogo = guiCreateStaticImage ( 0.87, 0.015, 0.15, 0.13, "logocris.png", true ) end )) I put this addEventHandler logo in the server resource code, but for some reason he still breaks. Wut? How many addEventHandler's, functions, logo's do you want? 1000000? This is why it doesn't work: https://wiki.multitheftauto.com/wiki/Game_Processing_Order You can't decide when you render a GUI, that does MTA for you because they(GUI's) are elements. While with dx you can change the render order in your code. Render your logo with this, to solve the problem: dxDrawImage Link to comment
dima3367 Posted March 16, 2017 Author Share Posted March 16, 2017 The topic is still relevant. Who can help? 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