Jump to content

Music when Player joins the Server?


Recommended Posts

I'm wondering if it would be possible to make a script where when you join a Server it plays a song, It would be great fun to see if it works, I'm just not sure if its Possible. The Track i would use is only 1.04mins so it wouldn't be too hefty a DL

Here's what I have so far, It wont play when I connect though so I'm not sure what to do

function onPlayerSpawn ( theSpawnpoint, theTeam )
local sound = playSound("sound/intro.mp3",[ bool looped = false ] )
setSoundVolume(sound, 0.5)
end
addEventHandler ( "onPlayerSpawn", getRootElement(), onPlayerSpawn )

<meta>
<info author="Spike" version="1.0.0" type="script" 
description="" />
<script src="spwnsound.lua" type="client"/>
 
 
<file src="sound/intro.mp3" />
 
</meta>

Can anyone Help please?

Link to comment

ok, first error i see is that you using as event "onPlayerSpawn" and that even is only server side and your code its client so i suggets you to use triggerClientEvent to play the song.

also

[ bool looped = false? wth is this? there u just put "false" or "true"

Link to comment
ok, first error i see is that you using as event "onPlayerSpawn" and that even is only server side and your code its client so i suggets you to use triggerClientEvent to play the song.

also

[ bool looped = false? wth is this? there u just put "false" or "true"

Thanks for a quit response, I have tried what you suggested and it hasn't seemed to work the script currently looks like:

function onPlayerSpawn ( theSpawnpoint, theTeam )
local sound = playSound("sound/intro.mp3",false)
setSoundVolume(sound, 0.5)
end
addEventHandler ( "triggerClientEvent", getRootElement(), onPlayerSpawn )

Link to comment

omg.. get back to basics..

btw: onPlayerSpawn will be fired EVERY RESPAWN, not on join.

and you added handler for triggerClientEvent ?

total mess!!

re-read about scripting again. scripting is not using random words. computer wouldnt understand that

edit:

you can use this resource if you want to play sound for one local player on join (not on spawn!)

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