Jump to content

Problem with isTransferBoxActive...


Recommended Posts

Posted

I am making my ping kicker, but I have a problem with isTransferBoxActive()

When the map is downloading, isTransferBoxActive returns false, making it to kick the player.

But when it's downloading a map resource (txd, music, etc) isTransferBoxActive returns the right value, true.

Is this a bug?

Thanks

Posted

Maps aren't downloaded per-se, they're loaded as elements and those elements are synced with clients. So, yes, that's to be expected.

Posted

While the map is "downloading", the element count should be increasing. Try something like this

  
mapDownloading = true 
totalElements = 0 
  
function checkElementCount() 
    local tempCount = 0 
    for i,elem in ipairs(getElementsByType("object")) do 
        tempCount = tempCount + 1 
    end 
    if tempCount > totalElements then 
        totalElements = tempCount 
        setTimer(checkElementCount,1000,1) 
    else 
        mapDownloading = false 
    end 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),checkElementCount) 
  
function isMapDownloading() 
    return mapDownloading 
end 
  

Posted

Bear in mind that functions like getElementsByType aren't exactly cheap, so be careful how often you run it.

Posted

I bet you're doing it for race, so use ScreenFadedIn and FadeOut (consult wiki for those) (race-) events to detect whether a map is loading or not. When screen is faded in, a map has been fully loaded.

Using Nextreme's suggestion with 1000+ objects map is just not reasonable.

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