kuba90pl Posted April 12, 2013 Share Posted April 12, 2013 Hey! I wanted to make a message while downloading files in my server. Well i know i need to use onClientResourceStart , but i dont know which way i need to use it. i tried: function downloadingText() addEventHandler("onClienResourceStart",root,startText) addEvent("downloadingText",true) addEventHandler("downloadingText",root,downloadingText) function startText() addEventHandler("onClientRender",root,napisSciagnie) end function napisSciaganie() local x, y = guiGetScreenSize() dxDrawText ( "ASDASDADADSDASDADDDASDAD", 100,100,400,400, tocolor(255,255,255,255), 2, "default-small", "center","top",false,false,false ) end function join() triggerClientEvent(source,"downloadingText",source) end addEventHandler("onPlayerJoin",root,join) doesnt work. any tips? Link to comment
Sasu Posted April 12, 2013 Share Posted April 12, 2013 function napisSciagnie() local x, y = guiGetScreenSize() dxDrawText ( "ASDASDADADSDASDADDDASDAD", 100,100,400,400, tocolor(255,255,255,255), 2, "default-small", "center","top",false,false,false ) end function startText() addEventHandler("onClientRender",root, napisSciagnie) end addEventHandler("onClienResourceStart",root,startText) And pls use lua tags [ lua ] [ /lua ] Link to comment
kuba90pl Posted April 12, 2013 Author Share Posted April 12, 2013 still doesnt show message while downloading files Link to comment
Sasu Posted April 12, 2013 Share Posted April 12, 2013 Fail. I wrote wrong the event: function napisSciagnie() local x, y = guiGetScreenSize() dxDrawText ( "ASDASDADADSDASDADDDASDAD", 100,100,400,400, tocolor(255,255,255,255), 2, "default-small", "center","top",false,false,false ) end function startText() addEventHandler("onClientRender", root, napisSciagnie) end addEventHandler("onClientResourceStart", root, startText) Link to comment
PaiN^ Posted April 12, 2013 Share Posted April 12, 2013 Client Side scripts are dose not start until all files are downloaded in the client's PC, Try To make a trigger from the server with the event onPlayerJoin to draw that text, And then use the event onClientResourceStart to remove the text ones all files are downloaded on the clients PC ... @Sasuke : You should use resourceRoot with the events onResourceStart & onClientResourceStart Link to comment
Sasu Posted April 12, 2013 Share Posted April 12, 2013 (edited) Client: function napisSciagnie() local x, y = guiGetScreenSize() dxDrawText ( "ASDASDADADSDASDADDDASDAD", 100,100,400,400, tocolor(255,255,255,255), 2, "default-small", "center","top",false,false,false ) end function startText() addEventHandler("onClientRender", root, napisSciagnie) end addEvent("downloadingFiles", true) addEventHandler("downloadingFiles", root, startText) function stopText() removeEventHandler("onClientRender", root, napisSciagnie) end addEventHandler("onClientResourceStart", resourceRoot, stopText) Server: function startText() triggerClientEvent(source, "downloadingFiles", source) end addEventHandler("onPlayerJoin", root, startText) Is it correct #Pain_[N] ? Edited April 12, 2013 by Guest Link to comment
PaiN^ Posted April 12, 2013 Share Posted April 12, 2013 You are using triggerServerEvent in the server file + Mr.Pres[T]ege's way is much easier and better .. Link to comment
DNL291 Posted April 13, 2013 Share Posted April 13, 2013 Server: addEvent( "removeTextDisplay", true ) addEventHandler( "removeTextDisplay", root, function() textDisplayRemoveObserver( serverDisplay, source ) end ) addEventHandler( "onPlayerJoin", root, function() serverDisplay = textCreateDisplay() textDisplayAddObserver ( serverDisplay, source ) serverText = textCreateTextItem ( "Downloading client files...", 0.5, 0.5,1,255,255,255,255,1.2,"center","center",200 ) textDisplayAddText ( serverDisplay, serverText ) end ) Client: local checkTransferBoxTimer addEventHandler( "onClientPlayerJoin", root, function() if isTransferBoxActive() then checkTransferBoxTimer = setTimer( c_clientTransferBox, 200, 0, source ) end end ) local joinTimer = setTimer( function() if not isTransferBoxActive() then triggerServerEvent( "removeTextDisplay", localPlayer ) if isTimer(joinTimer) then killTimer(joinTimer) end end end, 200, 5 ) function c_clientTransferBox(player) if not isTransferBoxActive() then triggerServerEvent( "removeTextDisplay", player ) killTimer(checkTransferBoxTimer) end end 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