Jump to content

onElementZoneChange


Drakath

Recommended Posts

Posted

Add an event onElementZoneChange. It should trigger when an element enters a different zone. GTA San Andreas has this by default, when you enter a new zone, it outputs the name of the new zone.

Parameters: oldZone, newZone, oldCity, newCity

Posted (edited)

You can do it on the clientside with the event "onClientRender", like this:

  
local areaName = "" 
local currentZone = nil 
addEventHandler( "onClientRender", root, 
    function() 
        local x,y,z = getElementPosition(element) 
        currentZone = getZoneName(x,y,z) 
         
        if (areaName ~= currentZone) then 
             
            areaName = currentZone 
            triggerEvent(...) 
        end 
    end 
) 

And store the current area of the element with setElementData.

Edited by Guest
Posted

I'm not sure if onClientRender should be abused for such things.

In the end, you will get lags. Maybe not in this case, but in general.

Posted
You can do it on the clientside with the event "onClientRender", like this:
  
local areaName = "" 
local currentZone = nil 
addEventHandler( "onClientRender", root, 
    function() 
        if not isPlayerHudComponentVisible("area_name") then 
            local x,y,z = getElementPosition(element) 
            currentZone = getZoneName(x,y,z) 
             
            if (areaName ~= currentZone) then 
                 
                areaName = currentZone 
                triggerEvent(...) 
            end 
        else 
            setPlayerHudComponentVisible("area_name", false) 
        end 
    end 
) 

And store the current area of the element with setElementData.

I don't understand why are you using: isPlayerHudComponentVisible and setPlayerHudComponentVisible.

Posted
You can do it on the clientside with the event "onClientRender", like this:
  
local areaName = "" 
local currentZone = nil 
addEventHandler( "onClientRender", root, 
    function() 
        if not isPlayerHudComponentVisible("area_name") then 
            local x,y,z = getElementPosition(element) 
            currentZone = getZoneName(x,y,z) 
             
            if (areaName ~= currentZone) then 
                 
                areaName = currentZone 
                triggerEvent(...) 
            end 
        else 
            setPlayerHudComponentVisible("area_name", false) 
        end 
    end 
) 

And store the current area of the element with setElementData.

I don't understand why are you using: isPlayerHudComponentVisible and setPlayerHudComponentVisible.

Bingo : )

Posted
You can do it on the clientside with the event "onClientRender", like this:
  
local areaName = "" 
local currentZone = nil 
addEventHandler( "onClientRender", root, 
    function() 
        if not isPlayerHudComponentVisible("area_name") then 
            local x,y,z = getElementPosition(element) 
            currentZone = getZoneName(x,y,z) 
             
            if (areaName ~= currentZone) then 
                 
                areaName = currentZone 
                triggerEvent(...) 
            end 
        else 
            setPlayerHudComponentVisible("area_name", false) 
        end 
    end 
) 

And store the current area of the element with setElementData.

I don't understand why are you using: isPlayerHudComponentVisible and setPlayerHudComponentVisible.

Oh yeah, it's because I got this code from a script 'custom zone name' i made.

By the way, i edited it.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...