Jump to content

MTA:Dayz Onduty Script


Recommended Posts

Posted

Hello all!

I need help, i made by myself Onduty script for MTA:dayz, and i need some help whit it

When i write /aduty it shows me the arrow, but how can i get the TEXT at that Arrow

arrowTable = {}

addCommandHandler("aduty",

function(player)

local duty = getElementData(player, "duty") or 0

if duty == 0 then

if not isElement(arrowTable[player]) then

arrowTable[player] = createMarker(0, 0, 0, "arrow", 0.75, 255, 0, 0, 175)

end

attachElements(arrowTable[player], player, 0, 0, 2)

else

if isElement(arrowTable[player]) then

destroyElement(arrowTable[player])

arrowTable[player] = nil

end

end

end)

addEventHandler("onPlayerQuit", root,

function()

if isElement(arrowTable[player]) then

destroyElement(arrowTable[player])

arrowTable[player] = nil

end

end)

Posted

replace player with source

here

17adeaab26.png

About second question all what you need is

  
triggerClientEvent 
getScreenFromWorldPosition() 
getCameraMatrix() 
getDistanceBetweenPoints3D() 
dxDrawText 
  

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

addEventHandler ( "onClientRender", root,

function ( )

if ( getDistanceBetweenPoints3D ( 0, 0, 3, getElementPosition ( localPlayer ) ) ) < 50 then

local coords = { getScreenFromWorldPosition ( 0, 0, 3 ) }

if coords[1] and coords[2] then

dxDrawText ( "Hello !", coords[1], coords[2], coords[1], coords[2], tocolor(255,255,255), 1, "default-bold" )

end

end

end )

like this?

Posted

not bad

local screenX, screenY = guiGetScreenSize () 
  
function leaderText(marker) 
    local xm,ym,zm = getElementPosition(marker) 
    local x,y = getScreenFromWorldPosition(xm,ym,zm+0.2) 
    local camX,camY,camZ = getCameraMatrix() 
        if (x and y and getDistanceBetweenPoints3D(camX, camY, camZ, xm,ym,zm) <= 20) then 
           dxDrawText ("Hello", x,y,x,y, tocolor (255,0, 0, 255) , ( screenX / 1440 ) * 2 , "default-bold" , "center" , "center" , false , true , false ) 
    end 
end 

Now try to use triggerClientEvent and post your code here and i will help you

Note :use LUA highlight syntax

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

[arrowTable = {}

addCommandHandler("aduty",

function(player)

local duty = getElementData(player, "duty") or 0

if duty == 0 then

if not isElement(arrowTable[player]) then

arrowTable[player] = createMarker(0, 0, 0, "arrow", 0.75, 255, 0, 0, 175)

addEventHandler("onClientRender",createText)

end

attachElements(arrowTable[player], player, 0, 0, 2)

else

if isElement(arrowTable[player]) then

destroyElement(arrowTable[player])

arrowTable[player] = nil

end

end

end)

addEventHandler("onPlayerQuit", root,

function()

if isElement(arrowTable[player]) then

destroyElement(arrowTable[player])

arrowTable[player] = nil

end

end)

local screenX, screenY = guiGetScreenSize ()

function leaderText(marker)

local xm,ym,zm = getElementPosition(marker)

local x,y = getScreenFromWorldPosition(xm,ym,zm+0.2)

local camX,camY,camZ = getCameraMatrix()

if (x and y and getDistanceBetweenPoints3D(camX, camY, camZ, xm,ym,zm) <= 20) then

dxDrawText ("Hello", x,y,x,y, tocolor (255,0, 0, 255) , ( screenX / 1440 ) * 2 , "default-bold" , "center" , "center" , false , true , false )

end

end

function greetingCommand ( playerSource, commandName )

triggerClientEvent ( playerSource, "onGreeting", playerSource, "Hello World!" )

end

addCommandHandler ( "greet", greetingCommand )

how to get LUA highlight syntex ?

Posted

Try to use this untested.

-- Server side

[arrowTable] = {} 
  
addCommandHandler("aduty", 
function(player) 
    if isElement(player) then  
    local duty = getElementData(player, "duty") or 0 
        if duty == 0 then 
            if not isElement(arrowTable[player]) then 
            local x,y,z = getElementPosition(player) 
            arrowTable[player] = createMarker(x,y,z, "arrow", 0.75, 255, 0, 0, 175)  
            attachElements(arrowTable[player], player, 0, 0, 2) 
            triggerClientEvent(player,"ShowText",player,"output",arrowTable[player]) 
        else 
            if isElement(arrowTable[player]) then 
            destroyElement(arrowTable[player]) 
            arrowTable[player] = nil 
            triggerClientEvent(player,"ShowText",player,"remove",arrowTable[player]) 
            end 
        end 
    end  
end  
end) 
  
addEventHandler("onPlayerQuit", root, 
function() 
    if isElement(arrowTable[source]) then 
    destroyElement(arrowTable[source]) 
    arrowTable[source] = nil 
    end 
end) 

-- Client side

local screenX, screenY = guiGetScreenSize () 
  
function leaderText() 
local xm,ym,zm = getElementPosition(marker) 
local x,y = getScreenFromWorldPosition(xm,ym,zm+0.2) 
local camX,camY,camZ = getCameraMatrix() 
    if (x and y and getDistanceBetweenPoints3D(camX, camY, camZ, xm,ym,zm) <= 20) then 
        dxDrawText ("Hello", x,y,x,y, tocolor (255,0, 0, 255) , ( screenX / 1440 ) * 2 , "default-bold" , "center" , "center" , false , true , false ) 
    end 
end 
  
function Text (type,mar) 
    if type == "output" then  
    marker = mar 
    addEventHandler("onClientPreRender",root,leaderText) 
    elseif type == "remove" then  
    removeEventHandler("onClientPreRender",root,leaderText) 
    end  
end  
addEvent("ShowText",true) 
addEventHandler("ShowText",root,Text) 

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

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