Jump to content

help with this :|


Sora

Recommended Posts

hey guys i made this resource it's works good but .. i added a feature to make the sound can be heard by other players

then it's works also but only works when i put the text in the script file for example

URLE = guiCreateEdit(16,72,328,38,"",false,GUIEditor_Window[1]) 

now i want to get the text that player wrote

i use

guiGetText ( URLE ) 

local URL = guiGetText ( URLE ) 

well now when i change the Edit and click at play the sound can be heard by me only

but when i change the Edit in the script file to

URLE = guiCreateEdit(16,72,328,38,"http://www.sora.x10.mx/up/cat.mp3",false,GUIEditor_Window[1]) 

the sound playing and can be heard by all

now the thing that i need is to make this sound heard by all players without wrote it in the script file

The Client Side

--[[ 
Scripted By |S.s|SoRa 
--]] 
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Window[1] = guiCreateWindow(255,131,359,185,"Play Sound From URL",false) 
guiSetVisible(GUIEditor_Window[1],false) 
guiWindowSetSizable(GUIEditor_Window[1],false) 
guiSetAlpha(GUIEditor_Window[1],1) 
URLE = guiCreateEdit(16,72,328,38,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(21,44,75,18,"Sound URL :",false,GUIEditor_Window[1]) 
GUIEditor_Label[2] = guiCreateLabel(11,116,330,20,"*  File Extensions :  mp3 , wav, ogg, riff , mod, xm, it , s3m",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0) 
PlayStop = guiCreateButton(204,140,127,36,"Play",false,GUIEditor_Window[1]) 
GUIEditor_Label[3] = guiCreateLabel(11,159,25,15,"By :",false,GUIEditor_Window[1]) 
GUIEditor_Label[4] = guiCreateLabel(37,160,101,18,"|S.s|SoRa",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[4],255,0,0) 
GUIEditor_Label[5] = guiCreateLabel(97,25,47,16,"Speed :",false,GUIEditor_Window[1]) 
sup = guiCreateButton(161,24,27,23,"+",false,GUIEditor_Window[1]) 
sdown = guiCreateButton(189,24,27,23,"-",false,GUIEditor_Window[1]) 
sn = guiCreateLabel(144,26,16,18,"0",false,GUIEditor_Window[1]) 
guiLabelSetColor(sn,0,255,0) 
GUIEditor_Label[7] = guiCreateLabel(220,26,50,18,"Volume :",false,GUIEditor_Window[1]) 
sv = guiCreateLabel(272,28,18,21,"0",false,GUIEditor_Window[1]) 
guiLabelSetColor(sv,255,255,0) 
vup = guiCreateButton(292,24,27,23,"+",false,GUIEditor_Window[1]) 
vdown = guiCreateButton(322,24,26,23,"-",false,GUIEditor_Window[1]) 
adv = guiCreateButton(9,134,70,25,"Advanced",false,GUIEditor_Window[1]) 
advwin = guiCreateWindow(331,147,237,119,"Advanced",false) 
guiSetVisible(advwin,false) 
guiSetAlpha(advwin,1) 
guiWindowSetSizable(advwin,false) 
pa = guiCreateButton(9,61,101,43,"Play to all players",false,advwin) 
close = guiCreateButton(124,61,101,43,"Close",false,advwin) 
GUIEditor_Label[1] = guiCreateLabel(7,22,211,20,"* Notice : This feature just for admins.",false,advwin) 
guiLabelSetColor(GUIEditor_Label[1],255,0,0) 
guiSetInputMode ("no_binds_when_editing") -- [[ [url=https://wiki.multitheftauto.com/wiki/GuiSetInputMode]https://wiki.multitheftauto.com/wiki/GuiSetInputMode[/url] ]] 
--[[ 
local volume = true 
local speed = true 
--]] 
local sound = true 
function onGuiClick (button, state, absoluteX, absoluteY) 
  
    if (source == PlayStop) then 
    if sound == true then 
    local URL = guiGetText ( URLE ) 
  
         sp = playSound(URL,true) 
         outputChatBox ( "Sound loading maybe take time ...", getLocalPlayer(), 255, 0, 0, true ) 
         outputChatBox ( "Sound starting !", getLocalPlayer, 255, 0, 0, true ) 
  
guiSetText(PlayStop,"Stop") 
sound = false 
  
else 
        stopSound(sp) 
guiSetText(PlayStop,"Play") 
outputChatBox ( "Sound stopped !", getLocalPlayer(), 255, 0, 0, true ) 
guiSetText(sn,"1") 
guiSetText(sv,"1") 
sound = true 
  
end 
end 
end 
  
  
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClick) 
  
  
function GuiClick (button, state, absoluteX, absoluteY) 
if (source == sup) then 
triggerServerEvent("sup",getLocalPlayer(),getRootElement()) 
elseif (source == sdown) then 
triggerServerEvent("sdown",getLocalPlayer(),getRootElement()) 
elseif (source == vup) then 
triggerServerEvent("vup",getLocalPlayer(),getRootElement()) 
elseif (source == vdown) then 
triggerServerEvent("vdown",getLocalPlayer(),getRootElement()) 
 elseif (source == adv) then 
  triggerServerEvent("check",getLocalPlayer(),getRootElement()) 
 elseif (source == pa) then 
   triggerServerEvent("sora",getLocalPlayer(),getRootElement()) 
  elseif (source == close) then 
   guiSetVisible(advwin,false) 
end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), GuiClick) 
  
  
function show() 
guiSetInputMode("no_binds_when_editing")  -- [[ [url=https://wiki.multitheftauto.com/wiki/GuiSetInputMode]https://wiki.multitheftauto.com/wiki/GuiSetInputMode[/url] ]] 
    if guiGetVisible(GUIEditor_Window[1]) == true then 
        guiSetVisible(GUIEditor_Window[1],false) 
        showCursor(false) 
    else 
        guiSetVisible(GUIEditor_Window[1],true) 
        showCursor(true) 
  
    end 
end 
addCommandHandler("su",show) 
  
addEvent("OP",true) 
addEventHandler("OP",getRootElement(), 
function () 
    guiSetVisible(advwin,true) 
    showCursor(true) 
end) 
  
addEvent("Playsora",true) 
addEventHandler("Playsora",getRootElement(), 
function () 
    if sound == true then 
    local URL = guiGetText ( URLE ) 
  
         sp = playSound(URL,true) 
  
guiSetText(pa,"Stop from all players") 
sound = false 
  
else 
        stopSound(sp) 
guiSetText(pa,"Play To all players") 
outputChatBox ( "Sound stopped !", getLocalPlayer(), 255, 0, 0, true ) 
guiSetText(sn,"1") 
guiSetText(sv,"1") 
sound = true 
end 
end) 
  
addEvent("vvup",true) 
addEventHandler("vvup",getRootElement(), 
function () 
local svol = getSoundVolume(sp)+1 
while not setSoundVolume ( sp, svol ) do svol = svol + 1 end 
guiSetText(sv,""..svol.."") 
end) 
  
addEvent("vvdown",true) 
addEventHandler("vvdown",getRootElement(), 
function () 
local svol = getSoundVolume(sp)-1 
  
 while not setSoundVolume ( sp, svol ) do svol = svol -1 
end 
  
 guiSetText(sv,""..svol.."") 
end) 
  
addEvent("ssup",true) 
addEventHandler("ssup",getRootElement(), 
function () 
local ss = getSoundSpeed(sp)+1 
  
while not setSoundSpeed ( sp, ss ) do ss = ss + 1 end 
guiSetText(sn,""..ss.."") 
end) 
  
addEvent("ssdown",true) 
addEventHandler("ssdown",getRootElement(), 
function () 
  
local ss = getSoundSpeed(sp)-1 
while not setSoundSpeed ( sp, ss ) do ss = ss - 1 end 
guiSetText(sn,""..ss.."") 
end) 

The Server Side

--[[ 
Scripted By |S.s|SoRa 
--]] 
addEvent("check",true) 
addEventHandler("check",getRootElement(), 
function () 
if ( hasObjectPermissionTo ( source, "function.kickPlayer", true ) ) then 
triggerClientEvent(source,"OP",source) 
else 
outputChatBox ( "* Access denied for advanced mode", source, 255, 0, 0, true ) 
end 
end) 
  
addEvent("sora",true) 
addEventHandler("sora",getRootElement(), 
function () 
triggerClientEvent("Playsora",getRootElement()) 
outputChatBox ( "* "..getPlayerName(source).."#ffffff Started/Stopped a sound.",getRootElement(), 255, 255, 255, true ) 
end 
) 
  
addEvent("vup",true) 
addEventHandler("vup",getRootElement(), 
function () 
triggerClientEvent("vvup",getRootElement()) 
end) 
  
addEvent("vdown",true) 
addEventHandler("vvdown",getRootElement(), 
function () 
triggerClientEvent("vvdown",getRootElement()) 
end) 
  
addEvent("sup",true) 
addEventHandler("sup",getRootElement(), 
function () 
triggerClientEvent("ssup",getRootElement()) 
end) 
  
addEvent("sdown",true) 
addEventHandler("sdown",getRootElement(), 
function () 
triggerClientEvent("ssdown",getRootElement()) 
end) 

help needed :?

Link to comment
Guest Guest4401

Ah ok, I hadn't seen this resource before so, I take back my words :oops:

--

To play a sound to every player, you must do something like this (like Kenix said)

First trigger serverside:

triggerServerEvent("anEvent",localPlayer,URL) -- url is the url of the sound which has to be played 

Then trigger to everyone:

addEvent("anEvent",true) 
addEventHandler("anEvent",root, 
    function(URL) 
        triggerClientEvent("c_playSound",root,URL) -- trigger it for everyone 
    end 
) 

addEvent("c_playSound",true) 
addEventHandler("c_playSound",root, 
    function(URL) 
        playSound(URL) -- now its played for everyone. 
    end 
) 

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