MACIEKW89 Posted October 21, 2013 Share Posted October 21, 2013 Witam! Zrobiłem kod na ustawianie barierki niedaleko gracza. Jak zrobić, aby ta barierka zawsze ustawiała się przed graczem? function CreateBarrier ( thePlayer ) if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local theObject = createObject ( 1228, x, y + 2, z - 0.7, 0, 0, 0) if ( theObject ) then outputConsole ( "Stworzono barierkę.", thePlayer ) else outputConsole ( "Nie można stworzyć barierki.", thePlayer ) end end end addCommandHandler ( "barierka", CreateBarrier ) Link to comment
Wojak Posted October 22, 2013 Share Posted October 22, 2013 Nie testowane (funkcja getPointFromDistanceRotation z tąd: https://wiki.multitheftauto.com/wiki/Ge ... ceRotation) function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end function CreateBarrier ( thePlayer ) local odleglosc = 2 if ( thePlayer ) then local x, y, z = getElementPosition ( thePlayer ) local _,_,rotz = getElementRotation(thePlayer) x,y = getPointFromDistanceRotation(x, y, odleglosc, rotz) local theObject = createObject ( 1228, x, y , z - 0.7, 0, 0, 0) -- tutaj zamiast ostatniego 0 chyba tez rotz if ( theObject ) then outputConsole ( "Stworzono barierkę.", thePlayer ) else outputConsole ( "Nie można stworzyć barierki.", thePlayer ) end end end addCommandHandler ( "barierka", CreateBarrier ) 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