Jump to content

Dar arma para ped


Recommended Posts

oi, eu estava a tentar criar este seguinte script. Mas ainda sou iniciante em script ...

Ja tentei varias formas e atualmente estou com esta.. O objetivo era o Ped1 ficar a disparar para uma tal posição. (238.79436, 1863.61792, 20.07644)

Se me poderem ajudar ..

  --Client side-- 
Ped1 = createPed(0, -56.77341, 2083.91870, 33.67812) 
setElementDimension(Ped1,10)     
setPedControlState(Ped1,"fire",true) 
setPedControlState(Ped1,"aim_weapon",true)   
triggerServerEvent ( "ondararma", resourceRoot, "" ) 
setPedAimTarget(Ped1, 238.79436, 1863.61792, 20.07644) 
  
function cancelPedDamage1() 
    cancelEvent()  
end 
addEventHandler("onClientPedDamage", Ped1, cancelPedDamage1) 
  

--Server side-- 
  
function armaped() 
setTimer( giveWeapon, 100, 1, Ped1, 31, 900, true) 
end 
addEvent( "ondararma", true ) 
addEventHandler( "ondararma", resourceRoot, armaped)  
  
  

Link to comment

tente ai parsa

--Client side-- 
Ped1 = createPed(0, -56.77341, 2083.91870, 33.67812) 
setElementDimension(Ped1,10)    
setPedControlState(Ped1,"fire",true) 
--setPedControlState(Ped1,"aim_weapon",true)  
triggerServerEvent ( "ondararma", resourceRoot, Ped1 ) 
setPedAimTarget(Ped1, 238.79436, 1863.61792, 20.07644) 
  
function cancelPedDamage1() 
    cancelEvent() 
end 
addEventHandler("onClientPedDamage", Ped1, cancelPedDamage1) 
  
--server 
function armaped(ped) 
setTimer( giveWeapon, 100, 1, ped, 31, 900, true) 
end 
addEvent( "ondararma", true ) 
addEventHandler( "ondararma", resourceRoot, armaped) 

Link to comment

ok tente denovo

--Client side-- 
local Ped1 = createPed(0, -56.77341, 2083.91870, 33.67812) 
setElementDimension(Ped1,10)   
setPedControlState(Ped1,"fire",true) 
triggerServerEvent ("ondararma", resourceRoot, Ped1 ) 
setPedAimTarget(Ped1, 238.79436, 1863.61792, 20.07644) 
  
function cancelPedDamage1() 
    cancelEvent() 
end 
addEventHandler("onClientPedDamage", Ped1, cancelPedDamage1) 
  
--server 
function armaped(ped) 
giveWeapon(ped, 31, 900, true) 
end 
addEvent( "ondararma", true ) 
addEventHandler( "ondararma", resourceRoot, armaped) 

Link to comment

Tenta criando o ped no lado server.

Tente isto:

Client

addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        triggerServerEvent("onClientCall", resourceRoot) 
    end 
) 
  
addEvent("doPedAttack", true) 
addEventHandler( "doPedAttack", root, 
    function (thePed) 
        setPedControlState(thePed,"fire",true) 
        setPedAimTarget(thePed, 238.79436, 1863.61792, 20.07644) 
    end 
) 
  
addEventHandler( "onClientElementDataChange", root, 
    function (dataName, oldValue) 
        if (dataName == "cancelPedDamage") then 
            local ped = getElementData(source, "cancelPedDamage") 
            addEventHandler("onClientPedDamage", ped, cancelEvent) 
        end 
    end 
) 

Server

function createThePed() 
    local Ped1 = createPed(0, -56.77341, 2083.91870, 33.67812) 
    setElementDimension(Ped1,10) 
    setElementData(Ped1, "cancelPedDamage", Ped1) 
    giveWeapon(Ped1, 31, 900, true) 
    triggerClientEvent(root, "doPedAttack", Ped1) 
end 
addEvent( "onClientCall", true ) 
addEventHandler( "onClientCall", root, createThePed) 

Link to comment

Porque eu passei o ped como fonte do evento e não como um argumento.

Tente isto:

addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        triggerServerEvent("onClientCall", resourceRoot) 
    end 
) 
  
addEvent("doPedAttack", true) 
addEventHandler( "doPedAttack", root, 
    function() 
        setPedControlState(source,"fire",true) 
        setPedAimTarget(source, 238.79436, 1863.61792, 20.07644) 
    end 
) 
  
addEventHandler( "onClientElementDataChange", root, 
    function (dataName, oldValue) 
        if (dataName == "cancelPedDamage") then 
            local ped = getElementData(source, "cancelPedDamage") 
            addEventHandler("onClientPedDamage", ped, cancelEvent) 
        end 
    end 
) 

Link to comment
  • 4 years later...
On 24/07/2014 at 02:12, DNL291 said:

Server


function createThePed() 
    local Ped1 = createPed(0, -56.77341, 2083.91870, 33.67812) 
    setElementDimension(Ped1,10) 
    setElementData(Ped1, "cancelPedDamage", Ped1) 
    giveWeapon(Ped1, 31, 900, true) 
    triggerClientEvent(root, "doPedAttack", Ped1) 
end 
addEvent( "onClientCall", true ) 
addEventHandler( "onClientCall", root, createThePed) 
 

Client:

On 25/07/2014 at 04:08, DNL291 said:

 


addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        triggerServerEvent("onClientCall", resourceRoot) 
    end 
) 
  
addEvent("doPedAttack", true) 
addEventHandler( "doPedAttack", root, 
    function() 
        setPedControlState(source,"fire",true) 
        setPedAimTarget(source, 238.79436, 1863.61792, 20.07644) 
    end 
) 
  
addEventHandler( "onClientElementDataChange", root, 
    function (dataName, oldValue) 
        if (dataName == "cancelPedDamage") then 
            local ped = getElementData(source, "cancelPedDamage") 
            addEventHandler("onClientPedDamage", ped, cancelEvent) 
        end 
    end 
) 
 

No meta vai esses dois, o server e o client.

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