Jump to content

[Help] guiCreateStaticImage


xnot2x

Recommended Posts

hi ,this is my first subject and i hope that you help me fast :D

i'm trying to make splash screen by using ( guiStaticImageLoadImage ) and i want it to end after 9 second

  
local screenWidth,screenHeight = guiGetScreenSize()  
function showimg() 
local myImage = guiCreateStaticImage ( 0, 0, screenWidth , screenHeight, "1.jpg", true ) 
setTimer ( guiStaticImageLoadImage, 3000, 1, myImage, "2.jpg" ) 
setTimer ( guiStaticImageLoadImage, 6000, 1, myImage, "3.jpg" ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(),showimg) 
  

and sorry about me English i Know it's very bad :arrow::|

Link to comment

Change. very easy lua.

local screenWidth,screenHeight = guiGetScreenSize() 
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
triggerServerEvent("onPlayerLoginServer", getLocalPlayer()) 
end 
) 
  
addEvent("onClientPlayerLogin", true) 
addEventHandler("onClientPlayerLogin", root, 
function() 
local myImage = guiCreateStaticImage ( 0, 0, screenWidth , screenHeight, "1.jpg", true ) 
setTimer ( guiStaticImageLoadImage, 3000, 1, myImage, "2.jpg" ) 
setTimer ( guiStaticImageLoadImage, 6000, 1, myImage, "3.jpg" ) 
end 
) 
  

Server-Side

addEvent("onPlayerLoginServer", true) 
addEventHandler("onPlayerLoginServer", root, 
function() 
triggerClientEvent(client, "onClientPlayerLogin", client) 
end 
) 

Link to comment
Change. very easy lua.
local screenWidth,screenHeight = guiGetScreenSize() 
addEventHandler("onClientResourceStart", resourceRoot, 
function() 
triggerServerEvent("onPlayerLoginServer", getLocalPlayer()) 
end 
) 
  
addEvent("onClientPlayerLogin", true) 
addEventHandler("onClientPlayerLogin", root, 
function() 
local myImage = guiCreateStaticImage ( 0, 0, screenWidth , screenHeight, "1.jpg", true ) 
setTimer ( guiStaticImageLoadImage, 3000, 1, myImage, "2.jpg" ) 
setTimer ( guiStaticImageLoadImage, 6000, 1, myImage, "3.jpg" ) 
end 
) 
  

Server-Side

addEvent("onPlayerLoginServer", true) 
addEventHandler("onPlayerLoginServer", root, 
function() 
triggerClientEvent(client, "onClientPlayerLogin", client) 
end 
) 

thank you for helping me

but the main problem not solved yet

which is i want to hide the img after 9 second or kill the function

Link to comment

It appears that you're trying to display that "splash screen" when player joins the server. All you need is to do is to see if player has joined and finished downloading by using onClientResourceStart. You don't need serverside to do that. If you want special effects on your "splash screen" though, i would recommend using dxCreateImage. But you must first bother with using DX functions to understand how it works.

Link to comment
It appears that you're trying to display that "splash screen" when player joins the server. All you need is to do is to see if player has joined and finished downloading by using onClientResourceStart. You don't need serverside to do that. If you want special effects on your "splash screen" though, i would recommend using dxCreateImage. But you must first bother with using DX functions to understand how it works.

what i trying to do is start the img show and finished in 9 Second

every image take 3 Second only

and then the images disappear from the screen

Link to comment
  • Moderators
hi ,this is my first subject and i hope that you help me fast :D

i'm trying to make splash screen by using ( guiStaticImageLoadImage ) and i want it to end after 9 second

  
local screenWidth,screenHeight = guiGetScreenSize()  
function showimg() 
local myImage = guiCreateStaticImage ( 0, 0, screenWidth , screenHeight, "1.jpg", true ) 
setTimer ( guiStaticImageLoadImage, 3000, 1, myImage, "2.jpg" ) 
setTimer ( guiStaticImageLoadImage, 6000, 1, myImage, "3.jpg" ) 
end 
addEventHandler ( "onPlayerJoin", getRootElement(),showimg) 
  

and sorry about me English i Know it's very bad

You were pretty close actually !

"onPlayerJoin" is a server event only, he has a "clone" in the client side called: "onClientPlayerJoin" but it's still not the right event to use in your case as it is triggered before the player downloads the client scripts.

So as Tete omar said, you have to use "onClientResourceStart" which will be triggered each time a resource is started.

So to make sure our showimg() function (which is the handler of our event) will be called only for the current resource, we have to restrict the scope of that handler to the root of the current resource by replacing getRootElement() by getResourceRootElement( getThisResource() ).

And finally the last thing you wanted to do is to destroy/delete the image after 9 seconds.

Client:

local screenWidth,screenHeight = guiGetScreenSize() 
function showimg() 
    local myImage = guiCreateStaticImage ( 0, 0, screenWidth , screenHeight, "1.jpg", true ) 
    setTimer ( guiStaticImageLoadImage, 3000, 1, myImage, "2.jpg" ) 
    setTimer ( guiStaticImageLoadImage, 6000, 1, myImage, "3.jpg" ) 
    -- You wanted to destroy the image after 9 secs: 
    setTimer ( destroyElement, 9000, 1, myImage ) 
end 
-- You wanted it when this resource start (and it will start when the player connected to the server and finished to download the client scripts): 
addEventHandler ( "onClientResourceStart", getResourceRootElement( getThisResource() ), showimg) 

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