SkiZo Posted May 28, 2017 Share Posted May 28, 2017 (edited) Hello Everyone 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 Edited May 28, 2017 by Dutchman101 Fix topic title for section requirements Link to comment
Dealman Posted May 28, 2017 Share Posted May 28, 2017 (edited) 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. Edited May 28, 2017 by Dealman 1 Link to comment
SkiZo Posted May 28, 2017 Author Share Posted May 28, 2017 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
Dealman Posted May 28, 2017 Share Posted May 28, 2017 (edited) You're misusing the playSound function, first parameter is the filepath. Make sure you read the wiki thoroughly. Edited May 28, 2017 by Dealman Link to comment
idarrr Posted May 28, 2017 Share Posted May 28, 2017 -- 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now