ronaldoguedess Posted July 5, 2014 Author Share Posted July 5, 2014 Need some way to fix the crosshair in "PED". anyone has idea? I was unable to "setCameraMatrix" : ( Link to comment
Moderators IIYAMA Posted July 5, 2014 Moderators Share Posted July 5, 2014 FROM VERSION 1.3.1 r5212 ONWARDS bool setCameraTarget ( float targetX, float targetY, float targetZ ) Required Arguments targetX, targetY, targetZ: The target position that you want the local camera to look at. But it won't be the crosshair, it will be the middle of the screen. You should calculate that... Link to comment
ronaldoguedess Posted July 7, 2014 Author Share Posted July 7, 2014 I did it! By the crosshair does not go to the ped ... what calculation should I do? Link to comment
Saml1er Posted July 9, 2014 Share Posted July 9, 2014 If you're using Den's code then all you need is this function: setPedAimTarget local function getPedsOnScreen() local peds = {} for key, ped in ipairs(getElementsByType("ped", root, true)) do if isElementOnScreen(ped) then table.insert(peds, ped) end end return peds end local function dxDrawCircle(posX, posY, radius, width, angleAmount, color, postGUI) radius = radius or 50 width = width or 5 angleAmount = angleAmount or 1 color = color or tocolor(255, 255, 255, 200) postGUI = postGUI or false for i=0,360,angleAmount do local _i = i*(math.pi/180) dxDrawLine(math.cos(_i)*(radius-width)+posX, math.sin(_i)*(radius-width)+posY, math.cos(_i)*(radius+width)+posX, math.sin(_i)*(radius+width)+posY, tocolor(255, 0, 0), width, postGUI) end return true end local function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end local function sortbyrot(a, b) local _, _, rz = getElementRotation(localPlayer) local x, y = getElementPosition(localPlayer) local ax, ay = getElementPosition(a) local bx, by = getElementPosition(b) local arz = findRotation(x, y, ax, ay) arz = math.abs(rz - arz) local brz = findRotation(x, y, bx, by) brz = math.abs(rz - brz) return arz < brz end addEventHandler("onClientRender", root, function() local weapon = getPedWeapon(localPlayer) if weapon and weapon > 0 then local peds = getPedsOnScreen() if #peds > 0 then table.sort(peds, sortbyrot) local chosen = peds[1] local hx, hy, hz = getPedBonePosition(chosen, 6) local sx, sy = getScreenFromWorldPosition(hx, hy, hz) if sx then dxDrawCircle(sx, sy) setPedAimTarget(chosen,hx,hy,hz) --- Now see the magic end end end end) Link to comment
bandi94 Posted July 9, 2014 Share Posted July 9, 2014 how , about create a Ped ( make it invisible ) give him the same wep you have , ammo , etc...... Attach it to you pos ( get your pos , and set the ped's pos ) , rotate your player to the target for visual effect ..... And for shooting use the Ped , after the fire key is released , read the Ped's left ammo , and set your own ammo. Link to comment
MTA Team botder Posted July 9, 2014 MTA Team Share Posted July 9, 2014 Or simply create a custom weapon. Link to comment
Moderators IIYAMA Posted July 9, 2014 Moderators Share Posted July 9, 2014 or wait for the release of my cheat panel which is included auto aim. Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 Or just help this person so she/he can learn. Link to comment
Moderators IIYAMA Posted July 9, 2014 Moderators Share Posted July 9, 2014 Or just help this person so she/he can learn. I did, I gave him a way to do it. But I am not going to teach him old school math, that is something he has to learn from his teachers.... Well if you want go a head and learn it him, be the school teacher. Link to comment
Et-win Posted July 9, 2014 Share Posted July 9, 2014 Or just help this person so she/he can learn. I did, I gave him a way to do it. But I am not going to teach him old school math, that is something he has to learn from his teachers.... Well if you want go a head and learn it him, be the school teacher. Nah, my math sucks, otherwise I would ^^ Link to comment
ronaldoguedess Posted July 10, 2014 Author Share Posted July 10, 2014 or wait for the release of my cheat panel which is included auto aim. At least we know how to create it there! is expected to launch? you used some function beyond the setCameraTarget? setCameraMatrix? I managed to make the player look ped close to the target, the crosshairs will not put to him, is in the middle of the screen! Or just help this person so she/he can learn. Thanks for the help, I'm half bad math too so I am suffering to create it! Link to comment
ronaldoguedess Posted July 10, 2014 Author Share Posted July 10, 2014 I have a big problem! Auto aim only works in some angles, note in the video that I did! local X, Y, Z = getElementPosition(localPlayer); local tx, ty, tz= getElementPosition(Ped); local difx = math.floor(tx - X) --distance (X) m local dify = math.floor(ty - Y) --the lateral distance (Y) in meters local difz = math.floor(tz - Z) --distance height (Z) in meters local difr = math.floor(rz - prz) --difference of rotation (Z) in degrees local hx, hy, hz = getPedBonePosition(Ped, 6) setCameraTarget (hx-dify/360-0.5, hy-difx/360, hz-1.4) Help-meee Link to comment
MTA Team botder Posted July 10, 2014 MTA Team Share Posted July 10, 2014 getPedBonePosition already returns the exact 3D world position. Why not simply use the 3 values and set it to setCameraTarget? Link to comment
ronaldoguedess Posted July 11, 2014 Author Share Posted July 11, 2014 I tried, but got the same thing ... Somebody help me! I am unsure what to do, tried everything! Link to comment
bandi94 Posted July 12, 2014 Share Posted July 12, 2014 As IIYAMA say'd setCameraTarget(X,Y,Z) will put the screen center to X,Y,Z and not the crosshair position , in 3D you can't just add X-1.5 , bk the axe positioning will chnage when you move around to in one angel you need -1.5 in other one you need -5 and -2 on Y and etc....... So you need to calculate all offset's acording to the 3D axe plan , or calculate it in 2D and transform them back to 3D. IT should work on any resolution i tested it on 1024/768 Windowed mode local x,y,z = getElementPosition( getLocalPlayer ()) local Ped = createPed(49,x,y,z) local dx,dy = guiGetScreenSize() aimX ,aimY = dx*0.54 , dy*0.3971 function AimOnPosition() local setToX,setToY = 0,0 local hx, hy, hz = getPedBonePosition(Ped, 6) local sx,sy = getScreenFromWorldPosition(hx,hy,hz) setToX = math.abs(dx/2-(aimX)) setToY = math.abs(dy/2-aimY) local a1,a2,a3 = getPedBonePosition(Ped, 6) local a4,a5,a6 = getElementPosition(Ped) local b1,b2,b3 = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(a1,a2,a3,b1,b2,b3) setToX,setToY = getWorldFromScreenPosition(sx-setToX,sy+setToY,dist) _,_,setToX1 = getWorldFromScreenPosition(dx/2,dy/2,dist) _,_,setToX2 = getWorldFromScreenPosition(aimX,aimY,dist) setToX3 = (setToX2 - setToX1) setCameraTarget(setToX,setToY,b3-setToX3+0.2 +(a6-b3)) end function drawStuff() if getControlState("aim_weapon") then AimOnPosition() end end addEventHandler("onClientRender", root, drawStuff) P.S If we had access to yaw/pitch/roll camera of GTA:SA then it would be easyer to make a very perfect aimbot , but we don't have direct access to yaw/pitch/roll of the camera. In online FPS Aimbot hack's , we control the yaw/pitch/roll it's like a direct link to the game engine camera positioning , so we can make it pin point accurate ( we can kill any target from very very far distance only with one bullet ( headshot) even if the target is moving like crazy or he is jumping / is in free fall , etc.. ). But thi's is up the the mod's to make MTA function's that would alow us to modifi the yaw/pitch/roll directly and not from this kind of camera function's like setCameraTarget , etc ..... Link to comment
ronaldoguedess Posted July 12, 2014 Author Share Posted July 12, 2014 Thank bandi94, that your script is as close to perfection as I saw .... works exactly as I imagined! However has some minor problems! Rifre, M4, Ak47, is closely wrong. Sniper is not right somehow! The smaller weapons were perfect ... The M4 is right at 29 feet away! Can you filter out the gun, and give different data for each! however want to know if this is possible! WHAT did you say! we do not have all the data we need! Sorry for my english. Link to comment
Einheit-101 Posted July 12, 2014 Share Posted July 12, 2014 I just dont know why setPedAimTarget doesnt work for localPlayer, it would make this stuff easy like hell Link to comment
bandi94 Posted July 13, 2014 Share Posted July 13, 2014 Thank bandi94, that your script is as close to perfection as I saw .... works exactly as I imagined! However has some minor problems! Rifre, M4, Ak47, is closely wrong. Sniper is not right somehow! The smaller weapons were perfect ... The M4 is right at 29 feet away! Can you filter out the gun, and give different data for each! however want to know if this is possible! WHAT did you say! we do not have all the data we need! Sorry for my english. All the magic is done by : aimX ,aimY = dx*0.54 , dy*0.3971 that is the 2D Cord of the crosshair , possible that M4 , etc have other crosshair position. Try to aim with a small wep and see where the crosshair is on your screen after that aim with M4 and compare where the crosshair is now according to that change the aimX,AimY value until it aim's well. After that use a check if is a small wep aimX/Y is x value is is m4 , etc aimX/Y is y value. Link to comment
Saml1er Posted July 13, 2014 Share Posted July 13, 2014 I just dont know why setPedAimTarget doesnt work for localPlayer, it would make this stuff easy like hell Ow I didn't know that. Calculating offsets for some weapons is time consuming and it would be better if MTA team makes setPedAimTarget for localPlayer as well. Link to comment
bandi94 Posted July 13, 2014 Share Posted July 13, 2014 I just dont know why setPedAimTarget doesnt work for localPlayer, it would make this stuff easy like hell Ow I didn't know that. Calculating offsets for some weapons is time consuming and it would be better if MTA team makes setPedAimTarget for localPlayer as well. MTA is just a synchronized code injector , what he dose is hooking up GTA:SA function's and after he read's the LUA command's transform them and send the command to GTA:SA original function's. Most possbile in GTA:SA setPedAimTarget is implemented only for Ped's ( when you play in single player the function is used to control the bot's) , so there is no straight way to implement it for localPlayer the only way would be to hardcode the aimbot into MTA using existing function's ( already suporrted be MTA here i mean camera functions ) so that will be the same thing i did but it would be implemented into MTA's dll , and from script's you would need to call that function ->dose the hardcode -> inject's into GTA:SA camera function's. P.S is so hard to make 2-3 print screen's on some weapon's after that in PhotoShop check the x,y cord of the crosshair ??? Link to comment
ronaldoguedess Posted July 14, 2014 Author Share Posted July 14, 2014 All the magic is done by : aimX ,aimY = dx*0.54 , dy*0.3971 that is the 2D Cord of the crosshair , possible that M4 , etc have other crosshair position. Try to aim with a small wep and see where the crosshair is on your screen after that aim with M4 and compare where the crosshair is now according to that change the aimX,AimY value until it aim's well. After that use a check if is a small wep aimX/Y is x value is is m4 , etc aimX/Y is y value. Now I understand ... I took a print screen's glances with both arms in ped (same place) The position of the crosshair is the same ... and now? How to pick the difference if the two staffs are in the same place? Thanks for helping me! I just dont know why setPedAimTarget doesnt work for localPlayer, it would make this stuff easy like hell Ow I didn't know that. Calculating offsets for some weapons is time consuming and it would be better if MTA team makes setPedAimTarget for localPlayer as well. This function will not work with players from the server? Link to comment
bandi94 Posted July 14, 2014 Share Posted July 14, 2014 Okey. I check it out. It seem's that for rifles , the camera will zoom in ( above the shoulder ) and that zoom in mess with setCameraTarget. What you could do is , to filter out the gun's (check if is rifle) if is a rifle then according to the distance add a small offset for the AimX value. Let's say AimX = AimX + (10 - distance*0.2) or something like that ( 10 mean's 10 pixel's - distance*0.2 , how distance will increase the offset will decreas bk you say'd that from 47 feet it's working well , so that offset would be added if the distance is smaller ) Link to comment
ronaldoguedess Posted July 14, 2014 Author Share Posted July 14, 2014 Understood, but which of these two vars "aimX" should be changed? This? aimX ,aimY = dx*0.54 , dy*0.3971 Or this? _,_,setToX2 = getWorldFromScreenPosition(aimX,aimY,dist) Have managed to do a check for the gun, missing only make the same correction! placed well below the first block of code shown above: aimX aimX = + (10 - 0.2 * dist) and the targeted player to the other side! Link to comment
bandi94 Posted July 14, 2014 Share Posted July 14, 2014 local x,y,z = getElementPosition( getLocalPlayer ()) local Ped = createPed(49,x,y,z) local dx,dy = guiGetScreenSize() aimX ,aimY = dx*0.54 , dy*0.3971 function AimOnPosition() local setToX,setToY = 0,0 local hx, hy, hz = getPedBonePosition(Ped, 6) local sx,sy = getScreenFromWorldPosition(hx,hy,hz) setToX = math.abs(dx/2-(aimX)) setToY = math.abs(dy/2-aimY) local a1,a2,a3 = getPedBonePosition(Ped, 6) local a4,a5,a6 = getElementPosition(Ped) local b1,b2,b3 = getElementPosition(localPlayer) local dist = getDistanceBetweenPoints3D(a1,a2,a3,b1,b2,b3) -- here if isRifle then aimX = dx*0.54 + (10 - dist*0.2) -- maybe you will need to play around with 10 or *0.2 to get the right result. else aimX = dx*0.54 end setToX,setToY = getWorldFromScreenPosition(sx-setToX,sy+setToY,dist) _,_,setToX1 = getWorldFromScreenPosition(dx/2,dy/2,dist) _,_,setToX2 = getWorldFromScreenPosition(aimX,aimY,dist) setToX3 = (setToX2 - setToX1) setCameraTarget(setToX,setToY,b3-setToX3+0.2 +(a6-b3)) end function drawStuff() if getControlState("aim_weapon") then AimOnPosition() end end addEventHandler("onClientRender", root, drawStuff) 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