Jump to content

shield ajuda


Gallagher

Recommended Posts

Posted (edited)

:cry:

Why not work?

I want to create a gate near the ped.

function pedLoad ( name ) 
  
   local x, y, z = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) 
       local theObject = createObject ( 980, x, y, z, 0, 0, 0,) 
      attachElements ( trader, 0, 0, 5 ) 
       
end 
addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) 

I am one an idea of making a shield as the player is shooting, then how can I adapt it?

When I press mouse2 the object is attachElements (theObject, theplayer, 0, -0.5, -0.1),

and when I drop the object is mouse2 attachElements (theObject, theplayer, 0, 0, -5)

bindKey("mouse2", "both",

function consoleCreateObject ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer )  
     
      local theObject = createObject ( 1337, x + 2, y + 2, z, 0, 0, 0) 
      setElementAlpha( theObject, 0) 
      attachElements ( theObject, thePlayer, 0, -0.5, -0.1 ) 
      if ( theObject ) then  
         outputConsole ( "shield", thePlayer ) 
      else 
         outputConsole ( "fail", thePlayer ) 
      end 
   end 
end 
addCommandHandler ( "shield", consoleCreateObject ) 

Edited by Guest
Posted

createPed does NOT return coords of where it was created. Also, always check the debug window and I'm sure you will find the answer to most of your questions.

Posted (edited)

Try this

function pedLoad () 
  
   local ped = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) 
     local x, y, z = getElementPosition ( ped ) 
       local theObject = createObject ( 980, x, y, z, 0, 0, 0) 
      attachElements (theObject, ped, 0, 0, 5 ) 
       
end 
addEventHandler ( "onResourceStart", getResourceRootElement(), pedLoad ) 

Edited by Guest
Posted

I am one an idea of making a shield as the player is shooting, then how can I adapt it?

When I press mouse2 the object is attachElements (theObject, theplayer, 0, -0.5, -0.1),

and when I drop the object is mouse2 attachElements (theObject, theplayer, 0, 0, -5)

bindKey("mouse2", "both",

function consoleCreateObject ( thePlayer, commandName ) 
   if ( thePlayer ) then 
      local x, y, z = getElementPosition ( thePlayer )  
     
      local theObject = createObject ( 1337, x + 2, y + 2, z, 0, 0, 0) 
      setElementAlpha( theObject, 0) 
      attachElements ( theObject, thePlayer, 0, -0.5, -0.1 ) 
      if ( theObject ) then  
         outputConsole ( "shield", thePlayer ) 
      else 
         outputConsole ( "fail", thePlayer ) 
      end 
   end 
end 
addCommandHandler ( "shield", consoleCreateObject ) 

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