Majhol Posted July 13, 2013 Share Posted July 13, 2013 Hi everybody I need help in making this script when they hit the marker the ped set the animation I guess I did everything but it's not working can anybody help me out this is my code local pepsi= createObject(955, 1463.5, -2206, 12.5, 0, 0, 0) local marker= createMarker(1464.3000488281, -2208.1000976563, 13.5, "cylinder", 1, 255, 255, 255, 0) function givePepsi () local Everyoneusergroup = getAccountName(getPlayerAccount(psource)) if isObjectInACLGroup("user."..Everyoneusergroup, aclGetGroup("Everyone")) then setPedAnimation(localplayer, "VEND_Drink_P ", "animation1") end end addEventHandler("onMarkerHit", marker, givePepsi) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartup) meta.xml "B7raani" type="script" version="1.1.0" /> Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 can u help me in making it without getting aclgroup I used aclgroup because I I don't know other way to use it without getaclgroup can u now help me with making it without gettingaclgroup Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 local pepsi= createObject(955, 1463.5, -2206, 12.5, 0, 0, 0) local marker= createMarker(1464.3000488281, -2208.1000976563, 13.5, "cylinder", 1, 255, 255, 255, 0) addEventHandler("onClientMarkerHit", marker, function ( hitPlayer, matchingDimension ) if ( isElementWithinMarker(hitPlayer, marker) ) then setPedAnimation(localplayer, "VEND_Drink_P ", "animation1") end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartup) this is my new code but the object is not showing and it is not working can u help me out Link to comment
iPrestege Posted July 13, 2013 Share Posted July 13, 2013 local pepsi = createObject( 955, 1463.5, -2206, 12.5, 0, 0, 0 ) local marker = createMarker( 1464.3000488281, -2208.1000976563, 13.5, "cylinder", 1, 255, 255, 255, 0 ) function givePepsi ( psource ) if getElementType ( psource ) == "player" then if isObjectInACLGroup( "user."..getAccountName ( getPlayerAccount ( psource ) ), aclGetGroup( "Everyone" ) ) then setPedAnimation( psource, "VENDING", "VEND_Drink_P" ) outputChatBox ( 'Anim Start' ) end end end addEventHandler("onMarkerHit", marker, givePepsi) Try this. Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 guys how can iset a timer to it now It is working perfectly but he keeps drinking I want him to drink once Link to comment
iPrestege Posted July 13, 2013 Share Posted July 13, 2013 You mean if you hit the marker again you don't want to anim the player? Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 can u guys help me in this attachElementToBone(kb_beer,player,MarkerHit1,1463.541015625,-2207.1723632813,13.546875,0,0,0) this is the code where it attach an object to the player I tried my best to do it I want it when it hit the marker they give him a beer in his hand but it is not working anybody can help me out? Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 That's because is not a native MTA function, is exported from "bone_attach" resource ( make sure you have it and is running ), you must do it this way: exports [ "bone_attach" ]:attachElementToBone(kb_beer,player,MarkerHit1,1463.541015625,-2207.1723632813,13.546875,0,0,0) Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 I used your code and it is on the bone_attach mod but still not working Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 local pepsi = createObject( 955, 1463.5, -2206, 12.5, 0, 0, 0 ) local myMarker1 = createMarker( 1463.4791259766, -2207.4919433594, 13.546875, "cylinder", 1, 255, 255, 0, 170 ) function MarkerHit1( player, matchingDimension ) takePlayerMoney ( player, tonumber(150) ) setPedAnimation( player, "VENDING", "VEND_Drink_P", -1, true, false, true ) setTimer(function () setPedAnimation ( player, nil, nil) end,1300,1, true) outputChatBox( "لقد استعدت قوتك", player, 255, 0, 0 ) setPedRotation ( player, 0 ) setElementHealth ( player, 100 ) exports [ "bone_attach" ]:attachElementToBone(kb_beer,player,MarkerHit1,1463.541015625,-2207.1723632813,13.546875,0,0,0) end addEventHandler( "onMarkerHit", myMarker1, MarkerHit1 ) Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 this is the instruction attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz) : attaches element to the bone of the ped. Server and client function. element : Element which you want to attach. ped : Ped or player which you want to attach element to. bone : Bone which you want to attach element to. x,y,z : Position offset from the bone. rx,ry,rz : Rotation offset from the bone. Returns true if element was successfully attached, false otherwise. Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 kb_beer is the element I guess Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 No, you need to create the object with createObject. Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 I did it local pepsi = createObject( 955, 1463.5, -2206, 12.5, 0, 0, 0 ) local myMarker1 = createMarker( 1463.4791259766, -2207.4919433594, 13.546875, "cylinder", 1, 255, 255, 0, 170 ) local kb_beer = createObject( 1950, 1463.5, -2206, 12.5, 0, 0, 0 ) function MarkerHit1( player, matchingDimension ) takePlayerMoney ( player, tonumber(150) ) setPedAnimation( player, "VENDING", "VEND_Drink_P", -1, true, false, true ) setTimer(function () setPedAnimation ( player, nil, nil) end,1300,1, true) outputChatBox( "لقد استعدت قوتك", player, 255, 0, 0 ) setPedRotation ( player, 0 ) setElementHealth ( player, 100 ) exports [ "bone_attach" ]:attachElementToBone(kb_beer,player,MarkerHit1,1463.541015625,-2207.1723632813,13.546875,0,0,0) end addEventHandler( "onMarkerHit", myMarker1, MarkerHit1 ) still nothing Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 Remove "MarkerHit1" from attachElementToBone. Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 done exports [ "bone_attach" ]:attachElementToBone(kb_beer,player,1463.541015625,-2207.1723632813,13.546875,0,0,0) end sorry I know disturbed you a lot but cause I'm beginner anyway still not working the beer is not showing up in his hand Link to comment
iMr.3a[Z]eF Posted July 13, 2013 Share Posted July 13, 2013 Are you starting the bone_attach resource while you are using this exported function? Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 You aren't using offsets, you are using 3D world coordinates, change these: 1463.541015625,-2207.1723632813,13.546875 to something else. Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 To offsets, experiment, try with 0 on all of these, if that doesn't fit, change them. exports [ "bone_attach" ]:attachElementToBone(kb_beer,player,0,0,0,0,0,0) Link to comment
Majhol Posted July 13, 2013 Author Share Posted July 13, 2013 doesn't work , can u give me a hint to change to what exactly which number? Link to comment
Castillo Posted July 13, 2013 Share Posted July 13, 2013 0,0,0,0,0,0 First: Offset XSecond: Offset Y Third: Offset Z Four: Rotation X Five: Rotation Y Six: Rotation Z Link to comment
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