Raised This Month: $ Target: $400
 0% 

Play Music (when connect & ingame)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CS-A-Roland
Member
Join Date: Jul 2009
Old 07-14-2012 , 16:04   Play Music (when connect & ingame)
Reply With Quote #1

Hey guy's

Need a Plugin wich plays sound/musik if i connect, and then in the game also. With mp3, adjustable volume and with no restrictions about the MB of the file itself.

I found one but the creator seems to be away since a longer time so nobody work on it. Good time to learn i think...

The Code
Code:
//Loading Music Also In Spectator Mode
//by Torch
//MP3 ONLY
//Copy MP3 file to sound/misc/loading.mp3
//Music will still play after the player has joined server until he chooses a team.
//Music will start playing again if the person goes back to spectator mode
//(not DEAD spectator, only Team Select>Spectator)

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

new bool:playing[32]

public plugin_init() {
    register_plugin("Loading Song","1.0","Torch")
    register_event( "ResetHUD", "song","b" )
    register_event("TextMsg","song","b","2&#Spec_Mode")
    for (new i=0;i<32;i++)
    {
        playing[i]=false
    }
    return PLUGIN_CONTINUE
}

public plugin_precache() {
    precache_sound("misc/loading.mp3")
    return PLUGIN_CONTINUE
}

public client_connect(id) {
    play_song(id)
    return PLUGIN_CONTINUE
}

public play_song(id) {
    client_cmd(id,"mp3 loop sound/misc/loading.mp3")
    return PLUGIN_HANDLED
}

public play_song_task(params[],id) {
    new player = params[0]
    client_cmd(player,"mp3 loop sound/misc/loading.mp3")
    return PLUGIN_HANDLED
}

public song(id) {
    new CsTeams:team
    team = cs_get_user_team(id)

    if ((team==CS_TEAM_SPECTATOR)||(team==CS_TEAM_UNASSIGNED))
    {
        if (playing[id]==false)
        {
            new params[1]
            params[0]=id
            set_task(0.5,"play_song_task",0,params,1,"a",1)
            playing[id]=true
        }
    }
    else
    {
            client_cmd(id,"mp3 stop")
            playing[id]=false
    }
    return PLUGIN_CONTINUE
}
Questions about:
Is it right that when i wish to change the volume ive turn this here:
Code:
set_task(0.5,"play_song_task",0,params,1,"a",1)
to this here?!:
Code:
set_task(0.8,"play_song_task",0,params,1,"a",1)
And if i want to use more Sounds ive turn this here:
Code:
public plugin_precache() {
    precache_sound("misc/loading.mp3")
    return PLUGIN_CONTINUE
}

public client_connect(id) {
    play_song(id)
    return PLUGIN_CONTINUE
}

public play_song(id) {
    client_cmd(id,"mp3 loop sound/misc/loading.mp3")
    return PLUGIN_HANDLED
}

public play_song_task(params[],id) {
    new player = params[0]
    client_cmd(player,"mp3 loop sound/misc/loading.mp3")
    return PLUGIN_HANDLED
}

into this:
Code:
public plugin_precache() {
    precache_sound("misc/mysounds/one.mp3")
    precache_sound("misc/mysounds/two.mp3")
    precache_sound("misc/mysounds/three.mp3")
    return PLUGIN_CONTINUE
}

public client_connect(id) {
    play_song(id)
    return PLUGIN_CONTINUE
}

public play_song(id) {
    client_cmd(id,"mp3 loop sound/misc/mysounds/*s.mp3")
    return PLUGIN_HANDLED
}

public play_song_task(params[],id) {
    new player = params[0]
    client_cmd(player,"mp3 loop sound/misc/mysounds/*s.mp3")
    return PLUGIN_HANDLED
}
I dont know it can work, i just made my first test with coding a plugin...
The next question is, i think there is needed a command to loop one song coincident. If i connect maybe it will play sound 3 or at a mapchange then sound 5 (if so much sounds exist)

Next Question iss, where i can find setting teams wich can hear it?!
The plugin uses Spec and unassigned players but i will use it for all...

Thanks for everyone who help! ;)
__________________
oOOOoooh it's www.Cs-Attack.de
New World of Warcraft Mod Beta 0.5(based on WC3FT 3.5)
Counterstrike 1.6 SERVER:
Server IP: 193.192.58.154:27200

CONDITION ZERO SERVER:
Server IP: 193.192.58.154:27016
CS-A-Roland is offline
MokeN
Senior Member
Join Date: Jan 2012
Location: Vaasa, Finland
Old 07-17-2012 , 14:11   Re: Play Music (when connect & ingame)
Reply With Quote #2

Use PHP wraps instead of Code ;)
__________________
Private Works:
- Achievements, HNS & JB Menus, HNS & JB Shops

mY BlockMaker - mY Steam - mY Game Menu

Last edited by MokeN; 07-17-2012 at 14:14.
MokeN is offline
Send a message via Skype™ to MokeN
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 07-17-2012 , 14:21   Re: Play Music (when connect & ingame)
Reply With Quote #3

Quote:
Originally Posted by MokeN View Post
Use PHP wraps instead of Code ;)
He can use whatever he wants, there is no requirement

Quote:
Is it right that when i wish to change the volume ive turn this here
No, you tell the client to turn up their volume

Quote:
And if i want to use more Sounds ive turn this here
Nope, a client can only hear one mp3 at a time
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
CS-A-Roland
Member
Join Date: Jul 2009
Old 07-17-2012 , 17:29   Re: Play Music (when connect & ingame)
Reply With Quote #4

Can closed... deledet or whatever! Works for me...
Yami i hope you had fun! ;)
__________________
oOOOoooh it's www.Cs-Attack.de
New World of Warcraft Mod Beta 0.5(based on WC3FT 3.5)
Counterstrike 1.6 SERVER:
Server IP: 193.192.58.154:27200

CONDITION ZERO SERVER:
Server IP: 193.192.58.154:27016
CS-A-Roland is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode