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

s.epicrow.com:22003.png

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

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

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 : )

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

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.

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

  • Recently Browsing   0 members

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