Jump to content

Message while downloading


kuba90pl

Recommended Posts

Posted

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?

Posted
  
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 ]

State: Inactive

Posted

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) 

State: Inactive

Posted

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

" Keep Thinking Different . " - Steve Jops

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

Don't send me PMs asking for help, I Won't reply !

Posted (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 by Guest

State: Inactive

Posted

You are using triggerServerEvent in the server file + Mr.Pres[T]ege's way is much easier and better ..

" Keep Thinking Different . " - Steve Jops

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

Don't send me PMs asking for help, I Won't reply !

Posted

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 
  

Please do not PM me with scripting related question nor support, use the forums instead.

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