xnot2x Posted September 13, 2015 Posted September 13, 2015 hi ,this is my first subject and i hope that you help me fast 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
' A F . Posted September 13, 2015 Posted September 13, 2015 'onClientResourceStart' onPlayerJoin -- Server guiStaticImageLoadImage -- Client guiCreateStaticImage -- Client guiGetScreenSize -- Client
-ffn-python Posted September 13, 2015 Posted September 13, 2015 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 )
xnot2x Posted September 13, 2015 Author Posted September 13, 2015 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
Tete omar Posted September 14, 2015 Posted September 14, 2015 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.
xnot2x Posted September 14, 2015 Author Posted September 14, 2015 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
Tete omar Posted September 14, 2015 Posted September 14, 2015 In line 8 of your code, replace "onPlayerJoin" with "onClientResourceStart" and "getRootElement()" with "resourceRoot". Make sure the script's type is "client" in meta.xml file.
Moderators Citizen Posted September 14, 2015 Moderators Posted September 14, 2015 hi ,this is my first subject and i hope that you help me fast 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now