Jump to content

Clean screen


dima3367

Recommended Posts

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

 

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
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

Mta_game_proccess.png

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
  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...