Jump to content

[BUG] Play Sound


SkiZo

Recommended Posts

Hello Everyone :D
i need some help here :) 
i'm trying to create an idea that maybe help me in my script .. 

--server side--
function Bot1 ()  

exports [ "slothBot" ]:spawnBot ( x, y, z, rotation,  skin1, intr, dims, team, wep, "hunting", true )

triggerClientEvent( root,"onBotSpawn1",root)

outputChatBox ("Bot Spawned",getRootElement(), 255, 255, 255, true )

end
--client side-- 

addEvent("onBotSpawn1",true)
addEventHandler("onBotSpawn1",root,
    function ()
        playSound(root,"BotSpawn.ogg",root)
    end
)
--XML file --

<meta>
                      
    <info author="|TN|~>Legend" description="BotScript" type="script" version="1.0.0" />
    <script src="Server.lua" type="server" />
    <script src="Client.lua" type="client" />     
    <file src="BotSpawn.ogg"/>
    <include resource="slothbot" /> 
</meta>

The Problem That the sound dont start and i need it to start to everyone ! ! Thx :D

 

Edited by Dutchman101
Fix topic title for section requirements
Link to comment
1 minute ago, Dealman said:

You're trying to execute a client-side event that is called onBotSpawn. While in your client-side script, you have added an event and a handler for that event, but it's called onBotSpawn1.

yea i fixed that the same problem :\ 

Link to comment
-- Client Side
addEvent("onBotSpawn1",true)
addEventHandler("onBotSpawn1",root,
    function ()
        playSound("BotSpawn.ogg")
    end
)

Also read this from wiki about triggerClientEvent:

Quote

Note: To save client CPU, you should avoid setting sourceElement to the root element where possible. Using resourceRoot is usually sufficient if the event is handled by the same resource on the client.

 

function Bot1 ()  
	exports [ "slothBot" ]:spawnBot ( x, y, z, rotation,  skin1, intr, dims, team, wep, "hunting", true )
	for _, player in ipairs(getElementsByType("player")) do
		triggerClientEvent( player,"onBotSpawn1",player)
	end
	outputChatBox ("Bot Spawned",getRootElement(), 255, 255, 255, true )
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...