Jump to content

Zone name wont draw


Recommended Posts

Posted

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) 

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Oh gosh, you saved me THANKS

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
Oh gosh, you saved me THANKS

You are welcome.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Found the mess. FIXED

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

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) 

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

It's the same, suddenly disappers

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

It disappears instantly but everything works...

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
It disappears instantly but everything works...

Just remove setTimer function here:

647d9c1c4f.png

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
i8wAKEz.png

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

Fixed it, thanks for help :D

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Helped me a lot thanks :P

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

One more thing, the text length goes straight but i want to go in rows, here's an example. How i want to draw it..

6wNAZOu.png

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

you can use sth like this

-- Example:

local example = "an example string" 
for i in string.gmatch(example, "%S+") do 
  outputChatBox(i) 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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) 

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted

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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Didnt work..

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

Posted
Didnt work..

working fine for me check your elementData.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

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

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

works

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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