Jump to content

voice command problem,not the whole server hears it


xTravax

Recommended Posts

Hi

I've made some script for fun by just copying the examples from wiki and text command script and this is how it looks like

function startMySound() 
    sound = playSound( "snw.mp3", true ) 
end 
addCommandHandler ( "snw", startMySound ) 
  
function makeTrain(commandname) 
        outputChatBox ( "ALERT!", 255, 0, 0) 
        outputChatBox ( "ALERT!", 255, 0, 0) 
        outputChatBox ( "ALERT!", 255, 0, 0) 
        outputChatBox ( "ALERT!", 255, 0, 0) 
        outputChatBox ( "System has occurred an error", 255, 0, 0) 
        outputChatBox ( "Starting Protocol 1541-56-a", 255, 100, 250) 
        outputChatBox ( "Recovery in 30 secs...", 0, 255, 0) 
        outputChatBox ( "Emergency Shut Down...", 255, 255, 255) 
        outputChatBox ( "SERVER REBOOT IN in 30 secs...", 0, 255, 0) 
        outputChatBox ( "HOLD OOOOOOOOOOON!", 0, 255, 0) 
end 
addCommandHandler("snw", makeTrain) 

the problem is if i use that /snw command only me will be able to hear that but i want that every player in server hears that sound

i need that incase im rebooting the server to uinform people to come back when it removes because some people don't speak english but i believe that alarm sound would meant something to non english people.

Link to comment

ummm

i don't know to do this i tried visiting wiki to see more about that but i don't understand scripting so well and i made a big mistake because i simply don't know how should i make this work because i don't know to script and when i try to learn to script atleast for a bit i have to learn 6 lines on my mind and i dont know where does it teach me when can i use each event function or whatever so i can't learn it :/

so here is my big mistake can someone please correct it for me because it's hard for me to learn scripting

function startMySound() 
    triggerClientEvent ( "onSound", getRootElement(), "playSound" ) 
    sound = playSound( "snw.mp3", true ) 
end 
addCommandHandler ( "snw", startMySound ) 
  
function makeTrain(commandname) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "System has occurred an error", 255, 0, 0) 
    outputChatBox ( "Starting Protocol 1541-56-a", 255, 100, 250) 
    outputChatBox ( "Recovery in 30 secs...", 0, 255, 0) 
    outputChatBox ( "Emergency Shut Down...", 255, 255, 255) 
    outputChatBox ( "SERVER REBOOT IN in 30 secs...", 0, 255, 0) 
    outputChatBox ( "HOLD OOOOOOOOOOON!", 0, 255, 0) 
end 
addCommandHandler("snw", makeTrain) 

Edited by Guest
Link to comment

Server side:

addCommandHandler ( "snw", function() -- adding a command handler on the server side 
    triggerClientEvent ( "onSound", root) -- triggering to client side for all players (root) with the eventname "onSound" 
end)-- and end ofc, with ) [for closing the function] 

Client side:

  
addEvent ( "onSound", true ) -- adding the event 
addEventHandler ( "onSound", root, -- making the event handler 
function() -- the fuction 
    sound = playSound( "snw.mp3", true ) -- the sound 
makeTrain() -- this will execute the makeTrain() function 
end) -- the end 
  
  
function makeTrain() -- your stuff 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "ALERT!", 255, 0, 0) 
    outputChatBox ( "System is under Attack!", 255, 0, 0) 
    outputChatBox ( "Starting Protocol 1541-56-a", 255, 100, 250) 
    outputChatBox ( "Recovery in 30 secs...", 0, 255, 0) 
    outputChatBox ( "Emergency Shut Down...", 255, 255, 255) 
    outputChatBox ( "SERVER REBOOT IN in 30 secs...", 0, 255, 0) 
    outputChatBox ( "HOLD OOOOOOOOOOON!", 0, 255, 0) 
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...