Search the Community
Showing results for tags 'target'.
-
My goal is simple, after using GetPedCollisionTarget, I want it to return 3 numbers that correspond to the coordinates of the target that has collision detection, but for this function to return something, you must first aim the weapon. And here is the problem because when the player is aiming, the crosshair is somewhere close but not in the center of the center, and I want to get the coordinates of the target in the center, not somewhere nearby. And here comes the question, is it possible to make GetPedCollisionTarget work but without aiming the weapon? PLEASE HELP
-
I have a problem with setElementTarget recently, because I would like to make a script in which when I aim at something, "CreateWeapon" will shoot in that direction, but no matter what I do, it shoots too close or crooked. Anyone got any idea for this?
-
for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,2555,255,255)) dxSetRenderTarget() end Why not working? No errors/warnings..
-
When you press handbrake it should draw the image named 'crosshair.png' on the target, but this does not happen. What can be the error? The debugscript 3 does not output any errors Here's the code : local SHOOT_COOLDOWN = 5000 --Cooldown between homing shots local LOCKON_TIME = 100 --Time required to lock on to a target local LOCK_RANGE = 330 --Maximum distance between you and the target local LOCK_ANGLE = 0.95 --(in radians) We cannot lock on targets unless they are within this angle of the front of the hydra local VALID_TARGET_FUNCTION = function (vehicle) --Used to decide whether a vehicle should appear as a lock-on option -- local targetTeam = vehicle.controller and vehicle.controller.team -- local ourTeam = localPlayer.team -- if targetTeam and ourTeam and targetTeam == ourTeam then -- return false --The target vehicle has someone driving, and both of you are on the same team -- end return true end local validTarget = VALID_TARGET_FUNCTION or function() return true end LOCK_ANGLE = math.cos(LOCK_ANGLE) local inHydra = false local firestate = nil local visibleVehicle = {} local targetVehicle = nil local nearbyVehicles = {} getNearbyVehicles = function() return nearbyVehicles end --Used by other files local currentHydra = nil local function getTarget() -- Look for the nearest targets and lock on local nearestVehicle = nil local shortestDistance = LOCK_RANGE for _, vehicle in ipairs(nearbyVehicles) do local targPos = vehicle.position local myPos = localPlayer.position local displacement = targPos-myPos local dist = displacement.length if vehicle ~= localPlayer.vehicle and dist < shortestDistance then shortestDistance = dist nearestVehicle = vehicle end end return nearestVehicle end local function checkForLockout(vehicle) if visibleVehicle[vehicle] then visibleVehicle[vehicle] = nil lockedVehicle = nil targetVehicle = nil end end local lastShot = SHOOT_COOLDOWN*-2 local function shootMissile() if not inHydra then return end local target = lockedVehicle if not target or getTickCount() < lastShot + SHOOT_COOLDOWN then return end lastShot = getTickCount() local hydra = localPlayer.vehicle -- Shoot missile createProjectile( hydra, 20, hydra.position, 5000, target, _, _, _, hydra.velocity*1.2) lockedVehicle = nil targetVehicle = nil visibleVehicle[target] = nil end local function update() local curtime = getTickCount() local vehicle = targetVehicle if not vehicle then return end local visibleNow = false if vehicle ~= localPlayer.vehicle and not vehicle.blown and validTarget(vehicle) then local targPos = vehicle.position local myPos = localPlayer.position local displacement = targPos-myPos local dist = displacement.length local cosAngle = localPlayer.vehicle.matrix.forward:dot(displacement)/dist if dist < LOCK_RANGE and cosAngle>LOCK_ANGLE and firestate then local aX, aY = getScreenFromWorldPosition(targPos) if (aX and aY) then visibleNow = true if lockedVehicle == vehicle then dxDrawImage (aX-118,aY-118, 246, 246, 'crosshair.png',0,0,0,tocolor (255,0,0,255)) else dxDrawImage (aX-118, aY-118, 246, 246, 'crosshair.png',0,0,0,tocolor (255,255,255,255)) end end end end if not visibleNow then checkForLockout() elseif visibleVehicle[vehicle] then if curtime - visibleVehicle[vehicle] > LOCKON_TIME then lockedVehicle = vehicle end else visibleVehicle[vehicle] = curtime end end local function homingState(key,state) if not inHydra then return end if state == "down" then targetVehicle = getTarget() firestate = isControlEnabled("vehicle_secondary_fire") toggleControl("vehicle_secondary_fire",false) bindKey("vehicle_secondary_fire","down",shootMissile) else targetVehicle = nil lockedVehicle = nil toggleControl("vehicle_secondary_fire",firestate) firestate = nil unbindKey("vehicle_secondary_fire","down",shootMissile) end end local function vehicleGoneHandler() removeEventHandler("onClientElementDestroy", source, vehicleGoneHandler) removeEventHandler("onClientElementStreamOut", source, vehicleGoneHandler) if getElementType( source ) == "vehicle" then for i, v in ipairs(nearbyVehicles) do if v == source then checkForLockout(source) table.remove(nearbyVehicles, i) return end end end end local function prepAfterStreamIn(vehicle) addEventHandler("onClientElementStreamOut", vehicle, vehicleGoneHandler) addEventHandler("onClientElementDestroy", vehicle, vehicleGoneHandler) end local function streamInHandler() if getElementType( source ) == "vehicle" then table.insert(nearbyVehicles, source) prepAfterStreamIn(source) end end local function startHydra(vehicle) if not inHydra and vehicle and isElement(vehicle) and vehicle.model == 520 then nearbyVehicles = getElementsByType("vehicle", root, true) for i, v in ipairs(nearbyVehicles) do prepAfterStreamIn(v) end addEventHandler("onClientElementStreamIn", root, streamInHandler) addEventHandler("onClientVehicleExplode", vehicle, stopHydra) addEventHandler("onClientElementDestroy", vehicle, stopHydra) addEventHandler("onClientElementStreamOut", vehicle, stopHydra) inHydra = isControlEnabled("handbrake") currentHydra = vehicle toggleControl("handbrake", false) bindKey("handbrake","down",homingState) bindKey("handbrake","up",homingState) addEventHandler( "onClientRender", root, update) end end function stopHydra() if inHydra then local target = getTarget() for i, v in ipairs(nearbyVehicles) do if v ~= target then removeEventHandler("onClientElementDestroy", v, vehicleGoneHandler) removeEventHandler("onClientElementStreamOut", v, vehicleGoneHandler) checkForLockout(v) end end checkForLockout(target) if target then removeEventHandler("onClientElementDestroy", target, vehicleGoneHandler) removeEventHandler("onClientElementStreamOut", target, vehicleGoneHandler) end removeEventHandler("onClientRender", root, update) unbindKey("handbrake","down",homingState) unbindKey("handbrake","up",homingState) if firestate ~= nil then homingState("handbrake","up") end local vehicle = currentHydra currentHydra = nil toggleControl("handbrake", inHydra) inHydra = false removeEventHandler("onClientElementStreamIn", root, streamInHandler) if isElement(vehicle) then removeEventHandler("onClientVehicleExplode", vehicle, stopHydra) removeEventHandler("onClientElementDestroy", vehicle, stopHydra) removeEventHandler("onClientElementStreamOut", vehicle, stopHydra) end end end local function initScript() if localPlayer.vehicle and localPlayer.vehicle.model == 520 then startHydra(localPlayer.vehicle) end addEventHandler("onClientResourceStop", resourceRoot, stopHydra) addEventHandler("onClientPlayerVehicleExit",localPlayer,stopHydra) addEventHandler("onClientPlayerWasted",localPlayer,stopHydra) addEventHandler("onClientPlayerVehicleEnter",localPlayer,startHydra) end addEventHandler("onClientResourceStart",resourceRoot,initScript)
-
Olá senhores. Bom, estou precisando fazer um objeto apontar para outro como se ele estivesse fazendo um Look At. Mas não sei como calcular o ângulo da rotação Z com base nas posições. Exemplo. Objeto A está na posição 0, 0, 0. Objeto B está na posição 1, 1, 0. Ilustrações: Aplicando o Look At no Objeto A para o B, deve fazer o objeto A "mirar" no Objeto B, colocando a rotação Z do objeto A em 315. Mas como calculo isso? Obs: A rotação é com base nas posições, não importa a rotação do objB.
-
UPDATE: This resource is now on version 1.1 This update includes: * Hydra targetting actions now trigger MTA events. * Only rendered vehicles are considered, making it scale much better on larger servers. * Many bugs fixed (Such as errors spawning from a hydra being deleted via "destroyElement" * The coloured boxes around the targets are now optional, and can be customized. * A new feature called "focus" to show what the events triggered can be used for. * Better colour choices. New demo video is here: ========================================== The creator of this bug report (https://bugs.mtasa.com/view.php?id=9763) gave me some good reasons why MTA's default Hydra missile targetting system needs to be redone. * GTA was not made for multiplayer, so bugs like the one he filed are present in the default targetting system * It is not flexible, the server cannot change parameters such as lock-on time, angle of detection, range, cooldown etc. * You cannot have team tagging, which would be a great feature. Don't you hate it when you're holding space your own clan mates get targetted? * You cannot cycle through possible targets. The game decides which target you locked on to, and you can't change it unless you move around and do random stuff. So, I decided to implement a custom Hydra targetting system with all these features, with help from Antix. (Thanks to Edeen, Slim, Meex, Ease and Khid for testing the script) This is a drop in replacement for GTA's default missile targetting system, and only adds a few features (that can be nerfed) while remaining faithful to the original mechanics. The resource is free (MIT License) and you can use it on your server if you want. Download it and read the instructions for customizing it here: https://github.com/Luca-spopo/better-hydra-missiles Once it gets used by enough servers and tested enough, maybe we can include this in the default resources as a replacement for the current hydra/hunter missile system.
-
so i saw in a server when i got into hydra i got to see all the targets what resource is this can someone tell me please?