Shuvit Posted June 5, 2013 Posted June 5, 2013 Hey, I've tried to add the function of moveObject. When i use the command "/placespeaker" while sitting in the car, it will bug. So i tried to move it to the back of the car, but it seems that it does'nt work. It does'nt give any errors or warnings in the debugscript. Could anyone help me? Best regards, Shuvit. -- Server Side function createSpeaker(thePlayer) local x, y, z = getElementPosition(thePlayer) speakerObject = createObject(2232, x, y, z-0. outputChatBox("You have Succesfully created a speaker!", thePlayer, 0, 250, 0) if (isPedInVehicle(thePlayer)) then local vehicle = getPedOccupiedVehicle(thePlayer) local origX, origY, origZ = getElementPosition ( speakerObject ) local newY = origY + 3 moveObject ( speakerObject, 0, origX, newY, origZ ) attachElements(speakerObject, vehicle) triggerClientEvent(root, "playTheSound", root, x, y, z, vehicle) else triggerClientEvent(root, "playTheSound", root, x, y, z) end end addCommandHandler("placespeaker", createSpeaker) function deleteSpeaker(thePlayer) if (isElement(speakerObject)) then destroyElement(speakerObject) outputChatBox("You have Succesfully destroyed the Speaker!", thePlayer, 0, 0, 255) triggerClientEvent("stopTheSound", root) else outputChatBox("Speaker is not created!", thePlayer, 250, 0, 0) end end addCommandHandler("destroyspeaker", deleteSpeaker)
Moderators IIYAMA Posted June 5, 2013 Moderators Posted June 5, 2013 try: local x, y, z = getElementPosition(getPedOccupiedVehicle (thePlayer) or thePlayer)
Shuvit Posted June 6, 2013 Author Posted June 6, 2013 What do you mean by "it'll bug"? By placing the speaker, it will bug into the player that is driving. By slowing down the car, your cam will be bugged into the speaker.
DakiLLa Posted June 6, 2013 Posted June 6, 2013 Try to disable its collisions with setElementCollisionsEnabled
Moderators IIYAMA Posted June 6, 2013 Moderators Posted June 6, 2013 You can also create offset. --syntax attachElements ( element theElement, element theAttachToElement, [ float xPosOffset, float yPosOffset, float zPosOffset, float xRotOffset, float yRotOffset, float zRotOffset ] ) -- try attachElements(speakerObject, vehicle,2,0,0) and no, moveObject doesn't work when the object is attached.
Shuvit Posted June 6, 2013 Author Posted June 6, 2013 You can also create offset. --syntax attachElements ( element theElement, element theAttachToElement, [ float xPosOffset, float yPosOffset, float zPosOffset, float xRotOffset, float yRotOffset, float zRotOffset ] ) -- try attachElements(speakerObject, vehicle,2,0,0) and no, moveObject doesn't work when the object is attached. WARNING: 3d_musicspeakers\server.lua:6: Bad argument @'attachElements' [Expected element at argument 2, got nil] Any suggestions to fix that?
Castillo Posted June 6, 2013 Posted June 6, 2013 Try to disable its collisions with setElementCollisionsEnabled That should work.
Shuvit Posted June 6, 2013 Author Posted June 6, 2013 full code? I accidently pressed spacebar once, the function was correct, setElementCollisionsEnabled worked. Thanks a lot!
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