Sign in to follow this  
sagi100

How to put an image when i join server

Recommended Posts

Hello every one,i have a DD cw server,i want to put my clan logo on the screen in the begging of every round .

I saw alot of servers with it, how can i do it

Share this post


Link to post
31 minutes ago, DABL said:

"onClientPlayerJoin"
guiCreateStaticImage

 

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

Share this post


Link to post
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" )

Share this post


Link to post
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 

Share this post


Link to post
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

Share this post


Link to post
1 minute ago, sagi100 said:

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

make also an meta file and move it to rescource?

 

Yes, you have to do that with the given instructions

Share this post


Link to post

'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

Share this post


Link to post
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?

Share this post


Link to post
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" />

 

Share this post


Link to post
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?

Share this post


Link to post

i need a script of this:

when i join the server it will show   logo / image /  for 7 seconds , and then it will stop auto.

By the way , there is the dealy with 

Share this post


Link to post

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

Share this post


Link to post
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

Share this post


Link to post

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

Share this post


Link to post
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?

Share this post


Link to post

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)

 

Share this post


Link to post
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?

Share this post


Link to post
5 minutes ago, sagi100 said:

i need to remove this line?

Comment line 84 by adding two dashes in front of it "--".

You can also delete the line...

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.