Jump to content

Tell me one command


pocko

Recommended Posts

there are examples on the wiki, you know.

  
function playMySound() 
  local sound = playSound("mySoundFile.mp3") 
end 
addCommandHandler("wtf", playMySound) 
  

dont forget that sound file should also be added to meta.xml of your resource:

  
<file src="mySoundFile.mp3" /> 
  

Link to comment

Please Help me again i have somewhere mistake :x

function AngryEmotion(player, command) 
        outputChatBox( "* "..getPlayerName(player).." is angry", getRootElement(), 255, 0, 255, true ) 
  
end 
  
addCommandHandler("angry", AngryEmotion) 
  
function angry() 
  local sound = angry("sounds/angry.mp3") 
end 
addCommandHandler("angry", angry) 

Link to comment
function AngryEmotion(command) 
  outputChatBox( "* "..getPlayerName(getLocalPlayer()).." is angry", 255, 0, 255, true ) 
  angry() 
end 
addCommandHandler("angry", AngryEmotion) 
  
function angry() 
  local sound = playSound("sounds/angry.mp3") --typo 
end 

Since it is a client-side, no one will see your message. If you want to output your message to everyone, you should add a server side event and trigger it when you type /angry. So the final result will be:

--client 
function AngryEmotion(command) 
  triggerServerEvent( "onAngry", getLocalPlayer() ) 
  angry() 
end 
addCommandHandler("angry", AngryEmotion) 
  
function angry() 
  local sound = playSound("sounds/angry.mp3") 
end 
  
--server 
addEvent( "onAngry", true ) 
addEventHandler( "onAngry", root, function() 
  outputChatBox( "* "..getPlayerName(source).." is angry", root, 255, 0, 255, true ) 
end ) 

Edited by Guest
Link to comment

well you should try to understand.

--client 
addEvent( "onAngry", true ) 
addEventHandler( "onAngry", root, function() 
  local sound = playSound("sounds/angry.mp3")  
end ) 
  
--server 
function AngryEmotion(player, command) 
  outputChatBox( "* "..getPlayerName(player).." is angry", root, 255, 0, 255, true ) 
  triggerClientEvent("onAngry", root) -- this will trigger onAngry event for all players. 
end 
addCommandHandler("angry", AngryEmotion) 

Link to comment

hey i start to make a new emotion and write this !The text is showing but the sound can t :x please help me again and tell me where i making the problem :x

Client: 
function GoodbyeEmotion(command) 
  triggerServerEvent( "onbye", getLocalPlayer() ) 
end 
addCommandHandler("bb", GoodbyeEmotion) 
  
addEvent( "onbye", true ) 
addEventHandler( "onbye", root, function() 
  local sound = playSound("sound/goodbuy.mp3") 
end ) 
  
Server 
addEvent( "onbye", true ) 
addEventHandler( "onbye", root, function() 
  outputChatBox( "* "..getPlayerName(source).." said: Goodbye all", root, 255, 0, 255, true ) 
end ) 
  
function GoodbyeEmotions(player, command) 
   triggerClientEvent("onbye", root) 
end 
addCommandHandler("bb", GoodbyeEmotion) 

Link to comment

why didn't you copy Aiboforcen's code?

--client 
addEvent( "onBye", true ) 
addEventHandler( "onBye", root, function() 
  local sound = playSound("sounds/goodbuy.mp3") 
end ) 
  
--server 
function ByeEmotion(player, command) 
  outputChatBox( "* "..getPlayerName(player).."said: Goodbye all", root, 255, 0, 255, true ) 
  triggerClientEvent("onBye", root) 
end 
addCommandHandler("bye", ByeEmotion) 

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