Gallagher Posted January 3, 2014 Posted January 3, 2014 (edited) 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 January 3, 2014 by Guest
50p Posted January 3, 2014 Posted January 3, 2014 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.
Chaos Posted January 3, 2014 Posted January 3, 2014 (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 January 3, 2014 by Guest
Gallagher Posted January 3, 2014 Author Posted January 3, 2014 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. how do I report an error? https://wiki.multitheftauto.com/wiki/CreateObject Example2 local line theObject = CreateObject (980 + x 2 + y 2, z, 0, 0, 0,) <<< 0,0,0 ","
TAPL Posted January 3, 2014 Posted January 3, 2014 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. how do I report an error? https://wiki.multitheftauto.com/wiki/CreateObject Example2 local line theObject = CreateObject (980 + x 2 + y 2, z, 0, 0, 0,) <<< 0,0,0 "," Fixed.
Gallagher Posted January 3, 2014 Author Posted January 3, 2014 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. how do I report an error? https://wiki.multitheftauto.com/wiki/CreateObject Example2 local line theObject = CreateObject (980 + x 2 + y 2, z, 0, 0, 0,) <<< 0,0,0 "," Fixed. ok
Gallagher Posted January 3, 2014 Author Posted January 3, 2014 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 )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now