Jump to content

Create text while resource downloading


undefined

Recommended Posts

I'm use these code for create text while resource downloading. But sometime text not remove. What is the problem?

Client

local gMe = getLocalPlayer() 
downloadTimer = setTimer(function() 
    if not isTransferBoxActive() then 
        if not getElementData(gMe, "loggedin") then 
            triggerServerEvent("onClientDownloadFinish", gMe) 
            outputChatBox("test") -- It is showing. 
            fadeCamera(true) 
            showChat(false) 
            showPlayerHudComponent("radar",false) 
        end 
        if isTimer(downloadTimer) then killTimer(downloadTimer) end 
    end 
end, 50, 0) 

Server

local DownloadDisplay, textItem 
addEventHandler("onResourceStart", root, function() 
    DownloadDisplay = textCreateDisplay() 
    textItem = textCreateTextItem ("Kaynak indiriliyor...\n(Resource is downloading)\n\nTundra Gaming\nv1.0.0", 0.5, 0.4, "high", 255, 255, 255, 255, 2.5, "center", "center", 0) 
    textDisplayAddText(DownloadDisplay, textItem) 
end) 
  
addEventHandler("onPlayerJoin", root, function() 
    textDisplayAddObserver(DownloadDisplay, source) 
end) 
  
addEvent("onClientDownloadFinish", true) 
addEventHandler("onClientDownloadFinish", root, function() 
    if textDisplayIsObserver(DownloadDisplay, source) then 
        textDisplayRemoveObserver(DownloadDisplay, source) 
    end 
end) 

5djdal.png

Edited by Guest
Link to comment

Actually, under onClientDownloadFinish you are, for some reason, using 'player' as if there was any argument expected to arrive - whilst you do not send/specify any when triggering (line 5, uniquely specifying gMe as the event's source). So I guess you instead wanted to use 'client', respective element reference to the player that triggered the event.

Also note that there may be a short timespan between which the 'transferring box' is hidden and then shown up again, same span that might cause your timer to trigger the event that hides your custom messages. So basically, I would recommend you to increase your timer's interval up to 2000ms as specified in the example here.

function onClientDownloadFinish() 
    if textDisplayIsObserver(DownloadDisplay, client) then 
        textDisplayRemoveObserver(DownloadDisplay, client) 
    end 
end 

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