BORAT Posted January 2, 2017 Share Posted January 2, 2017 (edited) Hola lo que pasa es que estoy tratando de hacer un attachEfect a un jugador por medio de un comando y me salta este error al ejecutar el comando,(attempt to index local pov (a userdata value) n se por que pasa ya que tome el ejemplo de la misma wiki este es el codigo. local attachedEffects = {} -- Taken from https://wiki.multitheftauto.com/wiki/GetElementMatrix example function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function attachEffect(effect, element, pos) attachedEffects[effect] = { effect = effect, element = element, pos = pos } addEventHandler("onClientElementDestroy", effect, function() attachedEffects[effect] = nil end) addEventHandler("onClientElementDestroy", element, function() attachedEffects[effect] = nil end) return true end addEventHandler("onClientPreRender", root, function() for fx, info in pairs(attachedEffects) do local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(fx, x, y, z) end end ) function locatePlayer() local pov = getPedOccupiedVehicle( localPlayer ) local fx = createEffect("fire", pov.position) attachEffect(fx, pov, Vector3(0, 0, 2)) end addCommandHandler ( "faier", locatePlayer ) Edited January 2, 2017 by BORAT Link to comment
Rose Posted January 2, 2017 Share Posted January 2, 2017 No he probado esa función pero, ¿no es lo mismo hacer esto? function locatePlayer() local vehicle = getPedOccupiedVehicle( localPlayer ) local px, py, pz = getElementPosition( vehicle ) fx = createEffect("fire", px, py, pz+1) end addCommandHandler ( "faier", locatePlayer ) addEventHandler("onClientPreRender", root, function() if isElement(fx) then local vehicle = getPedOccupiedVehicle( localPlayer ) local px, py, pz = getElementPosition( vehicle ) setElementPosition(fx,px, py, pz+1) end end) De todas formas si alguien sabe arreglar el error que da el attachEffect sería bueno que explicaran bien cual es el error, porque estoy traumado con los error de 'a userdata value' D: Link to comment
#Dv^ Posted January 2, 2017 Share Posted January 2, 2017 (edited) function fire() local vehicle = getPedOccupiedVehicle(localPlayer) local x, y, z = getElementPosition(vehicle) local fx = createEffect("fire", x, y, z) attachEffect(fx, vehicle, Vector3(0, 0, 2)) end addCommandHandler("fire", fire) Podrían arreglar el ejemplo de la Wiki, para que nadie vuelva a tener el mismo problema Edited January 2, 2017 by #Dv^ Link to comment
Recommended Posts