Hallo liebe community,
Ich habe einen schript ( der nicht von mir ist da ich 0 scirpten kann) und meine bitte wäre, könnte den einer von euch für mich zusammen stellen ich weiß nicht wo ich einen abstand setzen soll und wo nicht. Ich habe einen eigenen Server und würde gerne bissl Musik spielen.
Ich wäre für jede hilfe dankbar.
Lua
------------------------------------------
-- Author: xXMADEXx --
-- Name: 3D Speakers 2.0 --
-- File: client.lua --
-- Copywrite 2013 ( C ) Braydon Davis --
------------------------------------------
-- Decompile Security --
sec = {{{{{{},{},{},{}}}}}} --
------------------------------
-- Variables --
------------------------------
local subTrackOnSoundDown = 0.1 -- The volume that goes down, when the player clicks "Volume -"
local subTrackOnSoundUp = 0.1 -- The volume that goes up, when the player clicks "Volume +"
------------------------------
-- The GUI --
------------------------------
local rx, ry = guiGetScreenSize ( )
button = { }
window = guiCreateWindow( ( rx - 295 ), ( ry / 2 - 253 / 2 ), 293, 253, "Speakers", false)
guiWindowSetSizable(window, false)
guiSetVisible ( window, false )
CurrentSpeaker = guiCreateLabel(8, 33, 254, 17, "Do you have a currently have a speaker: No", false, window)
volume = guiCreateLabel(10, 50, 252, 17, "Current Volume: 100%", false, window)
pos = guiCreateLabel(10, 66, 252, 15, "X: 0 | Y: 0 | Z: 0", false, window)
guiCreateLabel(11, 81, 251, 15, "URL:", false, window)
url = guiCreateEdit(11, 96, 272, 23, "", false, window)
--url = guiCreateEdit(11, 96, 272, 23, "http://roscripts.netau.net/sound.mp3", false, window) -- (This link may not work, by the time you get the script)
button["place"] = guiCreateButton(9, 129, 274, 20, "Create Speaker", false, window)
button["remove"] = guiCreateButton(9, 159, 274, 20, "Destroy Speaker", false, window)
button["v-"] = guiCreateButton(9, 189, 128, 20, "Volume -", false, window)
button["v+"] = guiCreateButton(155, 189, 128, 20, "Volume +", false, window)
button["close"] = guiCreateButton(9, 219, 274, 20, "Exit", false, window)
--------------------------
-- My sweet codes --
--------------------------
local isSound = false
addEvent ( "onPlayerViewSpeakerManagment", true )
addEventHandler ( "onPlayerViewSpeakerManagment", root, function ( current )
local toState = not guiGetVisible ( window )
guiSetVisible ( window, toState )
showCursor ( toState )
if ( toState == true ) then
guiSetInputMode ( "no_binds_when_editing" )
local x, y, z = getElementPosition ( localPlayer )
guiSetText ( pos, "X: "..math.floor ( x ).." | Y: "..math.floor ( y ).." | Z: "..math.floor ( z ) )
if ( current ) then guiSetText ( CurrentSpeaker, "Do you currently have a speaker: Yes" ) isSound = true
else guiSetText ( CurrentSpeaker, "Do you currently have a speaker: No" ) end
end
end )
addEventHandler ( "onClientGUIClick", root, function ( )
if ( source == button["close"] ) then
guiSetVisible ( window, false )
showCursor ( false )
elseif ( source == button["place"] ) then
if ( isURL ( ) ) then
triggerServerEvent ( "onPlayerPlaceSpeakerBox", localPlayer, guiGetText ( url ), isPedInVehicle ( localPlayer ) )
guiSetText ( CurrentSpeaker, "Do you currently have a speaker: Yes" )
isSound = true
guiSetText ( volume, "Current Volume: 100%" )
else
outputChatBox ( "You need to enter a URL.", 255, 0, 0 )
end
elseif ( source == button["remove"] ) then
triggerServerEvent ( "onPlayerDestroySpeakerBox", localPlayer )
guiSetText ( CurrentSpeaker, "Do you currently have a speaker: No" )
isSound = false
guiSetText ( volume, "Current Volume: 100%" )
elseif ( source == button["v-"] ) then
if ( isSound ) then
local toVol = math.round ( getSoundVolume ( speakerSound [ localPlayer ] ) - subTrackOnSoundDown, 2 )
if ( toVol > 0.0 ) then
outputChatBox ( "Volume set to "..math.floor ( toVol * 100 ).."%!", 0, 255, 0 )
triggerServerEvent ( "onPlayerChangeSpeakerBoxVolume", localPlayer, toVol )
guiSetText ( volume, "Current Volume: "..math.floor ( toVol * 100 ).."%" )
else
outputChatBox ( "The volume cannot go any lower.", 255, 0, 0 )
end
end
elseif ( source == button["v+"] ) then
if ( isSound ) then
local toVol = math.round ( getSoundVolume ( speakerSound [ localPlayer ] ) + subTrackOnSoundUp, 2 )
if ( toVol < 1.1 ) then
outputChatBox ( "Volume set to "..math.floor ( toVol * 100 ).."%!", 0, 255, 0 )
triggerServerEvent ( "onPlayerChangeSpeakerBoxVolume", localPlayer, toVol )
guiSetText ( volume, "Current Volume: "..math.floor ( toVol * 100 ).."%" )
else
outputChatBox ( "The volume cannot go any higher.", 255, 0, 0 )
end
end
end
end )
speakerSound = { }
addEvent ( "onPlayerStartSpeakerBoxSound", true )
addEventHandler ( "onPlayerStartSpeakerBoxSound", root, function ( who, url, isCar )
if ( isElement ( speakerSound [ who ] ) ) then destroyElement ( speakerSound [ who ] ) end
local x, y, z = getElementPosition ( who )
speakerSound [ who ] = playSound3D ( url, x, y, z, true )
setSoundVolume ( speakerSound [ who ], 1 )
setSoundMinDistance ( speakerSound [ who ], 13 )
setSoundMaxDistance ( speakerSound [ who ], 18 )
local int = getElementInterior ( who )
setElementInterior ( speakerSound [ who ], int )
setElementDimension ( speakerSound [ who ], getElementDimension ( who ) )
if ( isCar ) then
local car = getPedOccupiedVehicle ( who )
attachElements ( speakerSound [ who ], car, 0, 5, 3 )
end
end )
addEvent ( "onPlayerDestroySpeakerBox", true )
addEventHandler ( "onPlayerDestroySpeakerBox", root, function ( who )
if ( isElement ( speakerSound [ who ] ) ) then
destroyElement ( speakerSound [ who ] )
end
end )
--------------------------
-- Volume --
--------------------------
addEvent ( "onPlayerChangeSpeakerBoxVolumeC", true )
addEventHandler ( "onPlayerChangeSpeakerBoxVolumeC", root, function ( who, vol )
if ( isElement ( speakerSound [ who ] ) ) then
setSoundVolume ( speakerSound [ who ], tonumber ( vol ) )
end
end )
function isURL ( )
if ( guiGetText ( url ) ~= "" ) then
return true
else
return false
end
end
function math.round(number, decimals, method)
decimals = decimals or 0
local factor = 10 ^ decimals
if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end
Alles anzeigen