Jump to content

HELP PED GUI


stevensalvaro

Recommended Posts

getDistanceBetweenPoints2D 
bindKey 
guiSetVisible 
showCursor 

Wrong,

To make that, you can attach a colshap to ped or create a marker and attach it to the ped and set it invisible.

Then use these functions in below:

createMarker 
dxDrawText 
bindKey 
unbindKey 
showCursor 
--events: 
onMarkerHit 
onMarkerLeave 

Link to comment
getDistanceBetweenPoints2D 
bindKey 
guiSetVisible 
showCursor 

Wrong,

To make that, you can attach a colshap to ped or create a marker and attach it to the ped and set it invisible.

Then use these functions in below:

createMarker 
dxDrawText 
bindKey 
unbindKey 
showCursor 
--events: 
onMarkerHit 
onMarkerLeave 

It isn't wrong, you do this with functions that I have mentioned.

Link to comment

It isn't wrong, you do this with functions that I have mentioned.

I said wrong because

getDistanceBetweenPoints2D 

won't do what he wants,

But yeah this function can works for him only if he wants to create the marker in client side, but logically the job will be used for all players so what I had posted to him would work for him.

Also he'll needs to use

triggerClientEvent / triggerServerEvent 

Link to comment

I developed this function into my lobby script, so I'll share it:

  
local x, y = guiGetScreenSize() 
local npcs = {} 
  
function createNPC(name, modelID, x,y,z, rz) 
    rz = rz or 0 
  
    local pedElement = createPed(modelID, x,y,z, rz) 
    table.insert(npcs, {name = name, ped = pedElement, isClose = false}) 
end 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        dd = createNPC("Destruction Derby", 160, 5282.0478515625, -2192.97265625, 18.072999954224, 180) 
        shooter = createNPC("Shooter", 104, 5281.8583984375, -2210.6875, 18.072999954224, 0) 
        race = createNPC("Race", 30, 5300.0620117188, -2211.4533691406, 18.072999954224, 0) 
        hunter = createNPC("Hunter", 22, 5305.978515625, -2206.55078125, 18.072999954224, 90) 
        dm = createNPC("Deathmatch", 29, 5300.42432, -2192.78345, 18.07300, 180) 
        basketball = createNPC("Soon...", 16, 5305.9091796875, -2197.9853515625, 18.072999954224, 90) 
end) 
  
addEventHandler("onClientRender", root, 
function() 
    local x,y,z = getElementPosition(localPlayer) 
  
    for i, npc in ipairs (npcs) do 
        local nx, ny, nz = getElementPosition(npc.ped) 
        local dist = getDistanceBetweenPoints3D(x, y, z, nx, ny, nz) 
  
    if (dist < 3.5) then 
    local dx, dy = getScreenFromWorldPosition(nx, ny, nz) 
    if (dx) and (dy) then 
        for npcs in ipairs (npcs) do 
        if (npc.name == "Deathmatch") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("Press 'F'", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        elseif (npc.name == "Destruction Derby") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("Press 'F'", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        elseif (npc.name == "Race") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("Press 'F'", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        elseif (npc.name == "Shooter") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("Press 'F'", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        elseif (npc.name == "Hunter") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("Press 'F'", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        elseif (npc.name == "Soon...") then 
            dxDrawText(npc.name, dx, dy, dx, dy, tocolor(100, 210, 255, 255), 2.25, "arial") 
            dxDrawText("This gamemode will be avaible soon!", dx, dy+30, dx, dy, tocolor(255, 255, 255, 255), 2.25, "arial") 
        end 
    end 
  
        npc.isClose = true 
    else 
    npc.isClose = false 
            end 
        end 
    end 
end) 
  
bindKey("f", "down", 
    function() 
        for i, npc in ipairs (npcs) do 
            if (npc.isClose) then 
            -- do what you want here, to check a npc by name use the npc.name or a ped element: npc.ped 
            if (npc.name == "Destruction Derby") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                setElementDimension(localPlayer, 5) 
            elseif (npc.name == "Shooter") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                setElementDimension(localPlayer, 4) 
            elseif (npc.name == "Race") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                setElementDimension(localPlayer, 3) 
            elseif (npc.name == "Hunter") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                setElementDimension(localPlayer, 2) 
            elseif (npc.name == "Deathmatch") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                setElementDimension(localPlayer, 1) 
            elseif (npc.name == "Soon...") then 
                outputChatBox("You pressed 'F' at npc: " .. npc.name) 
                outputChatBox("Soon...") 
            end 
            npc.isClose = false 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerDamage", root, function () cancelEvent() end) 
  
function backToLobby() 
    setElementDimension(localPlayer, 0) 
end 
bindKey("F2", "down", backToLobby) 
  

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