Jump to content

Calling an clientimage from the server


Deltanic

Recommended Posts

Hi,

I want to show images for the client, but they must be called with the server. But how do is do this? It's for my stealth server. When a round ends, I want to show a image instead of some text. I thought about doing this:

Client:

function showClientRedWins()
guiCreateStaticImage( 123, 123, 123, 123, "image.png", false )
end

Server:

triggerClientEvent ( something-here? "showClientRedWins" something-here? )

But am I doing this right? And what must I fill in for "something-here"?

Edited by Guest
Link to comment

Ok, I read it again, and I did the following:

Client:

addEvent( "showRedWinImage", true )
function handleRedWinImage ()
guiCreateStaticImage( 20, 200, 640, 480, "redwin.png", false ) --Positions are for testing, I don't know the exact middle of the screen
end
addEventHandler( "showRedWinImage", getRootElement(), handleRedWinImage )
 
addEvent( "showBlueWinImage", true )
function handleBlueWinImage ()
guiCreateStaticImage( 20, 200, 640, 480, "bluewin.png", false ) --Positions are for testing, I don't know the exact middle of the screen
end
addEventHandler( "showBlueWinImage", getRootElement(), handleBlueWinImage )
 
addEvent( "showTieWinImage", true )
function handleTieWinImage ()
guiCreateStaticImage( 20, 200, 640, 480, "tiewin.png", false ) --Positions are for testing, I don't know the exact middle of the screen
end
addEventHandler( "showTieWinImage", getRootElement(), handleTieWinImage )

Server:

--Replaced textDisplayAddObserver( redwinsdisplay, thisplayer ) with triggerClientEvent ( thisplayer , "showRedWinImage"), and so on for blue and tie
function stealthroundended( timerID, player )
if playingaround == 1 then
if ( tostring(timerID) == tostring(roundfinish) ) then
if team1survivers > team2survivers then
local alltheplayers = getElementsByType("player")
for index, thisplayer in ipairs(alltheplayers) do
triggerClientEvent ( thisplayer , "showRedWinImage")
end
local teampoints = getElementData ( team1, "Score" )
setElementData ( team1, "Score", teampoints+1  )
end	
end
end
end

 

Meta.xml:

<file src="redwin.png" />
<file src="bluewin.png" />
<file src="tiewin.png" />

------------------------------------------------------

Example of one of these pictures.

Size: 640X480 PX, 25,8 KB

But the picture doesn't show. What's wrong than?

Link to comment

AWESOME, thank you :D

Just two things left, how do I hide the image?

And how do I put the image completely at the background? So if someone is new, and he wants to choose his team, he can't click on it now, because that image is in front of that gui. So I want that image behind it, always. How?

And a little question if someone knows, which X-Y point is the middle of the screen, to show my image in the middle?

Link to comment
AWESOME, thank you :D

Just two things left, how do I hide the image?

And how do I put the image completely at the background? So if someone is new, and he wants to choose his team, he can't click on it now, because that image is in front of that gui. So I want that image behind it, always. How?

And a little question if someone knows, which X-Y point is the middle of the screen, to show my image in the middle?

Why don't you read the tutorial about GUI? You know where to learn from now.

The center of the screen is just a simple math calculation which you should already know about...

screenSize = { guiGetScreenSize() } -- make a table which is the size of player's screen, width -> [1], height -> [2]
 
local centerOfScreenX = screenSize[ 1 ] / 2;
local centerOfScreenY = screenSize[ 2 ] / 2;
 
-- take a note of size of your image you want to display, eg. 100x200
-- and get the center of it or rather get half of its dimensions
local centerOfImageX = 100 / 2;
local centerOfImageY = 200 / 2;
MYIMAGE = guiCreateStaticImage( centerOfScreenX - centerOfImageX, centerOfScreenY - centerOfImageY, 100, 200, "IMAGE.png", false )
 
-- hide:
guiSetVisible( MYIMAGE, false );
 
-- make it underneath everything:
guiMoveToBack( MYIMAGE )

READ THE WIKI AND TUTORIALS IF YOU HAVE QUESTIONS REGARDING SUCH THINGS.

Most of the functions names are self-explanatory.

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