Jump to content

Zone name wont draw


Recommended Posts

Hello, i have a problem. The zone name won't draw, if i put the code in main hud it screws up.

------------>> 
local screenW, screenH = guiGetScreenSize ( ) 
function renderNewLocation() 
--  if (not isPlayerHudComponentVisible("radar") or isPlayerMapVisible() or not hudEnabled) then return end 
    local x,y,z = getElementPosition(localPlayer) 
    local zone = getZoneName(x, y, z) 
    if (zone == "El Castillo del Diablo") then zone = "Ghost Town" end 
     
    if (cur_zone == zone) then return end 
     
    cur_zone = zone 
       dxDrawShadowText(zone, screenW*(280/1980), 30, screenW*(280/1980), 30, tocolor(254, 254, 254, 255), scale,"bankgothic", "center", "top", false, false, true, true, false) 
    outputChatBox(zone)    
end 
addEventHandler("onClientRender",root,renderNewLocation) 

Link to comment

Try this

------------>> 
local screenW, screenH = guiGetScreenSize ( ) 
function renderNewLocation() 
    local x,y,z = getElementPosition(localPlayer) 
    local zone = getZoneName(x, y, z) 
    if (zone == "El Castillo del Diablo") then  
        zone = "Ghost Town"  
    end 
    dxDrawText(zone, screenW*(280/1980), 30, screenW*(280/1980), 30, tocolor(254, 254, 254, 255), scale,"bankgothic", "center", "top", false, false, true, true, false)  
end 
addEventHandler("onClientRender",root,renderNewLocation) 

Link to comment

I've made a script for events, it works but the text suddenly disappears. Here is the code.

Client

function output (text,name) 
 dxDrawText(""..text.."[Hosted by "..name.."", 4, 5, 296, 20, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
end 
addEvent("sendText", true) 
addEventHandler("sendText", getRootElement(), output) 

Server

  
nametags_Players = getElementsByType('player') 
function events(thePlayer,_, ...) 
if exports.staff:isPlayerStaff(thePlayer) then 
for i,allPlayers in ipairs(nametags_Players) do 
local message = table.concat({...}, ' ') 
local name = getPlayerName(thePlayer) 
triggerClientEvent(allPlayers, "sendText", getRootElement(), message,name) end 
end 
end 
addCommandHandler("event",events) 

Link to comment

Untested (i'm using the phone)

*Client side

-- output event stuff 
function output (text,name) 
    text = text 
    name = name 
    addEventHandler ( "onClientRender", getRootElement(), drawEvent) 
    setTimer(removeEventDraw,10000,1) 
end 
addEvent("sendText", true) 
addEventHandler("sendText", getRootElement(), output) 
  
-- remove draw event after 10 seconds 
function removeEventDraw () 
    removeEventHandler ( "onClientRender", getRootElement(), drawEvent ) 
end 
  
-- draw event message 
local screenW, screenH = guiGetScreenSize ( ) 
function drawEvent() 
    dxDrawText(text.."[Hosted by "..name.."]", screenW*(280/1980), 30, screenW*(280/1980), 30, tocolor(254, 254, 254, 255), 1,"default", "center", "top", false, false, true, true, false) 
end 

*Server side

function events(thePlayer,_, ...) 
    local nametags_Players = getElementsByType('player') 
    if exports.staff:isPlayerStaff(thePlayer) then 
        for i,allPlayers in ipairs(nametags_Players) do 
            local message = table.concat({...}, ' ') 
            if message and message ~= "" then  
                local name = getPlayerName(thePlayer) 
                triggerClientEvent(allPlayers, "sendText", getRootElement(), message,name)  
            end  
        end 
    end 
end 
addCommandHandler("event",events) 

Link to comment

-- Client side

-- output event stuff 
function output (text,name) 
    if text and name then  
        t , n = text , name 
        addEventHandler ( "onClientRender", getRootElement(), drawEvent) 
        setTimer(removeEventDraw,10000,1) 
    end  
end 
addEvent("sendText", true) 
addEventHandler("sendText", getRootElement(), output) 
  
-- remove draw event after 10 seconds 
function removeEventDraw () 
    removeEventHandler ( "onClientRender", getRootElement(), drawEvent ) 
end 
  
-- draw event message 
local screenW, screenH = guiGetScreenSize ( ) 
function drawEvent() 
    dxDrawText(t.."[Hosted by "..n.."]", screenW*(280/1980), 30, screenW*(280/1980), 30, tocolor(254, 254, 254, 255), 1,"default", "center", "top", false, false, true, true, false) 
end 

--Server side:

function events(thePlayer,_, ...) 
    local nametags_Players = getElementsByType('player') 
    if exports.staff:isPlayerStaff(thePlayer) then 
        for i,allPlayers in ipairs(nametags_Players) do 
            local message = table.concat({...}, ' ') 
            if message and message ~= "" then 
                local name = getPlayerName(thePlayer) 
                triggerClientEvent(allPlayers, "sendText", getRootElement(), message,name) 
            end 
        end 
    end 
end 
addCommandHandler("event",events) 

Link to comment

I want to toggle the control false if the data is true but it wont work...

  
g_ArmedVehicles = { 
    [425] = true, 
    [447] = true, 
    [520] = true, 
    [430] = false, 
    [464] = false, 
    [432] = true 
} 
  
function checkNoDMGreen () 
if g_ArmedVehicles[getPedOccupiedVehicle(source)] and getElementData(source,"invincible",true) or getElementData(source,"green", true) then 
        toggleControl(player, 'vehicle_fire', false) 
            toggleControl(player, 'vehicle_secondary_fire', false) end 
end 
setTimer(checkNoDMGreen,100,0) 

Link to comment

didn't work because:

source: not defined in your code.

c1921bfcbb.png

player: same thing with player.

d598719729.png

Try to use "onPlayerVehicleEnter" or just get a table of all the vehicles that exist and loop through it.

Example:

local g_ArmedVehicles = {[425] = true,[447] = true,[520] = true,[430] = false,[464] = false,[432] = true} 
  
function checkNoDMGreen() 
    local vehicles = getElementsByType ( "vehicle" ) 
    for _, vehicle in ipairs(vehicles) do 
        if g_ArmedVehicles[getElementModel(vehicle)] then 
            local invicsible = getElementData(vehicle,"invincible")  
            local green = getElementData(vehicle,"green")  
            if invicible or green then 
                local player = getVehicleController (vehicle)  
                if player then  
                    toggleControl(player, 'vehicle_fire', false) 
                    toggleControl(player, 'vehicle_secondary_fire', false)  
                end  
            end  
        end 
    end  
end  
setTimer(checkNoDMGreen,100,0) 

Link to comment
I'm not setting data on vehicle, i'm setting the data on player.

:o check your code as i can see source == vehicle.

c1921bfcbb.png

anyways try this:

local g_ArmedVehicles = {[425] = true,[447] = true,[520] = true,[430] = false,[464] = false,[432] = true} 
  
function checkNoDMGreen() 
    local vehicles = getElementsByType ( "vehicle" ) 
    for _, vehicle in ipairs(vehicles) do 
        if g_ArmedVehicles[getElementModel(vehicle)] then 
                local player = getVehicleController (vehicle) 
                if player then 
                    -- check elementData here then usetoggleControl 
                    toggleControl(player, 'vehicle_fire', false) 
                    toggleControl(player, 'vehicle_secondary_fire', false) 
            end 
        end 
    end 
end 
setTimer(checkNoDMGreen,100,0) 

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