Jump to content

Artix

Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

396 profile views

Artix's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. local target = a point with some meters ahead of the hydra. maybe 200 local m1 = createProjectile(hydra,20,hydraleftwingposition,1, target,0,0,0,hydra.matrix.forward) local m2 = createProjectile(hydra,20,hydrarightwingposition,1, target,0,0,0,hydra.matrix.forward) how can i get missiles to the same point or that gather along the way without slowing velocity, i already try setElementPosition and setElementVelocity, findRot and findRot3D but i can't make it work because i don't know how exactly to do it mathematically. can someone help me, pls? Thanks in advance
  2. function myCallback(data, errno,path) if errno == 0 then triggerEvent("onFileTDownload", root, "sound.mp3", data); else outputChatBox ('Error '..errno) --it return error 7, when ip == localhost returns error 1006 end end addEvent("onFileTDownload", false); addEventHandler("onFileTDownload", root, function(path,data) local file; if not fileExists(path) then file = fileCreate(path); else file = fileOpen(path); end; fileWrite(file, data); fileClose(file); -- do whatever with the file ... end); function testdownload () fetchRemote("http://127.0.0.1:80/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3'); --[[i tried the following two examples too... fetchRemote("http://localhost/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3'); fetchRemote("http://localhost:80/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3'); ]] end addCommandHandler ('tts',testdownload) --[[ All in the client side]] How to solve it? can someone help me pls
  3. There are two missiles that come from the sides of the hydra, I need that the missiles come together but I do not know how to do that by editing rotation or velocity. when I try, it deviate There is really no need to publish the code, I just want to know how to get the two missiles together without it deviating I hope someone helps me please
  4. Hello greetings to all I need help with this, I want to know how I can do to add the subPixelPositioning function to the dxDrawImage, or some way that the dxDrawImage is the same as if it had that function It would be very helpful, thanks in advance
  5. 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)
  6. 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)
×
×
  • Create New...