Jump to content

Problem with the 3D Musicspeaker


Shuvit

Recommended Posts

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) 

Link to comment
  • Moderators

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.

Link to comment
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?

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