Jump to content

Need help in my script


Majhol

Recommended Posts

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

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

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

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

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

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

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

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