ronaldoguedess Posted July 3, 2014 Share Posted July 3, 2014 Is there any way to make the auto aim? to follow the player? I would create this system in my server as a reward to those who turn "HERO". But I have no idea how to create this function the "Aimbot" anyone have any idea if the MTA allow this? Hugs. Link to comment
_DrXenon Posted July 3, 2014 Share Posted July 3, 2014 Why would MTA disallow that as long as it was created with Lua function? Link to comment
ronaldoguedess Posted July 3, 2014 Author Share Posted July 3, 2014 I did not understand your reply SuperCroz... Is there any way to enable this? I wonder if it is possible to create pro MTA? Link to comment
SkittlesAreFalling Posted July 4, 2014 Share Posted July 4, 2014 It is possible, I can view the code in my head, really simple. Link to comment
ronaldoguedess Posted July 4, 2014 Author Share Posted July 4, 2014 Can you help me with the script? or tell me what functions should I use? I try to do. Thank you. Link to comment
SkittlesAreFalling Posted July 4, 2014 Share Posted July 4, 2014 Use client-side scripting, bind the aim key, get the distance between the players to get the closest player, there's a useful function findRotation on the wiki, if you want it to lock onto the target (use a timer to determine if the player is still close to the target and keep setting rotation to that target), if you want it to bounce to the closest player always (use the timer to determine who's the closest player and set rotation towards the closest player). For the health arrows I'm sure you will find a way, I'm not too experienced in that subject but I am learning. Link to comment
bandi94 Posted July 4, 2014 Share Posted July 4, 2014 Well yes it's realy simple. Detection methode 2 way : closest by 3D world distance or closes in 2D dist by screen center. MTA has an inbulid aim script but it work's only with Ped's ( And not real player's ) so for aim you need to use some position matrix , maybe adding soem offset's etc... and after that use : setPedLookAt , and other aim function's. Link to comment
Moderators IIYAMA Posted July 4, 2014 Moderators Share Posted July 4, 2014 There are no functions that make this possible yet very easily. The functions that are there do not work for the localPlayer, but only for remote players(other players except your self) and peds. Link to comment
ronaldoguedess Posted July 4, 2014 Author Share Posted July 4, 2014 I'm trying to do here! the beginning did check when the player clicks the button to aim! function funcInput ( key, keyState ) if ( keyState == "down" ) then local x,y,z = getElementPosition( getLocalPlayer () ) -- ok local tx,ty,tz = getElementPosition( source ) -- [b][color=#FF0000]How to get the target?[/color][/b] end end bindKey ( "aim_weapon", "down", funcInput ) -- bind the aim_weapon down key bindKey ( "aim_weapon", "up", funcInput ) -- bind the aim_weapon up key And now? what is the next step? Link to comment
SkittlesAreFalling Posted July 4, 2014 Share Posted July 4, 2014 To get the target you can do a for loop with getElementsByType("player"): local X, Y, Z = 0.0, 0.0, 0.0; local TX, TY, TZ = 0.0, 0.0, 0.0; local ClosestPlayer = nil; local Distance = 999999.999999; local StreamedPlayers = {}; X, Y, Z = getElementPosition(getLocalPlayer() or source); StreamedPlayers = getElementsByType("player", getRootElement(), true); for Key, Value in ipairs(StreamedPlayers) do -- Value is the element. '/t' TX, TY, TZ= getElementPosition(Value); '/t' if(Distance > getDistanceBetweenPoints3D(X, Y, Z, TX, TY, TZ)) then '/t' '/t' ClosestPlayer = Value; '/t' '/t' Distance = getDistanceBetweenPoints3D(X, Y, Z, TX, TY, TZ); '/t' end end if(isElement(ClosestPlayer) and getElementType(ClosestPlayer) == "player") then '/t' TX, TY, TZ= getElementPosition(Value); -- Aiming code here. end '/t' - tab. Link to comment
SkittlesAreFalling Posted July 4, 2014 Share Posted July 4, 2014 You can also bind them to "both" instead of two binds "up" and "down" Then in the function parameters (Key, KeyState) KeyState = "up" or "down" based on what they player did. Link to comment
Moderators IIYAMA Posted July 4, 2014 Moderators Share Posted July 4, 2014 Getting isn't the problem, setting is it. Link to comment
ronaldoguedess Posted July 4, 2014 Author Share Posted July 4, 2014 This working! Thanks "SkittlesAreFalling" Thus I take the position of all players, like picking the nearest? only 1? What is the function to set the target? I tried: setElementRotation(player,0,0,TZ) setCameraTarget(player, Value) But it did not work! The player turns around, but not on top of the PED. Link to comment
SkittlesAreFalling Posted July 5, 2014 Share Posted July 5, 2014 Like "bandi94" said: "you need to use some position matrix , maybe adding soem offset's etc... and after that use : setPedLookAt , and other aim function's." Try setting the rotation to (TZ + 0.05) or even (TZ + 0.000005), small tinkers and experimenting until it's 100% perfect. I gave you a untested base, it wasn't going to work flawlessly the first test, you need to use your brain and the wiki. I can do it flawless but I am busy. Goodluck! Link to comment
ronaldoguedess Posted July 5, 2014 Author Share Posted July 5, 2014 Thanks for helping me! This "setPedLookAt" function would be perfect, however she is not working. the camera does not move. : ( Link to comment
SkittlesAreFalling Posted July 5, 2014 Share Posted July 5, 2014 Well we're not saying that it would work, we were saying you should test and experiment for yourself using different functions that are similar. Link to comment
MTA Team botder Posted July 5, 2014 MTA Team Share Posted July 5, 2014 Why not make use of processLineOfSight and simply make no switching between targets? Link to comment
ronaldoguedess Posted July 5, 2014 Author Share Posted July 5, 2014 What is the function to fix the camera on target? My difficulty is that I am getting a little long .. I have little knowledge. WHAT can I do with this "processLineOfSight" did not understand the example of the wiki. Link to comment
Den. Posted July 5, 2014 Share Posted July 5, 2014 There is no function that forces the localPlayer to aim with a weapon at a specific point/target. I don't think this is possible. You can easily determine which ped to actually aim/focus on by a combination of getting the closest ped by distance, and least rotation change to face the ped. The following code draws the circles ontop of the ped that should have the aim/focus (untested btw): Doesn't scale, or check for Line of sight. 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) end end end end) Link to comment
ronaldoguedess Posted July 5, 2014 Author Share Posted July 5, 2014 Wow, it worked! He put a circle in the nearest ped me head! Missing only one way to fix the crosshair in PED ... Is not there some way? some function? if not, all this insistence that system will be lost. : ( Link to comment
ronaldoguedess Posted July 5, 2014 Author Share Posted July 5, 2014 The example that "Den.Snitch" has posted this system "dxDrawcircle". However, now we need some function that makes localPlayer fix the aim and track the "Target Ped" or "Target Player". the MTA should have this function natively! Link to comment
MTA Team botder Posted July 5, 2014 MTA Team Share Posted July 5, 2014 Try some experiments with setCameraMatrix. 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