Jump to content

Poner distancia de funcionamiento a


MYSOTO

Recommended Posts

Hola tengo este pequeño script y lo que pasa que no se porque se bugea y no toma solo a los jugadores que les apunto o están cerca sino también toma a lejanos me gustaría saber como podría  hacer que a una distancia corta solo le baje vida a los jugadores cercanos pero no al reproductor
function playerTargetCheck ( )
    local target
    for i, thePlayer in ipairs ( getElementsByType("player") ) do  -- iterate over all players
        target = getPedTarget ( thePlayer )                        -
        if ( target ) then                                         -- if there was a target
            local health = getElementHealth(target) 
            setElementHealth (target, health - 50 ) 

        end
    end
end
addCommandHandler ( "sharigano", playerTargetCheck )

Link to comment
On 22/11/2017 at 00:21, MystoganScripter said:

Hola tengo este pequeño script y lo que pasa que no se porque se bugea y no toma solo a los jugadores que les apunto o están cerca sino también toma a lejanos me gustaría saber como podría  hacer que a una distancia corta solo le baje vida a los jugadores cercanos pero no al reproductor
function playerTargetCheck ( )
    local target
    for i, thePlayer in ipairs ( getElementsByType("player") ) do  -- iterate over all players
        target = getPedTarget ( thePlayer )                        -
        if ( target ) then                                         -- if there was a target
            local health = getElementHealth(target) 
            setElementHealth (target, health - 50 ) 

        end
    end
end
addCommandHandler ( "sharigano", playerTargetCheck )

function playerTargetCheck ( )
    for i, thePlayer in ipairs ( getElementsByType( "player" ) ) do    
    	if ( player ~= thePlayer ) then
       		local px, py, pz = getElementPosition( thePlayer )
      		local tx, ty, tz = getElementPosition( player )
      		if ( getDistanceBetweenPoints3D( px, py, pz, tx, ty, tz ) <= 50 ) then
        		setElementHealth( player, ( getElementHealth( player ) - 50 < 0 ) and 0 or getElementHealth( player ) - 50 )
        	end
        end
    end
end
addCommandHandler ( "sharigano", playerTargetCheck )

 

  • Thanks 1
Link to comment
On 22/11/2017 at 23:54, Uknown. said:

function playerTargetCheck ( )
    for i, thePlayer in ipairs ( getElementsByType( "player" ) ) do    
    	if ( player ~= thePlayer ) then
       		local px, py, pz = getElementPosition( thePlayer )
      		local tx, ty, tz = getElementPosition( player )
      		if ( getDistanceBetweenPoints3D( px, py, pz, tx, ty, tz ) <= 50 ) then
        		setElementHealth( player, ( getElementHealth( player ) - 50 < 0 ) and 0 or getElementHealth( player ) - 50 )
        	end
        end
    end
end
addCommandHandler ( "sharigano", playerTargetCheck )

 

gracias me ayudaste mucho xddd

 

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