Jump to content

processLineOfSight problem


Kenix

Recommended Posts

Posted (edited)

I have a problem when the bot behind the wall we see image please help fix it.

  
addEventHandler( "onClientRender", getRootElement(), 
   function( ) 
    for _, plr in ipairs( getElementsByType( "ped" ) ) do 
        if (getElementData (plr, "zombie") == true and getElementData(plr, "status" ) ~= "dead")  then 
            local Px,Py,Pz = getElementPosition( getLocalPlayer() ) 
            local Zx,Zy,Zz = getElementPosition( plr ) 
            local distance = (getDistanceBetweenPoints3D (Px, Py, Pz, Zx, Zy, Zz)) 
            if (distance < 35) and (distance > 2) then    
                local x, y, z = getPedBonePosition( plr, 8 ) 
                local sX, sY,sZ = getScreenFromWorldPosition( x, y, z+0.5 ) 
                local cx, cy, cz = getCameraMatrix() 
                local ht,hX,hY,hZ,hE  = processLineOfSight(cx, cy, cz,sX, sY,sZ,true,false, false, true, false, false,false,false,plr) 
                if ht then 
                    if sX then 
                        if getElementData( plr ,"zClass") == 6 then  
                            dxDrawImage(sX, sY,10, 10,"w.png") 
                    elseif getElementData( plr ,"zClass") == 1 then  
                            dxDrawImage(sX, sY,10, 10,"wg.png") 
                    elseif getElementData( plr ,"zClass") == 2 then 
                            dxDrawImage(sX, sY,10, 10,"g.png") 
                    elseif getElementData( plr ,"zClass") == 3 then 
                            dxDrawImage(sX, sY,10, 10,"y.png") 
                    elseif getElementData( plr ,"zClass") == 4 then 
                            dxDrawImage(sX, sY,10, 10,"r.png")  
                    elseif getElementData( plr ,"zClass") == 5 then 
                            dxDrawImage(sX, sY,10, 10,"b.png") 
                            end 
                        end 
                   end 
              end 
          end 
      end 
   end 
) 
  

Edited by Guest

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted
you don't need to use getScreenFromWorldPosition( x, y, z+0.5 ) for line of sight, just do processLineOfSight(cx,cy,cz,x,y,z+0.5)

thx karlis.

So I removed the image that was visible through objects, etc. but now there is no image at all please help :(

  
addEventHandler( "onClientRender", getRootElement(), 
   function( ) 
    for _, plr in ipairs( getElementsByType( "ped" ) ) do 
        if (getElementData (plr, "zombie") == true and getElementData(plr, "status" ) ~= "dead")  then 
            local Px,Py,Pz = getElementPosition( getLocalPlayer() ) 
            local Zx,Zy,Zz = getElementPosition( plr ) 
            local distance = (getDistanceBetweenPoints3D (Px, Py, Pz, Zx, Zy, Zz)) 
            if (distance < 35) and (distance > 2) then    
                local x, y, z = getPedBonePosition( plr, 8 ) 
                local sX, sY,sZ = getScreenFromWorldPosition( x, y, z ) 
                local cx, cy, cz = getCameraMatrix() 
                local ht,hX,hY,hZ,hE  = processLineOfSight(cx, cy, cz,x, y,z + 0.5,false,false,false,false,false,false,false,false,plr)  
                if ht then 
                    if sX then 
                        if getElementData( plr ,"zClass") == 6 then  
                            dxDrawImage(sX, sY,10, 10,"w.png") 
                    elseif getElementData( plr ,"zClass") == 1 then  
                            dxDrawImage(sX, sY,10, 10,"wg.png") 
                    elseif getElementData( plr ,"zClass") == 2 then 
                            dxDrawImage(sX, sY,10, 10,"g.png") 
                    elseif getElementData( plr ,"zClass") == 3 then 
                            dxDrawImage(sX, sY,10, 10,"y.png") 
                    elseif getElementData( plr ,"zClass") == 4 then 
                            dxDrawImage(sX, sY,10, 10,"r.png")  
                    elseif getElementData( plr ,"zClass") == 5 then 
                            dxDrawImage(sX, sY,10, 10,"b.png") 
                            end 
                        end 
                   end 
              end 
          end 
      end 
   end 
) 
  

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted
you need to see image when zombie is behind wall or when it is not?

if when not you need to put "if not hit then "

I need not see the image behind the wall :)

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...