Jump to content

Element Clicked


roaddog

Recommended Posts

Hello,

I need a little help here, so I was making a script, and I got a problem. the problem is when I clicked the ped, nothing happens.

function elementClicked( theButton, theState, thePlayer ) 
    if theButton == "left" and theState == "down" then 
        if getElementType( source) == "ped" then 
            outputChatBox("Ped clicked", thePlayer) -- doesn't reach this line 
            triggerClientEvent(thePlayer, "onPedClicked", thePlayer) 
        end 
    end 
end 
  
  
addEventHandler("onMarkerHit", getRootElement(), function(hitElement, matchingDimension) 
    if source == thismarker then 
        if not isPedInVehicle(hitElement) then 
            outputChatBox("Click the ped to talk!", hitElement, 200, 200, 0) 
            addEventHandler( "onElementClicked", getRootElement(), elementClicked ) -- I trigger the event here but when I try clicking the ped, nothing happens? 
        else outputChatBox("get out of the vehicle", hitElement, 200,0,0) 
        end 
    end 
end) 

ped = createPed(206, -537.8759765625, -98.71875, 63.296875, -90, 0) -- I created the ped on clientside. 
setElementFrozen(ped, true) 
function cancelPedDamage() 
    cancelEvent() 
end 
addEventHandler("onClientPedDamage", ped, cancelPedDamage) 
  
addEvent("onPedClicked", true) 
addEventHandler("onPedClicked", root, function() 
        windows() 
end) 

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