Rockstar23 Posted June 22, 2010 Share Posted June 22, 2010 So I was wanting make it so when someone joined it would play a sound saying "User Joined" and anytime someone joins, the sound does not play. addEventHandler("onPlayerJoin", root, function() playerData = {} playerData.mode = 1; if mode == 1 then local joined = playSound("sounds/joined.wav") setSoundVolume(joined, 1) end outputChatBox('Welcome to our server', source, 0, 255, 0) outputChatBox('Your current mode is: '..modeName(playerData.mode)..'.', source, 0, 255, 0) end ) Link to comment
Dark Dragon Posted June 22, 2010 Share Posted June 22, 2010 you are mixing up server side events and client side functions. in this case changing the event to the client side equivalent "onClientPlayerJoin" should work (you'll still need to change the script file type to "client" in the meta.xml), however you need to change the chat outputs then. you can use onClientResourceStart for that, if you use this you need to remove the source argument Link to comment
MaddDogg Posted June 22, 2010 Share Posted June 22, 2010 In addition to that, I also don't really get these lines: playerData = {} playerData.mode = 1; if mode == 1 then First of all, mode will probably be nil, you have to use playerData.mode within your if clause. Also, it doesn't make much sense, because you just set a variable to a value and then check, if the variable has this exact same value. That will always return true, so there is no need for the if clause. Link to comment
Rockstar23 Posted June 22, 2010 Author Share Posted June 22, 2010 In addition to that, I also don't really get these lines: playerData = {} playerData.mode = 1; if mode == 1 then First of all, mode will probably be nil, you have to use playerData.mode within your if clause. Also, it doesn't make much sense, because you just set a variable to a value and then check, if the variable has this exact same value. That will always return true, so there is no need for the if clause. Well actually I have a few commands that let you change the mode so it will check if there mode is 1 so then it will send them the message because mode 1 is freeroam and 2 is roleplaying 3 is racing. Link to comment
MaddDogg Posted June 22, 2010 Share Posted June 22, 2010 So, mode and playerData.mode are two different things? Then I'm sorry, my mistake I thought that you wanted to check the same variable you just created at that point. 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