Jump to content

How to put an image when i join server


sagi100

Recommended Posts

2 hours ago, sagi100 said:

How do i upload the image and where should i put it

Put this in client

local screenW, screenH = guiGetScreenSize()

function imag()
 
addEventHandler("onClientRender", getRootElement(), render)

end
addEventHandler ( "onClientPlayerJoin", getLocalPlayer(), imag )


function render()
 showChat(false)
    dxDrawImage((screenW - 800) / 2, (screenH - 600) / 2, 800, 600, "hello.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

This in meta.xml


<meta>
	<info author="YourName" version="1.0" name="Welcome" description="Welcome To My Server" type="script" />
	<script src="client.lua" type="client" />
	<file src="hello.png" />
</meta>

Now you need download a image, put her in png mode and take it to your resource ( you going to change her name to "hello" )

Link to comment
Just now, <~KaMiKaZe~> said:

Put this in client


local screenW, screenH = guiGetScreenSize()

function imag()
 
addEventHandler("onClientRender", getRootElement(), render)

end
addEventHandler ( "onClientPlayerJoin", getLocalPlayer(), imag )


function render()
 showChat(false)
    dxDrawImage((screenW - 800) / 2, (screenH - 600) / 2, 800, 600, "hello.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
end

This in meta.xml


<meta>
	<info author="YourName" version="1.0" name="Welcome" description="Welcome To My Server" type="script" />
	<script src="client.lua" type="client" />
	<file src="hello.png" />
</meta>

Now you need download a image, put her in png mode and take it to your resource ( you going to change her name to "hello" )

what client ?like where should i put it bro.

please i'm new here 

Link to comment
1 minute ago, <~kamikaze~> said:

do you have the lua program ?

yea like i should put this on the notepad +++ 

make also an meta file and move it to rescource?

btw how to i choose the image that i want , like how i need to upload her to the script

Edited by sagi100
Link to comment

'onClientPlayerJoin' event will trigger for all players except the local player.You need to use 'onClientResourceStart'.

Try this
 

local x,y = guiGetScreenSize()
local image
addEventHandler("onClientResourceStart",resourceRoot,
function()
	image = guiCreateStaticImage(x/2-400/2,y/2-400/2,400,400,"hello.png",false)
end)

Also add this line to your resource's meta.xml.It means that resource will be started earlier than other resources.

<download_priority_group>1</download_priority_group>
Edited by IRBIS
Link to comment
3 hours ago, IRBIS said:

'onClientPlayerJoin' event will trigger for all players except the local player.You need to use 'onClientResourceStart'.

Try this
 


local x,y = guiGetScreenSize()
local image
addEventHandler("onClientResourceStart",resourceRoot,
function()
	image = guiCreateStaticImage(x/2-400/2,y/2-400/2,400,400,"hello.png",false)
end)

Also add this line to your resource's meta.xml.It means that resource will be started earlier than other resources.


<download_priority_group>1</download_priority_group>

it's does work but the picture does not getting of the screen.

i want it only when i restart the map, a race map , so the picture will be on the screen for few sec till game start.

how can i fix it?

Link to comment
1 hour ago, sagi100 said:

it's does work but the picture does not getting of the screen.

i want it only when i restart the map, a race map , so the picture will be on the screen for few sec till game start.

how can i fix it?

Make sure you load the file in meta.xml too.

<file src="hello.png" />

 

Link to comment
2 minutes ago, myonlake said:

Make sure you load the file in meta.xml too.


<file src="hello.png" />

 

i do ,the image does showing up but she is not getting out of the screen,i want that i will be only when player join till the map starts for him

i saw it in many server.

4 minutes ago, myonlake said:

Make sure you load the file in meta.xml too.


<file src="hello.png" />

 

timer is needed?

Link to comment

If you only want the player to see it once, then this could work:

-- Whenever onClientMapStarting is triggered by mapmanager, execute the function
addEventHandler("onClientMapStarting", root, function()
	-- If the local player has already seen the server logo once, let's not show it again
	if (getElementData(localPlayer, "hasSeenServerLogo")) then
		return
	end

	-- Let's get our screen dimensions 
	local screenWidth, screenHeight = guiGetScreenSize()

	-- Let's create a static image element into serverLogo
	local serverLogo = guiCreateStaticImage(0, 0, 0, 0, "hello.png", false)

	-- Let's get the native image size
	local serverLogoWidth, serverLogoHeight = guiStaticImageGetNativeSize(serverLogo)

	-- Let's center the image
	guiSetPosition(serverLogo, (screenWidth - serverLogoWidth) / 2, (screenHeight - serverLogoHeight) / 2, false)
	guiSetSize(serverLogo, serverLogoWidth, serverLogoHeight, false)

	-- Let's destroy the logo in 7000 ms (7 seconds)
	setTimer(destroyElement, 7000, 1, serverLogo)

	-- Let's give the local player hasSeenServerLogo data so they won't see it again
	setElementData(localPlayer, "hasSeenServerLogo", true)
end)

 

Edited by myonlake
Link to comment
9 minutes ago, myonlake said:

If you only want the player to see it once, then this could work:


addEventHandler("onClientMapStarting", root, function()
	if (getElementData(localPlayer, "hasSeenServerLogo")) then
		return
	end

	local screenWidth, screenHeight = guiGetScreenSize()
	local serverLogo = guiCreateStaticImage(0, 0, 0, 0, "icon.jpg", false)
	local serverLogoWidth, serverLogoHeight = guiStaticImageGetNativeSize(serverLogo)

	guiSetPosition(serverLogo, (screenWidth - serverLogoWidth) / 2, (screenHeight - serverLogoHeight) / 2, false)
	guiSetSize(serverLogo, serverLogoWidth, serverLogoHeight, false)

	setTimer(destroyElement, 7000, 1, serverLogo)

	setElementData(localPlayer, "hasSeenServerLogo", true)
end)

 

I already have working code, now i need to know how to make it also when i restart the map or choose map

Link to comment

If you want the players to see it every time a map starts, then the following could work:

-- Let's get our screen dimensions
local screenWidth, screenHeight = guiGetScreenSize()

-- Save the static image into serverLogo, and the server logo timer into serverLogoTimer
local serverLogo, serverLogoTimer

-- Whenever onClientMapStarting is triggered by mapmanager, execute the function
addEventHandler("onClientMapStarting", root, function()
	-- If we already have a valid server logo timer, let's kill it
	if (isTimer(serverLogoTimer)) then
		killTimer(serverLogoTimer)
	end

	-- If we already have a server logo element, let's destroy it
	if (isElement(serverLogo)) then
		destroyElement(serverLogo)
	end

	-- Let's create a static image element into serverLogo
	serverLogo = guiCreateStaticImage(0, 0, 0, 0, "hello.png", false)

	-- Let's get the native image size
	local serverLogoWidth, serverLogoHeight = guiStaticImageGetNativeSize(serverLogo)

	-- Let's center the image
	guiSetPosition(serverLogo, (screenWidth - serverLogoWidth) / 2, (screenHeight - serverLogoHeight) / 2, false)
	guiSetSize(serverLogo, serverLogoWidth, serverLogoHeight, false)

	-- Let's destroy the logo in 7000 ms (7 seconds)
	serverLogoTimer = setTimer(destroyElement, 7000, 1, serverLogo)
end)

 

Edited by myonlake
Link to comment
4 minutes ago, myonlake said:

-- Let's get our screen dimensions
local screenWidth, screenHeight = guiGetScreenSize()

-- Save the static image into serverLogo, and the server logo timer into serverLogoTimer
local serverLogo, serverLogoTimer

-- Whenever onClientMapStarting is triggered by race, execute the function
addEventHandler("onClientMapStarting", root, function()
	-- If we already have a valid server logo timer, let's kill it
	if (isTimer(serverLogoTimer)) then
		killTimer(serverLogoTimer)
	end

	-- If we already have a server logo element, let's destroy it
	if (isElement(serverLogo)) then
		destroyElement(serverLogo)
	end

	-- Let's create a static image element into serverLogo
	serverLogo = guiCreateStaticImage(0, 0, 0, 0, "icon.jpg", false)

	-- Let's get the native image size
	local serverLogoWidth, serverLogoHeight = guiStaticImageGetNativeSize(serverLogo)

	-- Let's center the image
	guiSetPosition(serverLogo, (screenWidth - serverLogoWidth) / 2, (screenHeight - serverLogoHeight) / 2, false)
	guiSetSize(serverLogo, serverLogoWidth, serverLogoHeight, false)

	-- Let's destroy the logo in 7000 ms (7 seconds)
	serverLogoTimer = setTimer(destroyElement, 7000, 1, serverLogo)
end)

Ty bro do you know how to disable race intro?

Link to comment
16 minutes ago, myonlake said:

If you want to hide the race logo, then in race/race_client.lua file, comment line 84:


--g_GUI['titleImage'] = guiCreateStaticImage(screenWidth/2-256, screenHeight/2-256+adjustY, 512, 512, 'img/title.png', false)

 

i need to remove this line?

Link to comment

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