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)