Jump to content

onClientClick not detecting a dead pedestrian


myonlake

Recommended Posts

Posted (edited)

Hello,

So, I am trying to make a GUI that pops open when a player clicks a dead pedestrian (which is a character killed player), but it seems my debug outputs say it's not an element, how come?

local screenx, screeny = guiGetScreenSize() 
  
addEventHandler("onClientClick", root, 
    function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) 
        if button == "left" and state == "up" then 
            if clickedElement then 
                if getElementType(clickedElement) == "ped" then 
                    local ped = clickedElement 
                    if getElementData(ped, "ck.ped") then 
                        for i,v in ipairs(getElementsByType("p")) do 
                            if getElementData(v, "id") == getElementData(ped, "ck.ped") then 
                                ck_window = guiCreateWindow((screenx - 773) / 2, (screeny - 393) / 2, 361, 218, "Body", false) 
                                guiWindowSetSizable(ck_window, false) 
                                ck_memo = guiCreateMemo(16, 32, 329, 139, "Works.", false, ck_window) 
                                guiMemoSetReadOnly(ck_memo, true) 
                                ck_close = guiCreateButton(16, 178, 331, 25, "Close Window", false, ck_window) 
                                guiSetInputEnabled(true) 
                                showCursor(true) 
                                addEventHandler("onClientGUIClick", ck_close, ckCloseWindow, false) 
                                break 
                            end 
                        end 
                        outputChatBox("Works.") 
                    else 
                        outputChatBox("Not a CK.") 
                    end 
                else 
                    outputChatBox("Not a ped.") 
                end 
            else 
                outputChatBox("Not an element.") 
            end 
        end 
    end 
) 
  
function ckCloseWindow() 
    destroyElement(ck_window) 
    guiSetInputEnabled(false) 
    showCursor(false) 
end 
 
Edited by myonlake
Posted

I think when a ped dies, their not an element anymore, because they're dead...

plus gta automatically removes it from the game or the world so, MTA needs to remove it as an element.

Posted

He can try attaching setElementData to the ped before he dies, like on resource start or player join...

then get the element data here.

Posted

Simply create a ped with dead-animation on this place... it will sure work with client click and this stuff... try to find a way to work arround your problem(:

  • 2 months later...

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