Jump to content

I need a little help here


roaddog

Recommended Posts

Hey guys

I need help, I made this script which gonna draw gang above head,

Idk if it works or not, so this

isRendering = false 
addEventHandler( "onClientRender",root, 
   function( ) 
   if isRendering then 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 30.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) 
               local lmao = getElementData(localPlayer, "Group") 
               if x then -- getScreenFromWorldPosition returns false if the point isn't on screen 
                dxDrawText( tostring(lmao), x-25, y-70, x, y, tocolor(0, 150, 0), 0.85 + ( 15 - dist ) * 0.02, "bankgothic","center", "center" ) 
               end 
               end 
            end 
         end 
      end 
    end 
)              for i, d in ipairs ( getElementsByType 'player' ) do 
                    if d ~= localPlayer then 
                    isRendering = false 
                    else 
                    isRendering = true 
                    end 
               end 

Well is this gonna work? I mean localPlayer wont see his render, and only others can see it.

Link to comment

I'm just asking, what do you think these three lines do?

for i, d in ipairs ( getElementsByType 'player' ) do 
                    if d ~= localPlayer then 
                    isRendering = false 

Do you even try to understand the code you copy?

Link to comment

Alright then. I removed those line and add this

    function showGang() 
    for i,player in ipairs(getElementsByType"player") do 
              isRendering = true   
        end 
    end 
    addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), showGang) 

then how to show only for others?

Link to comment

By adding these thre lines you just removed again, then look at them carefully one or more times until you understand that the problem isn't the lines but the logical statement which returns the opposite result.

for i, d in ipairs ( getElementsByType 'player' ) do 
    if d ~= localPlayer then 
        isRendering = false 

Link to comment

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...