Jump to content

Area Name in alpha


SpoC^

Recommended Posts

Hello, I'm new here, I'm trying to get the name of the area down after appearing on my screen

want that it to delete after appearing

can someone help me?

my script

  
alpha = 255 
setTimer( function () 
if (dx ) then destroyElement(dx) end 
  
  
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
  
local dx = dxDrawRectangle(sW*70, sH*1355/2, sW*150, sH*35/2, tocolor(0, 0, 0, 100/alpha), false) 
dxDrawBorderedText(playerZoneName,sW*75, sH*1360/2, sW*515/2, sH*30/2,tocolor(255,255,255,alpha - 50),1.0,"default-bold","left","top",false,false,false) 
alpha = alpha - 50 
end,3,5000) 
  

My second attempt 

  
function show(type) 
     
    a = 100 
    aR = 255 
     
    rendered = true 
    addEventHandler("onClientRender", root, NameArea) 
    addEventHandler("onClientRender", root, startAlpha) 
end 
addEvent("output", true) 
addEventHandler('output', root, show) 
  
  
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
  
function NameArea 
dxDrawRectangle(sW*70, sH*1355/2, sW*150, sH*35/2, tocolor(0, 0, 0, a), true) 
dxDrawBorderedText(playerZoneName,sW*75, sH*1360/2, sW*515/2, sH*30/2,tocolor(255,255,255,aR),1.0,"default-bold","left","top",false,false,false) 
end 
  
function startAlpha() 
    if aR > 0 then 
        aR = aR - 1 
    end 
    if a > 0 then 
        a = a - 1 
    end 
    if a == 0 then 
        removeEventHandler("onClientRender", root, NameArea) 
        removeEventHandler("onClientRender", root, startAlpha) 
    end 
end  
  

function original of GTA:SA

imagem.PNG

Link to comment
local alpha = 150 
setTimer( function () 
if (dx ) then destroyElement(dx) end 
  
  
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
  
local dx = dxDrawRectangle(sW*70, sH*1355/2, sW*150, sH*35/2, tocolor(0, 0, 0, alpha), false) 
dxDrawBorderedText(playerZoneName,sW*75, sH*1360/2, sW*515/2, sH*30/2,tocolor(255,255,255,alpha),1.0,"default-bold","left","top",false,false,false) 
  
alpha = alpha + 1 
if ( alpha >= 254 ) then 
      alpha = 0 
end 
end,10000,0) 

Link to comment

area-name.gif

my script no function

  
local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) 
local playerZoneName =  getZoneName( playerX, playerY, playerZ ) 
  
  
dxDrawRectangle(sW*70, sH*1355/2, sW*150, sH*35/2, tocolor(0, 0, 0, 100), false) 
dxDrawBorderedText(playerZoneName,sW*75, sH*1360/2, sW*515/2, sH*30/2,tocolor(255,255,255,255),1.0,"default-bold","left","top",false,false,false) 
  

Link to comment

@Woovie is right, you're impolite. being rude won't get you answers, if you can't solve your own problem, don't be rude to others to solve it for you.

Anyhow, there is no event to be triggered when player changes zones, I believe you should add a timer, to trigger addEventHandler ("onClientRender",root,drawDXElements) and setTimer to removeEventHandler

I won't write the code for you, if you have any coding experience you'll know how to write this "simple" code.

Hope it works for you.

Link to comment

Wrote this code as an example whilst on my laptop, so don't expect miracles. This was thrown together in ~15 minutes, so no, it doesn't look good. But the purpose of it is for it to work as an example to you.

I decided to use timers for this example, but it's possible to do it with less timers(Timers really aren't as bad as some people on these forums claim them to be). There's probably a few resources like these up on the community, I'd suggest you check those out.

local sW, sH = guiGetScreenSize(); 
local lastZone = nil; 
local currentZone = ""; 
local fadingAlpha = 255;                                -- Set this to the value where you want it to start fading from. 
local fadingAlphaFrom = fadingAlpha; 
local fadingDuration = 4000;                            -- Set this for how long you want it to go from fully visible to not visible (255 -> 0). Milliseconds. 
local fadingInterval = 50;                              -- Set this for how often it should detract the increments. 50 ms minimum. Less = Smoother 
local timesToRun = (fadingDuration/fadingInterval);     -- This is just to make the code below somewhat auto, so you don't have to change values everywhere. 
local fadeIncremental = (fadingAlphaFrom/timesToRun);   -- This is just to make the code below somewhat auto, so you don't have to change values everywhere. 
  
function startCheckZoneTimer_Handler() 
    setTimer(function() 
        if(isPedDead(localPlayer) ~= true) then 
            local pX, pY, pZ = getElementPosition(localPlayer) 
            currentZone = getZoneName(pX, pY, pZ) 
                if(currentZone ~= lastZone) then 
                removeEventHandler("onClientRender", root, theStuffToDraw_Handler) 
                addEventHandler("onClientRender", root, theStuffToDraw_Handler) 
                fadingAlpha_Handler() 
                lastZone = currentZone 
                setTimer(function() 
                    removeEventHandler("onClientRender", root, theStuffToDraw_Handler) 
                     
                end, fadingDuration, 1); 
            end 
        end 
    end, 250, 0); 
end 
addEventHandler("onClientResourceStart", resourceRoot, startCheckZoneTimer_Handler); 
  
function theStuffToDraw_Handler() 
        dxDrawRectangle((10/1366)*sW, (715/768)*sH, (301/1366)*sW, (43/768)*sH, tocolor(0, 0, 0, fadingAlpha), true) 
        dxDrawText(currentZone, (38/1366)*sW, (720/768)*sH, (321/1366)*sW, (748/768)*sH, tocolor(255, 255, 255, fadingAlpha), 1.00, "pricedown", "left", "top", false, false, true, false, false) 
end 
  
function fadingAlpha_Handler() 
    fadingAlpha = 255; 
    setTimer(function() 
        fadingAlpha = fadingAlpha-fadeIncremental 
    end, fadingInterval, timesToRun); 
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...