ikzelf Posted May 13, 2012 Share Posted May 13, 2012 Hey, i tryed to get the Right Position 100 Meters Infront of mine Helicopter, but it doesnt get the right position wenn mine Heli is at 45 degrees i tryed this but it only get the right X, Y and not the Z setTimer( function () local x, y, z = getElementPosition(veh) local rx, ry, rz = getElementRotation(veh) local x = x+100*math.cos(math.rad(rz+90)) local y = y+100*math.sin(math.rad(rz+90)) setPedAimTarget ( ped, x, y, z ) end , 50, 0) anyone got a trick for it? -ikzelf Link to comment
Jaysds1 Posted May 13, 2012 Share Posted May 13, 2012 Sorry, I'm looking at this and I don't see veh defined anywhere... Do you have another piece to the script? Link to comment
ikzelf Posted May 13, 2012 Author Share Posted May 13, 2012 ye i will post the whole script didnt though it was needed client: addEvent("setFiring", true) addEventHandler("setFiring", getRootElement(), function (ped, veh) if ped then setTimer( function () local x, y, z = getElementPosition(veh) local rx, ry, rz = getElementRotation(veh) local x = x+100*math.cos(math.rad(rz+90)) local y = y+100*math.sin(math.rad(rz+90)) setPedAimTarget ( ped, x, y, z ) end , 50, 0) setPedControlState ( ped, "fire", true ) end end ) server: rain = createVehicle(563, 0, 0, 3, 0, 0, 45) ped1 = createPed(28, 0, 0, 10) attachElements(ped1, rain, 0, 5, 0) setTimer( function () if ped1 then giveWeapon ( ped1, 38, 5009, true) end end , 1000, 1) setTimer( function () if ped1 then local rx, ry, rz = getElementRotation(rain) setElementRotation(ped1, rx, ry, rz) end end , 50, 0) function setFire(play) triggerClientEvent("setFiring", play, ped1, getPedOccupiedVehicle(play)) end addCommandHandler("fire", setFire) Link to comment
Jaysds1 Posted May 13, 2012 Share Posted May 13, 2012 try this: Server rain = createVehicle(563, 0, 0, 3, 0, 0, 45) ped1 = createPed(28, 0, 0, 10) attachElements(ped1, rain, 0, 5, 0) setTimer( function () if ped1 then giveWeapon ( ped1, 38, 5009, true) end end , 1000, 1) setTimer( function() if ped1 then local rx, ry, rz = getElementRotation(rain) setElementRotation(ped1, rx, ry, rz) end end , 50, 0) function setFire(play) local veh = getPedOccupiedVehicle(play) triggerClientEvent(play"setFiring",root, ped1, veh) end addCommandHandler("fire", setFire) Client: addEvent("setFiring", true) addEventHandler("setFiring",root, function(ped, veh) if ped then setTimer( function() local x, y, z = getElementPosition(veh) local rx, ry, rz = getElementRotation(veh) local x = x+100*math.cos(math.rad(rz+90)) local y = y+100*math.sin(math.rad(rz+90)) setPedAimTarget ( ped, x, y, z ) end , 50, 0) setPedControlState ( ped, "fire", true ) end end ) Link to comment
ikzelf Posted May 13, 2012 Author Share Posted May 13, 2012 the Problem isn't that it doesnt fire, it does fire but it doesn't get the Right X, Y, Z position Infront of the Heli Link to comment
arezu Posted May 13, 2012 Share Posted May 13, 2012 you dont have to concentrate on the math if you just use: getElementMatrix(element) Link to comment
ikzelf Posted May 13, 2012 Author Share Posted May 13, 2012 you dont have to concentrate on the math if you just use: getElementMatrix(element) Going to try that Thank's for the quick respond edit: Works fine thanks 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