cuervox123 Posted March 4, 2016 Share Posted March 4, 2016 alguna funcion en mta para hacer lo del auto ? Link to comment
Alexs Posted March 5, 2016 Share Posted March 5, 2016 Esto funciona bien en client-side, tal vez sirva para que te des una idea: function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] 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 end local power = 1 local powerUp = 0.5 function throwOutNearVehicles() local x, y, z = getElementPosition(localPlayer) local dx, dy, dz = getPositionFromElementOffset(localPlayer,0,1,0) for _, veh in ipairs(getElementsByType('vehicle'), root, true) do local vx, vy, vz = getElementPosition(veh) if (( (dx - vx)^2 + (dy - vy)^2 + (dz - vz)^2 ) ^ .5) <= 2.5 then local angle = math.atan2(x - vx, y - vy) - math.rad(90) local velX, velY, velZ = getElementVelocity(veh) setElementVelocity(veh, velX + power*-math.cos(angle), velY + power*math.sin(angle), velZ + (powerUp*.1)) end end end addCommandHandler('drop', throwOutNearVehicles ) Link to comment
Recommended Posts