Jump to content

carfade issue


meh

Recommended Posts

hi, today's resouce that i want to talk about is carfade (https://community.multitheftauto.com/index.php?p= ... ls&id=3668). basically, what i want it to do is to hide other players cars completely. and to do so, you just need to set min alpha to 0 as far as i know. sounds simple? it sure does. BUT, unfortunately everything is a bit more complecated. even though it's possible to hide other players cars, their nicknames are still visible! so, i'm looking for an advice how to hide players nicknames as well. please halp. :) here's the script's code:

local MAX_DIST  = 30 
local MIN_DIST  = 5 
local MIN_ALPHA = 50 
local carfade = true 
  
addEventHandler("onClientRender", getRootElement(), 
function() 
    local camTarget = getCameraTarget() 
    local tarVehicle = false 
    if(camTarget == false)then return end 
    if(getElementType(camTarget) == "vehicle")then 
        tarVehicle = camTarget 
    elseif(getElementType(camTarget) == "player")then 
        tarVehicle = getPedOccupiedVehicle(camTarget) 
    end 
     
    if (camTarget == false or tarVehicle == false)then return end 
    local posX, posY, posZ = getElementPosition(tarVehicle) 
    local camX, camY, camZ = getCameraMatrix() 
    local player = getElementsByType("player") 
    for i = 1, #player do 
        local vehicle = getPedOccupiedVehicle(player[i]) 
        if(vehicle ~= tarVehicle and vehicle ~= false)then 
            local alpha = 255 
            local x, y, z = getElementPosition(vehicle) 
            local playerDist = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z) 
            local camDist = getDistanceBetweenPoints3D(camX, camY, camZ, x, y, z) 
            -- If distance is more or less than maximum and minimum values, then set alpha to minimum alpha. 
            if(playerDist <= MIN_DIST or camDist <= MIN_DIST)then 
                alpha = MIN_ALPHA 
            end 
            local alpha_dist = (playerDist/MAX_DIST) 
            if(alpha_dist >= 0)then 
                alpha = alpha_dist * 255 
                if(alpha > 255)then alpha = 255 end 
                if(alpha < MIN_ALPHA)then alpha = MIN_ALPHA end 
            end 
            if(carfade == false)then alpha = 255 end 
            local state = getElementData(player[i], "state") or false 
            if(state == "dead" or state == "not ready")then 
                alpha = 0 
            end 
            setElementAlpha(vehicle, alpha) 
            setElementAlpha(player[i], alpha) 
        end 
        if(vehicle == tarVehicle and vehicle ~= false)then 
            setElementAlpha(vehicle, 255) 
            setElementAlpha(player[i], 255) 
        end 
    end 
end) 
  
bindKey("F4", "up", 
function() 
    carfade = (not carfade) 
    if(carfade)then 
        outputChatBox("#FFFFFF[ENABLE]#FF5500Carfade is now #00FF00enabled#FF5500!", 255, 128, 0, true) 
    else 
        outputChatBox("#FFFFFF[DISABLE]#FF5500Carfade is now #FF0000disabled#FF5500!", 255, 128, 0, true) 
    end 
end) 

Link to comment

hm, this doesn't seem to work. any idead why?

local MAX_DIST  = 0 
local MIN_DIST  = 0 
local MIN_ALPHA = 0 
local carfade = true 
  
addEventHandler("onClientRender", getRootElement(), 
function() 
    local camTarget = getCameraTarget() 
    local tarVehicle = false 
    if(camTarget == false)then return end 
    if(getElementType(camTarget) == "vehicle")then 
        tarVehicle = camTarget 
    elseif(getElementType(camTarget) == "player")then 
        tarVehicle = getPedOccupiedVehicle(camTarget) 
    end 
     
    if (camTarget == false or tarVehicle == false)then return end 
    local posX, posY, posZ = getElementPosition(tarVehicle) 
    local camX, camY, camZ = getCameraMatrix() 
    local player = getElementsByType("player") 
    for i = 1, #player do 
        local vehicle = getPedOccupiedVehicle(player[i]) 
        if(vehicle ~= tarVehicle and vehicle ~= false)then 
            local alpha = 255 
            local x, y, z = getElementPosition(vehicle) 
            local playerDist = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z) 
            local camDist = getDistanceBetweenPoints3D(camX, camY, camZ, x, y, z) 
            -- If distance is more or less than maximum and minimum values, then set alpha to minimum alpha. 
            if(playerDist <= MIN_DIST or camDist <= MIN_DIST)then 
                alpha = MIN_ALPHA 
            end 
            local alpha_dist = (playerDist/MAX_DIST) 
            if(alpha_dist >= 0)then 
                alpha = alpha_dist * 255 
                if(alpha > 255)then alpha = 255 end 
                if(alpha < MIN_ALPHA)then alpha = MIN_ALPHA end 
            end 
            if(carfade == false)then alpha = 255 end 
            local state = getElementData(player[i], "state") or false 
            if(state == "dead" or state == "not ready")then 
                alpha = 0 
            end 
            setElementAlpha(vehicle, alpha) 
            setElementAlpha(player[i], alpha) 
                        setPlayerNametagShowing ( player, false ) 
        end 
        if(vehicle == tarVehicle and vehicle ~= false)then 
            setElementAlpha(vehicle, 255) 
            setElementAlpha(player[i], 255) 
                        setPlayerNametagShowing ( player, true ) 
        end 
    end 
end) 
  
bindKey("o", "up", 
function() 
    carfade = (not carfade) 
    if(carfade)then 
        outputChatBox("#FFFFFF[ENABLE]#FF5500Carfade is now #00FF00enabled#FF5500!", 255, 128, 0, true) 
    else 
        outputChatBox("#FFFFFF[DISABLE]#FF5500Carfade is now #FF0000disabled#FF5500!", 255, 128, 0, true) 
    end 
end) 

Link to comment
Guest Guest4401

Do you use default nametags or race's nametags? I think you use the race's nametags. ( That's why setPlayerNametagShowing does nothing ). You should find race's nametag-functions at : race/nametags.lua

Link to comment

found it! so, what do i do? i gotta link this resource with carfade or what?

nametag = {} 
local nametags = {} 
local g_screenX,g_screenY = guiGetScreenSize() 
local bHideNametags = false 
  
local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions 
local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out 
local NAMETAG_DISTANCE = 120 --Distance until we're gone 
local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag 
--The following arent actual pixel measurements, they're just proportional constraints 
local NAMETAG_TEXT_BAR_SPACE = 2 
local NAMETAG_WIDTH = 50 
local NAMETAG_HEIGHT = 5 
local NAMETAG_TEXTSIZE = 0.7 
local NAMETAG_OUTLINE_THICKNESS = 1.2 
-- 
local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE 
NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY  
  
-- Ensure the name tag doesn't get too big 
local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } 
-- Ensure the text doesn't get too small/unreadable 
local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } 
-- Make the text a bit brighter and fade more gradually 
local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } 
  
function nametag.create ( player ) 
    nametags[player] = true 
end 
  
function nametag.destroy ( player ) 
    nametags[player] = nil 
end 
  
addEventHandler ( "onClientRender", g_Root, 
    function() 
        -- Hideous quick fix -- 
        for i,player in ipairs(g_Players) do 
            if player ~= g_Me then 
                setPlayerNametagShowing ( player, false ) 
                if not nametags[player] then 
                    nametag.create ( player ) 
                end 
            end 
        end 
        if bHideNametags then 
            return 
        end 
        local x,y,z = getCameraMatrix() 
        for player in pairs(nametags) do  
            while true do 
                if not isPedInVehicle(player) or isPlayerDead(player) then break end 
                local vehicle = getPedOccupiedVehicle(player) 
                local px,py,pz = getElementPosition ( vehicle ) 
                local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) 
                if pdistance <= NAMETAG_DISTANCE then 
                    --Get screenposition 
                    local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) 
                    if not sx or not sy then break end 
                    --Calculate our components 
                    local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) 
                    local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) 
                    alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) 
                    scale = math.evalCurve(maxScaleCurve,scale) 
                    local textscale = math.evalCurve(textScaleCurve,scale) 
                    local textalpha = math.evalCurve(textAlphaCurve,alpha) 
                    local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) 
                    --Draw our text 
                    local r,g,b = 255,255,255 
                    local team = getPlayerTeam(player) 
                    if team then 
                        r,g,b = getTeamColor(team) 
                    end 
                    local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 
                    dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) 
                    --We draw three parts to make the healthbar.  First the outline/background 
                    local drawX = sx - NAMETAG_WIDTH*scale/2 
                    drawY = sy + offset 
                    local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale 
                    dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) 
                    --Next the inner background  
                    local health = getElementHealth(vehicle) 
                    health = math.max(health - 250, 0)/750 
                    local p = -510*(health^2) 
                    local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
                    dxDrawRectangle (   drawX + outlineThickness,  
                                        drawY + outlineThickness,  
                                        width - outlineThickness*2,  
                                        height - outlineThickness*2,  
                                        tocolor(r,g,0,0.4*alpha)  
                                    ) 
                    --Finally, the actual health 
                    dxDrawRectangle (   drawX + outlineThickness,  
                                        drawY + outlineThickness,  
                                        health*(width - outlineThickness*2),  
                                        height - outlineThickness*2,  
                                        tocolor(r,g,0,alpha)  
                                    )            
                end 
                break 
            end 
        end 
    end 
) 
  
  
---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- 
addEventHandler('onClientResourceStart', g_ResRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            if player ~= g_Me then 
                nametag.create ( player ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerJoin", g_Root, 
    function() 
        if source == g_Me then return end 
        setPlayerNametagShowing ( source, false ) 
        nametag.create ( source ) 
    end 
) 
  
addEventHandler ( "onClientPlayerQuit", g_Root, 
    function() 
        nametag.destroy ( source ) 
    end 
) 
  
  
addEvent ( "onClientScreenFadedOut", true ) 
addEventHandler ( "onClientScreenFadedOut", g_Root, 
    function() 
        bHideNametags = true 
    end 
) 
  
addEvent ( "onClientScreenFadedIn", true ) 
addEventHandler ( "onClientScreenFadedIn", g_Root, 
    function() 
        bHideNametags = false 
    end 
) 
  

Link to comment

Syntax:

--bool setPlayerNametagShowing ( player thePlayer, bool showing ) 
  
    --[[bool | 
'bool' just means that the function returns true or false. 
  
         --player | 
your player argument, in your case: it's 'player' 
check line 20:   local player = getElementsByType("player") 
  
       -- showing | 
it's either 'true' or 'false', false will hide, true will show 
  
  
-- now jump to line 48:             setElementAlpha(player[i], 255) (( This is how you use your player argument )) 
  
  

idk why lua tags wont work for me..

anyhow,

check these:

addEventHandler ( "onClientPlayerJoin", g_Root, 
    function() 
        if source == g_Me then return end 
        setPlayerNametagShowing ( source, false ) 
        nametag.create ( source ) 
    end 
) 
  
addEventHandler ( "onClientPlayerQuit", g_Root, 
    function() 
        nametag.destroy ( source ) 
    end 
) 
  
addEvent ( "onClientScreenFadedOut", true ) 
addEventHandler ( "onClientScreenFadedOut", g_Root, 
    function() 
        bHideNametags = true 
    end 
) 
  
addEvent ( "onClientScreenFadedIn", true ) 
addEventHandler ( "onClientScreenFadedIn", g_Root, 
    function() 
        bHideNametags = false 
    end 
) 
  

edit: re-added the comment, then lua tags would work, so strange..

Link to comment

Well, you can use getElementAlpha. Like:

  
nametag = {} 
local nametags = {} 
local g_screenX,g_screenY = guiGetScreenSize() 
local bHideNametags = false 
  
local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions 
local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out 
local NAMETAG_DISTANCE = 120 --Distance until we're gone 
local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag 
--The following arent actual pixel measurements, they're just proportional constraints 
local NAMETAG_TEXT_BAR_SPACE = 2 
local NAMETAG_WIDTH = 50 
local NAMETAG_HEIGHT = 5 
local NAMETAG_TEXTSIZE = 0.7 
local NAMETAG_OUTLINE_THICKNESS = 1.2 
-- 
local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE 
NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY 
  
-- Ensure the name tag doesn't get too big 
local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } 
-- Ensure the text doesn't get too small/unreadable 
local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } 
-- Make the text a bit brighter and fade more gradually 
local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } 
  
function nametag.create ( player ) 
    nametags[player] = true 
end 
  
function nametag.destroy ( player ) 
    nametags[player] = nil 
end 
  
addEventHandler ( "onClientRender", g_Root, 
    function() 
        -- Hideous quick fix -- 
        for i,player in ipairs(g_Players) do 
            if player ~= g_Me then 
                setPlayerNametagShowing ( player, false ) 
                if not nametags[player] then 
                    nametag.create ( player ) 
                end 
            end 
        end 
        if bHideNametags then 
            return 
        end 
        local x,y,z = getCameraMatrix() 
        for player in pairs(nametags) do 
            while true do 
                if not isPedInVehicle(player) or isPlayerDead(player) then break end 
                local vehicle = getPedOccupiedVehicle(player) 
                local px,py,pz = getElementPosition ( vehicle ) 
                local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) 
                if pdistance <= NAMETAG_DISTANCE then 
                    --Get screenposition 
                    local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) 
                    if not sx or not sy then break end 
                    --Calculate our components 
                    local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) 
                    local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) 
                    alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) 
                    scale = math.evalCurve(maxScaleCurve,scale) 
                    local textscale = math.evalCurve(textScaleCurve,scale) 
                    local textalpha = math.evalCurve(textAlphaCurve,alpha) 
                    local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) 
                    --Draw our text 
                    local r,g,b = 255,255,255 
                    local team = getPlayerTeam(player) 
                    if team then 
                        r,g,b = getTeamColor(team) 
                    end 
                    local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 
                    dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,getElementAlpha(player) or textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) 
                    --We draw three parts to make the healthbar.  First the outline/background 
                    local drawX = sx - NAMETAG_WIDTH*scale/2 
                    drawY = sy + offset 
                    local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale 
                    dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,getElementAlpha(player) or alpha) ) 
                    --Next the inner background 
                    local health = getElementHealth(vehicle) 
                    health = math.max(health - 250, 0)/750 
                    local p = -510*(health^2) 
                    local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
                    dxDrawRectangle (   drawX + outlineThickness, 
                                        drawY + outlineThickness, 
                                        width - outlineThickness*2, 
                                        height - outlineThickness*2, 
                                        tocolor(r,g,0,0.4*getElementAlpha(player) or 0.4*alpha) 
                                    ) 
                    --Finally, the actual health 
                    dxDrawRectangle (   drawX + outlineThickness, 
                                        drawY + outlineThickness, 
                                        health*(width - outlineThickness*2), 
                                        height - outlineThickness*2, 
                                        tocolor(r,g,0,getElementAlpha(player) or alpha) 
                                    )           
                end 
                break 
            end 
        end 
    end 
) 
  
  
---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- 
addEventHandler('onClientResourceStart', g_ResRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            if player ~= g_Me then 
                nametag.create ( player ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerJoin", g_Root, 
    function() 
        if source == g_Me then return end 
        setPlayerNametagShowing ( source, false ) 
        nametag.create ( source ) 
    end 
) 
  
addEventHandler ( "onClientPlayerQuit", g_Root, 
    function() 
        nametag.destroy ( source ) 
    end 
) 
  
  
addEvent ( "onClientScreenFadedOut", true ) 
addEventHandler ( "onClientScreenFadedOut", g_Root, 
    function() 
        bHideNametags = true 
    end 
) 
  
addEvent ( "onClientScreenFadedIn", true ) 
addEventHandler ( "onClientScreenFadedIn", g_Root, 
    function() 
        bHideNametags = false 
    end 
) 
  

Link to comment

lol, forget what has been said, i managed to get rid of nicknames. but still, vehicles headlights and smoke from pipes are still visible. what do i do? current settings of the script:

local MAX_DIST  = 500 
local MIN_DIST  = 0 
local MIN_ALPHA = 0 
local carfade = true 
  
addEventHandler("onClientRender", getRootElement(), 
function() 
    local camTarget = getCameraTarget() 
    local tarVehicle = false 
    if(camTarget == false)then return end 
    if(getElementType(camTarget) == "vehicle")then 
        tarVehicle = camTarget 
    elseif(getElementType(camTarget) == "player")then 
        tarVehicle = getPedOccupiedVehicle(camTarget) 
    end 
     
    if (camTarget == false or tarVehicle == false)then return end 
    local posX, posY, posZ = getElementPosition(tarVehicle) 
    local camX, camY, camZ = getCameraMatrix() 
    local player = getElementsByType("player") 
    for i = 1, #player do 
        local vehicle = getPedOccupiedVehicle(player[i]) 
        if(vehicle ~= tarVehicle and vehicle ~= false)then 
            local alpha = 255 
            local x, y, z = getElementPosition(vehicle) 
            local playerDist = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z) 
            local camDist = getDistanceBetweenPoints3D(camX, camY, camZ, x, y, z) 
            -- If distance is more or less than maximum and minimum values, then set alpha to minimum alpha. 
            if(playerDist <= MIN_DIST or camDist <= MIN_DIST)then 
                alpha = MIN_ALPHA 
            end 
            local alpha_dist = (playerDist/MAX_DIST) 
            if(alpha_dist >= 0)then 
                alpha = alpha_dist * 255 
                if(alpha > 255)then alpha = 0 end 
                if(alpha < MIN_ALPHA)then alpha = MIN_ALPHA end 
            end 
            if(carfade == false)then alpha = 255 end 
            local state = getElementData(player[i], "state") or false 
            if(state == "dead" or state == "not ready")then 
                alpha = 0 
            end 
            setElementAlpha(vehicle, alpha) 
            setElementAlpha(player[i], alpha) 
        end 
        if(vehicle == tarVehicle and vehicle ~= false)then 
            setElementAlpha(vehicle, 255) 
            setElementAlpha(player[i], 255) 
        end 
    end 
end) 
  
bindKey("F1", "up", 
function() 
    carfade = (not carfade) 
    if(carfade)then 
        outputChatBox("#FFFFFF[ENABLE]#FF5500Carfade is now #00FF00enabled#FF5500!", 255, 128, 0, true) 
    else 
        outputChatBox("#FFFFFF[DISABLE]#FF5500Carfade is now #FF0000disabled#FF5500!", 255, 128, 0, true) 
    end 
end) 

Link to comment

If you always want to hide other vehicles completely, then you should not use setElementAlpha because its the same as if the vehicles were there and it would be much better to set them to another dimension then players with bad computers would get the same fps as if they would only play by theirselves.

Then in nametags script in race resource, check player dimension, and if same as player, only then should nametags be drawn.

this is the one i used for my old server (only vehicle hider and carfade, not nametag hider)

local MAX_DIST  = 30 
local MIN_DIST  = 5 
local MIN_ALPHA = 50 
local carfade = false 
  
addEventHandler("onClientRender", getRootElement(), 
function() 
    local camTarget = getCameraTarget() 
    local tarVehicle = false 
    if(camTarget == false)then return end 
    if(getElementType(camTarget) == "vehicle")then 
        tarVehicle = camTarget 
    elseif(getElementType(camTarget) == "player")then 
        tarVehicle = getPedOccupiedVehicle(camTarget) 
    end 
     
    if (camTarget == false or tarVehicle == false)then return end 
    local posX, posY, posZ = getElementPosition(tarVehicle) 
    local camX, camY, camZ = getCameraMatrix() 
    local player = getElementsByType("player") 
    for i = 1, #player do 
        local vehicle = getPedOccupiedVehicle(player[i]) 
        if(vehicle ~= tarVehicle and vehicle ~= false)then 
            local alpha = 255 
            local x, y, z = getElementPosition(vehicle) 
            local playerDist = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z) 
            local camDist = getDistanceBetweenPoints3D(camX, camY, camZ, x, y, z) 
            -- If distance is more or less than maximum and minimum values, then set alpha to minimum alpha. 
            if(playerDist <= MIN_DIST or camDist <= MIN_DIST)then 
                alpha = MIN_ALPHA 
            end 
            local alpha_dist = (playerDist/MAX_DIST) 
            if(alpha_dist >= 0)then 
                alpha = alpha_dist * 255 
                if(alpha > 255)then alpha = 255 end 
                if(alpha < MIN_ALPHA)then alpha = MIN_ALPHA end 
            end 
            if(carfade == false or getElementModel(vehicle) == 425)then 
                --alpha = 255 
                setElementDimension(player[i], getElementDimension(getLocalPlayer())) 
                setElementDimension(vehicle, getElementDimension(getLocalPlayer())) 
                if(getElementModel(vehicle) == 425)then 
                    alpha = 255 
                end 
            else 
                if(player[i] ~= getLocalPlayer())then 
                    if(getElementDimension(player[i]) ~= 5)then 
                        setElementDimension(vehicle, 5) 
                        setElementDimension(player[i], 5) 
                        for k, element in pairs(getAttachedElements(vehicle)) do 
                            if(getElementType(element) == "blip")then 
                                setElementDimension(element, getElementDimension(getLocalPlayer())) 
                            end 
                        end 
                        for k, element in pairs(getAttachedElements(player[i])) do 
                            if(getElementType(element) == "blip")then 
                                setElementDimension(element, getElementDimension(getLocalPlayer())) 
                            end 
                        end 
                    end 
                end 
            end 
            local state = getElementData(player[i], "state") or false 
            if(state == "dead")then 
                alpha = 0 
            end 
            setElementAlpha(vehicle, alpha) 
            setElementAlpha(player[i], alpha) 
            --setElementData(player[i], "carfade.alpha", alpha) 
        end 
        if(vehicle == tarVehicle and vehicle ~= false)then 
            --setElementData(player[i], "carfade.alpha", 255) 
            setElementAlpha(vehicle, 255) 
            setElementAlpha(player[i], 255) 
            setElementDimension(player[i], getElementDimension(getLocalPlayer())) 
            setElementDimension(vehicle, getElementDimension(getLocalPlayer())) 
        end 
    end 
end) 
  
bindKey("F4", "up", 
function() 
    carfade = (not carfade) 
    if(carfade)then 
        outputChatBox("#FFFFFF[ENABLE]#FF5500Vehicles are now #FF0000hidden!", 255, 128, 0, true) 
    else 
        outputChatBox("#FFFFFF[DISABLE]#FF5500Vehicles are now #00FF00visible, carfade has been#00FF00enabled!", 255, 128, 0, true) 
    end 
end) 

Link to comment

problem solved. you rock, arezu. hey, while you sill here, maybe you can tell me how to lower position of that "press space to respawn" inscription in you training script? currently it's almost at the middle of screen and it's kinda uncomfortable for those who just wanna watch the game.

hey, and a big thank you to those who participated in this discussion. your participation is much appreciated. :)

Link to comment

go to line 74 in respawn_c.lua and change:

local x, y = screen_width/2 - textWidth/2, screen_height * 0.75 - fontHeight/2 

to:

local x, y = screen_width/2 - textWidth/2, screen_height * 0.85 - fontHeight/2 

or just experiment with the '0.85'.

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