Catching Objects between two players.

Xentron

Известный
Автор темы
15
0
Версия MoonLoader
.026-beta
Hey sorry for english again.
Is there any way to catch a big objects between two players? I am using this for a triggerbot. If yes, it shouldnt shoot (If the object is covering the player).

This is my attempt. It gives me other objects, and not those if are some inbetween.
Код:
function TriggerBot ()
    local result, target = getCharPlayerIsTargeting (playerHandle)
    if result then
        local result, id = sampGetPlayerIdByCharHandle (target)
        if result then
            local result = isCharInAnyCar (PLAYER_PED)
            if not result then
                local result = isPlayerDead (PLAYER_PED)
                local resultvictim = isPlayerDead (target)
                if not result and not resultvictim then
                    local object = sampGetObjectHandleBySampId (id)
                    print ("Objecthandle:" .. object)
                    local objectId = sampGetObjectSampIdByHandle (object)
                    print ("ObjectID:" .. objectId)
                    local modelId = getObjectModel (object)
                    print ("ModelID:" .. modelId)
                    local result, positionX, positionY, positionZ = getObjectCoordinates (object)
                    print ("Objects X / Y / Z Coordinates:" .. positionX .. "|" .. positionY .. "|" .. positionZ)
                    local myX, myY, myZ = getCharCoordinates (PLAYER_PED)
                    print ("My X / Y / Z Coordinates:" .. myX .. "|" .. myY .. "|" .. myZ)
                    local victimX, victimY, victimZ = getCharCoordinates (target)
                    print ("Victims X / Y / Z Coordinates:" .. victimX .. "|" .. victimY .. "|" .. victimZ)
                    print ("")
                    local lol = 0xB73458
                    lol = lol + 34
                    local randomCooldown = math.random (10, 50)
                    wait (randomCooldown)
                    writeMemory (lol, 4, 255, 0)
                    wait (100)
                    local int = readMemory (0xB6F3B8, 4, 0)
                    int = int + 0x79C
                    writeMemory (int, 4, 0, 0)
                end
            end
        end
    end
end
 [/ CODE] [/ CODE]
 
Последнее редактирование:
Решение
Yeah thats better, but how do i get the peds information with this function.
When i try to print out type and class, it doesnt give me any information.
There are several entity types:
Read more about MoonAdditions library here: https://github.com/THE-FYP/MoonAdditions/wiki
Here's the way you can print SAMP ID of player you are aiming
Lua:
function check_aiming_ped()
  local x1, y1, z1 = convertScreenCoordsToWorld3D(ax, ay, 3)
  local x2, y2, z2 = convertScreenCoordsToWorld3D(ax, ay, 200)
  local result, data = processLineOfSight(
    x1, y1, z1, x2, y2, z2,
    true,--checkSolid
    true,--car
    true,--ped
    true,--object
    false,--particle
    true,--seeThrough
    false,--ignoreSomeObjects...

Hatiko

Известный
Проверенный
1,512
627
Try using the isLineOfSightClear function using the coordinates of the player's dice. If most of the bones are visible, returns true.
i have one retarded idea:

for example ped have 20 bones...
1. using method from this script https://www.blast.hk/threads/15507/ or mad https://www.blast.hk/threads/18058/ you can get bones coords
2. create var = 0 and cycle check all bones. if bone visible then add +1 to var
3. if var >= 10 then half of the body is hidden
P.S. Мы прям одновременно одно и тоже написали )
 

Xentron

Известный
Автор темы
15
0
I dont know what you try to say by that. Can you give me a code example?
Try using the isLineOfSightClear function using the coordinates of the player's dice. If most of the bones are visible, returns true.

PS We wrote the same thing at the same time)
Ok so i got every position of every bone from the player. But when i do this like you said "if most of bones are visible", then shoot.
This doesnt prevent me from shooting an object (when crouching or just aiming at the models "blocked" stuff).
So how can i make it, that he only shoots to the bones which are visible to me? (Meaning: if his upper body is visible, my triggerbot shouldnt react to his feet thru an object) If i know this, then i can finish this.
i have one retarded idea:

for example ped have 20 bones...
1. using method from this script https://www.blast.hk/threads/15507/ or mad https://www.blast.hk/threads/18058/ you can get bones coords
2. create var = 0 and cycle check all bones. if bone visible then add +1 to var
3. if var >= 10 then half of the body is hidden

Код:
local moon = require "MoonAdditions"


function TriggerBot()
    local weaponCheck = isCurrentCharWeapon(PLAYER_PED, 24) -- Check if Deagle in hand
    if weaponCheck then
        local result, target = getCharPlayerIsTargeting(playerHandle)
        if result then
            local result, id = sampGetPlayerIdByCharHandle(target)
            if result then
                local result = isCharInAnyCar(PLAYER_PED)
                if not result then
                    local result = isPlayerDead(PLAYER_PED)
                    local resultvictim = isPlayerDead(target)
                    if not result and not resultvictim then
                        local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
                        local victimX, victimY, victimZ = getCharCoordinates(target) bv
                        for name, id in pairs(moon.bone_id) do
                            local bone = moon.get_char_bone(PLAYER_PED, id)
                            if bone then
                                local bone_pos = bone.matrix.pos
                                local sx, sy = convert3DCoordsToScreen(bone_pos.x, bone_pos.y, bone_pos.z)
                                print(name, id)
                            end
                        end
                        print("")
                        --local result = isLineOfSightClear(myX, myY, myZ, victimX, victimY, victimZ, true, true, false, true, false)
                        --print(result)
                        --if result then
                        --    local lol = 0xB73458
                        --    lol=lol + 34
                        --    local randomCooldown = math.random(1, 150)
                        --    wait(randomCooldown)
                        --    writeMemory(lol, 4, 255, 0)
                        --    wait(randomCooldown)
                        --    local int = readMemory(0xB6F3B8, 4, 0)
                        --    int=int + 0x79C
                        --    writeMemory(int, 4, 0, 0)
                        --end
                    end
                end
            end
        end
    --elseif isCurrentCharWeapon(PLAYER_PED, 34) then
    end
end
[/ CODE]
 
Последнее редактирование:

THERION

Известный
Проверенный
88
327
I dont know what you try to say by that. Can you give me a code example?

Ok so i got every position of every bone from the player. But when i do this like you said "if most of bones are visible", then shoot.
This doesnt prevent me from shooting an object (when crouching or just aiming at the models "blocked" stuff).
So how can i make it, that he only shoots to the bones which are visible to me? (Meaning: if his upper body is visible, my triggerbot shouldnt react to his feet thru an object) If i know this, then i can finish this.


Код:
local moon = require "MoonAdditions"


function TriggerBot()
    local weaponCheck = isCurrentCharWeapon(PLAYER_PED, 24) -- Check if Deagle in hand
    if weaponCheck then
        local result, target = getCharPlayerIsTargeting(playerHandle)
        if result then
            local result, id = sampGetPlayerIdByCharHandle(target)
            if result then
                local result = isCharInAnyCar(PLAYER_PED)
                if not result then
                    local result = isPlayerDead(PLAYER_PED)
                    local resultvictim = isPlayerDead(target)
                    if not result and not resultvictim then
                        local myX, myY, myZ = getCharCoordinates(PLAYER_PED)
                        local victimX, victimY, victimZ = getCharCoordinates(target) bv
                        for name, id in pairs(moon.bone_id) do
                            local bone = moon.get_char_bone(PLAYER_PED, id)
                            if bone then
                                local bone_pos = bone.matrix.pos
                                local sx, sy = convert3DCoordsToScreen(bone_pos.x, bone_pos.y, bone_pos.z)
                                print(name, id)
                            end
                        end
                        print("")
                        --local result = isLineOfSightClear(myX, myY, myZ, victimX, victimY, victimZ, true, true, false, true, false)
                        --print(result)
                        --if result then
                        --    local lol = 0xB73458
                        --    lol=lol + 34
                        --    local randomCooldown = math.random(1, 150)
                        --    wait(randomCooldown)
                        --    writeMemory(lol, 4, 255, 0)
                        --    wait(randomCooldown)
                        --    local int = readMemory(0xB6F3B8, 4, 0)
                        --    int=int + 0x79C
                        --    writeMemory(int, 4, 0, 0)
                        --end
                    end
                end
            end
        end
    --elseif isCurrentCharWeapon(PLAYER_PED, 34) then
    end
end
[/ CODE]
You shouldn't use getCharPlayerIsTargeting for this purpose. This function often returns true even if you are not aiming a char directly.
In my scripts i use the code below to check if i am aiming someone
Lua:
function get_crosshair_pos_3d()
  local ffi = require('ffi')
  local vec_out = ffi.new('float[3]')
  local tmp_vec = ffi.new('float[3]')
  ffi.cast('void (__thiscall*)(void*, float, float, float, float, float*, float*)', 0x514970)(ffi.cast('void*', 0xB6F028), 15.0, tmp_vec[0], tmp_vec[1], tmp_vec[2], tmp_vec, vec_out)
  return vec_out[0], vec_out[1], vec_out[2]
end

local cx, cy, cz =  get_crosshair_pos_3d()
local ax, ay = convert3DCoordsToScreen(cx, cy, cz)

local mad = require'MoonAdditions'

function check_aiming_ped()
  local x1, y1, z1 = convertScreenCoordsToWorld3D(ax, ay, 3)
  local x2, y2, z2 = convertScreenCoordsToWorld3D(ax, ay, 200)
  local result, data = processLineOfSight(
    x1, y1, z1, x2, y2, z2,
    true,--checkSolid
    true,--car 
    true,--ped 
    true,--object 
    false,--particle 
    true,--seeThrough
    false,--ignoreSomeObjects
    false)--shotThrough
  if result then
    local type, class = mad.get_entity_type_and_class(data.entity)
    return (type == mad.entity_type.PED and class == mad.entity_class.PLAYER_PED)
  else return false end
end
 
  • Нравится
Реакции: Xentron

Xentron

Известный
Автор темы
15
0
Yeah thats better, but how do i get the peds information with this function.
When i try to print out type and class, it doesnt give me any information.

You shouldn't use getCharPlayerIsTargeting for this purpose. This function often returns true even if you are not aiming a char directly.
In my scripts i use the code below to check if i am aiming someone
Lua:
function get_crosshair_pos_3d()
  local ffi = require('ffi')
  local vec_out = ffi.new('float[3]')
  local tmp_vec = ffi.new('float[3]')
  ffi.cast('void (__thiscall*)(void*, float, float, float, float, float*, float*)', 0x514970)(ffi.cast('void*', 0xB6F028), 15.0, tmp_vec[0], tmp_vec[1], tmp_vec[2], tmp_vec, vec_out)
  return vec_out[0], vec_out[1], vec_out[2]
end

local cx, cy, cz =  get_crosshair_pos_3d()
local ax, ay = convert3DCoordsToScreen(cx, cy, cz)

local mad = require'MoonAdditions'

function check_aiming_ped()
  local x1, y1, z1 = convertScreenCoordsToWorld3D(ax, ay, 3)
  local x2, y2, z2 = convertScreenCoordsToWorld3D(ax, ay, 200)
  local result, data = processLineOfSight(
    x1, y1, z1, x2, y2, z2,
    true,--checkSolid
    true,--car
    true,--ped
    true,--object
    false,--particle
    true,--seeThrough
    false,--ignoreSomeObjects
    false)--shotThrough
  if result then
    local type, class = mad.get_entity_type_and_class(data.entity)
    return (type == mad.entity_type.PED and class == mad.entity_class.PLAYER_PED)
  else return false end
end
 
Последнее редактирование:

THERION

Известный
Проверенный
88
327
Yeah thats better, but how do i get the peds information with this function.
When i try to print out type and class, it doesnt give me any information.
There are several entity types:
Read more about MoonAdditions library here: https://github.com/THE-FYP/MoonAdditions/wiki
Here's the way you can print SAMP ID of player you are aiming
Lua:
function check_aiming_ped()
  local x1, y1, z1 = convertScreenCoordsToWorld3D(ax, ay, 3)
  local x2, y2, z2 = convertScreenCoordsToWorld3D(ax, ay, 200)
  local result, data = processLineOfSight(
    x1, y1, z1, x2, y2, z2,
    true,--checkSolid
    true,--car
    true,--ped
    true,--object
    false,--particle
    true,--seeThrough
    false,--ignoreSomeObjects
    false)--shotThrough
  if result then
    local type, class = mad.get_entity_type_and_class(data.entity)
    if type == mad.entity_type.PED and class == mad.entity_class.PLAYER_PED then
      local handle = getCharPointerHandle(data.entity)
      if handle then
        local alive, id = sampGetPlayerIdByCharHandle(handle)
        if alive then
          print(string.format("%d is the id of char, you are aiming", id))
        end
      end
      return true
    else return false end
  else return false end
end
You can use functions like getCharPointerHandle to corresponding entities, so if you want to get info about car which you are aiming you should use getVehiclePointerHandle
 
  • Нравится
Реакции: Xentron