roaddog Posted October 26, 2014 Share Posted October 26, 2014 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
TAPL Posted October 26, 2014 Share Posted October 26, 2014 The event onElementClicked won't trigger for elements created client side because the server does not recognize client side elements. So you have to use onClientClick or create the ped server side. Link to comment
roaddog Posted October 26, 2014 Author Share Posted October 26, 2014 I got it, Thank you Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now