Monument Posted May 31, 2021 Posted May 31, 2021 hello i want make when player press b create object forward player and can all players see it
Tekken Posted May 31, 2021 Posted May 31, 2021 Hi, for that you will need the following functions: bindKey createObject attachElements (maybe?) and you have to do it in server side to assure others will see it! Good luck, and if you need help we’re here!
Monument Posted June 1, 2021 Author Posted June 1, 2021 15 hours ago, Tekken said: Hi, for that you will need the following functions: bindKey createObject attachElements (maybe?) and you have to do it in server side to assure others will see it! Good luck, and if you need help we’re here! i mean get forward position for player how ?
SpecT Posted June 1, 2021 Posted June 1, 2021 There are a few threads on the forum with the same subject. Don't be shy to use the search feature! Here is what I found which might be the answer for you (not written by me): function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end
Monument Posted June 1, 2021 Author Posted June 1, 2021 2 hours ago, SpecT said: There are a few threads on the forum with the same subject. Don't be shy to use the search feature! Here is what I found which might be the answer for you (not written by me): function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end i have seen all topics but i don't know what argument to setElementPosition Use in your Code use posX,posY,posZ Right ?
Tekken Posted June 1, 2021 Posted June 1, 2021 function getPositionInfrontOfElement ( element , meters ) if not element or not isElement ( element ) then return false end if not meters then meters = 3 end local posX , posY , posZ = getElementPosition ( element ) local _ , _ , rotation = getElementRotation ( element ) posX = posX - math.sin ( math.rad ( rotation ) ) * meters posY = posY + math.cos ( math.rad ( rotation ) ) * meters return posX , posY , posZ end Use it like that: local fx, fy, fz = getPositionInfrontOfElement(player, 5); -- get the x,y,z positions 5 meters in front of player! createObject(OBJECTID, fx, fy, fz); Remember getPositionInfrontOfElement is a useful function so you will have to paste the code above in order to work!
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