Jump to content

onClientClick not detecting a dead pedestrian


myonlake

Recommended Posts

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
Link to comment
  • 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...