FatalTerror Posted January 2, 2012 Share Posted January 2, 2012 Hi, I've playing in a server and i see a thing, a text before the download. Exist an event for it? How he do it Thanks Link to comment
Kenix Posted January 2, 2012 Share Posted January 2, 2012 Maybe you mean "Downloading Text" ? Easy,Example: Server: addEvent( "onClientSend",true ) local serverDisplay,serverText addEventHandler( "onClientSend",root, function( ) textDisplayRemoveObserver( serverDisplay, source ) end ) addEventHandler( "onPlayerJoin",root, function( ) serverDisplay = textCreateDisplay( ) textDisplayAddObserver ( serverDisplay, source ) serverText = textCreateTextItem ( "Downloading.Please wait!", 0.5, 0.5,1,255,0,0,255,2,"center","center",200 ) textDisplayAddText ( serverDisplay, serverText ) end ) Client: triggerServerEvent( "onClientSend",localPlayer ) -- trigger to remove text if player downloaded or maybe you mean this: Server: local timeShow = 5000 -- 5 seconds timerConnectShowText = { } addEventHandler( "onPlayerJoin",root, function( ) local serverDisplay = textCreateDisplay( ) textDisplayAddObserver ( serverDisplay, source ) local serverText = textCreateTextItem ( "Downloading.Please wait!", 0.5, 0.5,1,255,0,0,255,2,"center","center",200 ) textDisplayAddText ( serverDisplay, serverText ) timerConnectShowText[ source ] = setTimer( textDisplayRemoveObserver,timeShow,1,serverDisplay, source ) end ) addEventHandler( "onPlayerQuit",root, function( ) timerConnectShowText[ source ] = nil end ) Naturally, this example you need to modify it. Link to comment
Al3grab Posted January 2, 2012 Share Posted January 2, 2012 you use this function to check if player downloading isTransferBoxActive Like this -- Client Side local localPlayer = getLocalPlayer() function checkIfDown() if isTransferBoxActive() == false then triggerServerEvent( "onClientSend",localPlayer ) -- trigger to remove text if player downloaded if isTimer(Timer) then killTimer(Timer) end -- kills the checking timer end end Timer = setTimer(checkIfDown,1000,0) Link to comment
Kenix Posted January 2, 2012 Share Posted January 2, 2012 isTransferBoxActive not working if you downloading. But if you restart resource isTransferBoxActive needed or write warning with textDisplayRemoveObserver ( serverDisplay is nil ) . This is better: local timer = setTimer( function( ) if not isTransferBoxActive( ) then triggerServerEvent( "onClientSend",localPlayer ) killTimer( timer ) end end, 1000, 2 ) Remember operator "not" is if function return nil or false. This is better than to check the value. Link to comment
myonlake Posted January 16, 2014 Share Posted January 16, 2014 Make a separate resource and use what Kenix posted. Make the server-side event within that downloader resource (make sure it's downloaded first), and when client calls server that a resource has been downloaded, add it to a table and wait for all resources to be in it. When everything's in, cut the text and trigger the login panel or whatever. Link to comment
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