Jump to content

Ped Atirar Player invasion


Recommended Posts

--Client-siide
function cmdArmedPed( command, thePlayer )
    local x, y, z = getElementPosition(localPlayer) -- Get your position
    local thePed = createPed(12,-712.21143, 942.30859, 12.34728, 0, 0, 90) -- Create a CJ ped nearby
    givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4
    setControlState(thePed, "fire", true) -- Make him shoot continuously
	setPedAimTarget ( thePed, x, y, z )
	setPedCameraRotation ( thePlayer, x, y, z )
end
addCommandHandler("armedped", cmdArmedPed)
		

Poderiam me ajudar, bom quero que os PED atire nos player que invadir a zona, porem o ped n pode caminhar, mas queria movesse junto com a arma para atirar ou seja que ele tivese rotação, podem me ajudar com isso ?

--serve-side

local hillArea = createColRectangle ( -715.63965, 989.01202, 15, 15 )
local hillRadar = createRadarArea ( -715.63965, 989.01202, 40, -40, 0, 255, 0, 175 )

 

Link to comment
  • Other Languages Moderators

Não consegui entender sua frase, está muito mal-formulada.

  • Você quer que o PED atire nos players que invadirem a zona.
  • O PED não pode se mover de sua posição, apenas rotacionar.
  • O PED deve mirar e atirar nos players que invadirem.

É isso?

Link to comment
16 minutes ago, Lord Henry said:

Não consegui entender sua frase, está muito mal-formulada.

  • Você quer que o PED atire nos players que invadirem a zona.
  • O PED não pode se mover de sua posição, apenas rotacionar.
  • O PED deve mirar e atirar nos players que invadirem.

É isso?

yeah, 

Link to comment
11 minutes ago, Lord Henry said:

Já tentou usar SetPedAimTarget?

yeah porem ele mira apenas no lugar que foi usado o commando, a mira não move acompanhando o player, eu modifiquei um pouco mais ainda n funciona

--Client-siide
function cmdArmedPed( command, thePlayer )
    local x, y, z = getElementPosition(localPlayer) -- Get your position
    local thePed = createPed(12,-712.21143, 942.30859, 12.34728, 0, 0, 90) -- Create a CJ ped nearby
    givePedWeapon(thePed, 31, 5000, true) -- Give him 5000 rounds of M4
    setControlState(thePed, "fire", true) -- Make him shoot continuously
	setPedAimTarget ( thePed, x, y, z )
	setPedCameraRotation ( thePlayer, x, y, z )
end
addEventHandler ( "onColShapeHit", createcol, cmdArmedPed )

function createcol ()
	triggerServerEvent ( "mission", resourceRoot )
end

server-side

function areas ()
	local hillArea = createColRectangle ( -715.63965, 989.01202, 155, 155 )
	local hillRadar = createRadarArea ( -715.63965, 989.01202, 155, -155, 0, 255, 0, 175 )
end
addEvent( "mission", true )
addEventHandler( "mission", resourceRoot, greetingHandler )

 

Edited by kevincouto6
Link to comment
On 16/06/2018 at 20:26, Lord Henry said:

 

Poderia me ajudar, Não estou conseguindo aplicar a função findRotation no script

client-side

local x1, y1 = getElementPosition( getLocalPlayer())
local x2, y2 = getElementPosition( ped )

function playerlocal ()
    local x, y, z = getElementPosition( getLocalPlayer())
end
addEventHandler ( "onClientRender", root, playerlocal )

function findRotation( x1, y1, x2, y2 ) 
    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
    return t < 0 and t + 360 or t
end

function ped1 ()
    ped = createPed(104, -2406.92749, -593.24597, 132.64844)
    givePedWeapon( ped, 31, 5000, true)
    setElementFrozen( ped, true)
    setControlState( ped, "fire", true)
    setPedRotation ( ped, findRotation )
    setPedAimTarget ( ped, playerlocal )
end
addCommandHandler("ped",ped1 )

 

Link to comment
On 18/06/2018 at 15:39, Lord Henry said:

Você pelo jeito nem leu a Wiki para tentar entender o funcionamento da função.

Isso não vai funcionar:


 setPedRotation ( ped, findRotation )

 

client-side

Olá teria como me dizer alguma outra dica, eu acho que não esta funcionando porque estou especificando apenas a localização do player, porem se eu usar a localização do ped ele da "a nill value", e a mesma coisa esta acontecendo com apenas a local do player

function onPedRender() 
local ped = getElementsByType ( "ped" ) 
    for theKey, thePed in ipairs(ped) do  
        if getElementData(thePed, "shoot") then 
            cancelEvent() 
            local x ,y, z = getElementPosition(thePed) 
            local sx, sy, sz = getElementPosition(localPlayer)
            local Dist = getDistanceBetweenPoints3D (x, y, z, sx, sy, sz)

				givePedWeapon(thePed, 31, 5000, true) 
				setPedControlState(thePed, "fire", true)
				setPedAimTarget(thePed, sx, sy, sz) 		
				setPedRotation(player, findRotation(x , y))
            end 
        end 
    end
addEventHandler("onClientRender", root, onPedRender) 
addEventHandler("onClientPedDamage", root, onPedRender) 

 

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