AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Music player with menu (https://forums.alliedmods.net/showthread.php?t=25839)

Timoses 03-21-2006 12:28

Music player with menu
 
1 Attachment(s)
Hi guys!

I'm trying to make a menu which opens up if you say /buy in front of a tv
in bar in the map shaunsville_b5v7.
The menu is working and stuff.
But if I now choose one of the songs it doesn't play.
is emit_sound the only way to play sounds?
I guess I can't use it the way I used it there.

And can I play the songs from like one point? like in the center of a room?
(with coordinates some how?) or maybe with 2 points ( so you actually have
2 sound boxes) or even 3 or 4 boxes?

Here's what I got:

Code:
public bar_play_music(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 6) return PLUGIN_HANDLED     if(key == 0) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/austin2.mp3", 1.0, ATTN_NORM, 0, PITCH_NORM)     if(key == 1) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/coldasice.mp3", 1.0, ATTN_NORM, 0, PITCH_NORM)     if(key == 2) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/gman.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     if(key == 3) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/jskil.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     if(key == 4) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/pulp.mp3", 1.0, ATTN_NORM, 0, PITCH_NORM)     if(key == 5) emit_sound(id, CHAN_ITEM, "Pimplordz/Music/whatislove.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)     bar_play_music_show(id)     return PLUGIN_HANDLED }

If you need more of the code then tell me. Hope this time somebody will
reply o.o ;)

The whole code ..

Code:
public tv_bar_guess(id) {     new body[256]     new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)     new len = format(body,sizeof(body),"Bar TV + Music Player^n")     len += format(body[len],sizeof(body)-len,"---------------------------------------^n")     len += format(body[len],sizeof(body)-len,"              .%i.%i.%i.%i.%i.        ^n",bar_guesscode[id][0],bar_guesscode[id][1],bar_guesscode[id][2],bar_guesscode[id][3],bar_guesscode[id][4])     len += format(body[len],sizeof(body)-len,"---------------------------------------^n")     add(body,sizeof(body),"^n0. Exit^n")     show_menu(id,key,body)     return PLUGIN_HANDLED } public action_bar_guess(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 9) return PLUGIN_HANDLED         for(new i = 0;i < 5;i++) {  // Search for the specific slot and set value         if(bar_guesscode[id][i] == 0) {         bar_guesscode[id][i] = key+1         break         }     }         if(bar_guesscode[id][4] != 0)   // If last number then show menu     {         if(bar_guesscode[id][0] == bar_rightpass[0] && bar_guesscode[id][1] == bar_rightpass[1] && bar_guesscode[id][2] == bar_rightpass[2] && bar_guesscode[id][3] == bar_rightpass[3] && bar_guesscode[id][4] == bar_rightpass[4]) bar_menu(id)         else {             for(new i = 0;i < 5;i++) {             bar_guesscode[id][i] = 0             }         }         return PLUGIN_HANDLED     }     else                // If NOT last then reshow menu     {         tv_bar_guess(id)         return PLUGIN_HANDLED     }     return PLUGIN_HANDLED } public bar_menu(id) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     client_print(id,print_chat,"[LaptopMod] Correct Code!")     for(new i = 0;i < 5;i++) {         leet_guesscode[id][i] = 0     }         new body[256]     new key = (1<<0|1<<9)     new len = format(body,sizeof(body),"Music Player Menu^n")         add(body,sizeof(body),"^n1. Music Player^n")     add(body,sizeof(body),"^n0. Close Menu^n")     show_menu(id,key,body)     return PLUGIN_HANDLED } public action_bar_menu(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 9) return PLUGIN_HANDLED     if(key == 0) bar_play_music_show(id)     return PLUGIN_HANDLED } public bar_play_music_show(id) {     new body[256]     new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)     new len = format(body,sizeof(body),"Music Player^n^n")     add(body,sizeof(body),"1. Austin Powers^n")     add(body,sizeof(body),"2. Will Smith - Switch^n")     add(body,sizeof(body),"3. Happy Music o.o^n")     add(body,sizeof(body),"4. Sad Music :(^n")     add(body,sizeof(body),"5. Pulp Fiction^n")     add(body,sizeof(body),"6. What is love?")     add(body,sizeof(body),"^n0. Close Menu^n")     show_menu(id,key,body)     return PLUGIN_HANDLED } public bar_play_music(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 6) return PLUGIN_HANDLED     if(key == 0) console_cmd(id,"play Pimplordz/Music/gman.wav")     if(key == 1) console_cmd(0,"play Pimplordz/Music/gman.wav")     if(key == 2) console_cmd(id,"play Pimplordz/Music/gman.wav")     if(key == 3) console_cmd(0,"play Pimplordz/Music/gman.wav")     if(key == 4)     if(key == 5)     bar_play_music_show(id)     return PLUGIN_HANDLED }

Rixorster 03-21-2006 13:51

Code:
client_cmd(0,"spk ^"Pimplordz/Music/austin2.mp3^"")

Timoses 03-21-2006 14:09

That doesn't work :s
And would it play the sound for all players around it in a certain distance?
btw. I am using amx version 1.01 for TSRP Harbu RP plugin.

v3x 03-21-2006 14:47

The *new* menu system is sexy :)

Rixorster 03-21-2006 14:48

Hmm, it should work >_<
Ill edit this post if i find working one >_>
(WHY YOU PEOPLE GIVE ME - KARMA, WHAT HAVE I DONE WRONG? :( )

Timoses 03-21-2006 15:14

or do I maybe have to do it like

Code:
if(key == 0) {           emit_sound(id, CHAN_AUTO, "Pimplordz/Music/austin2.mp3", 1.0, ATTN_NORM, 0, PITCH_NORM) } //or with the client_cmd if(key == 1) {            client_cmd(0,"spk ^"Pimplordz/Music/austin2.mp3^"") } // are mp3 files possible at all? // and does the sound play for people around this guy also? // and about that that the sound should appear from like an origin or 2 origings o.o //got so many questions arrgh.

organizedKaoS 03-21-2006 17:12

Quote:

Originally Posted by Rixorster
Code:
client_cmd(0,"spk ^"Pimplordz/Music/austin2.mp3^"")

Not the correct way to play mp3's in half-life.

I dont believe you can use mp3's in emit sound. You might have to find another route :cry: :cry:

[ --<-@ ] Black Rose 03-22-2006 01:19

think its like
Code:
client_cmd(id, "mp3 play Pimplordz/Music/austin2.mp3")

organizedKaoS 03-22-2006 02:21

Quote:

Originally Posted by [ --<-@
Black Rose]think its like
Code:
client_cmd(id, "mp3 play Pimplordz/Music/austin2.mp3")

Absolutely correct. mp3 play then the entire file directory. BUT, the mp3 file must be at least inside the sound folder.

Timoses 03-22-2006 09:35

It doesn't work!!!
Code:
public bar_play_music(id,key) {     if(!is_user_alive(id)) return PLUGIN_HANDLED     new origin[3]     get_user_origin(id,origin)     if(get_distance(origin,bar_tv) > 25.0) return PLUGIN_HANDLED     if(key == 6) return PLUGIN_HANDLED     if(key == 0) client(id, "mp3 play Pimplordz/Music/austin2.mp3")     if(key == 1) client_cmd(id,"play Pimplordz/Music/gman.wav")     if(key == 2) client_cmd(id, "play Pimplordz/Music/gman.wav")     if(key == 3) client_cmd(id," play Pimplordz/Music/gman.wav")     if(key == 4) client_cmd(id, " play Pimplordz/Music/gman.wav")     if(key == 5)     bar_play_music_show(id)     return PLUGIN_HANDLED }

I think something is wrong with the if clauses.
Because if I put this

Code:
public bar_play_music_show(id) {     new body[256]     new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)     new len = format(body,sizeof(body),"Music Player^n^n")     add(body,sizeof(body),"1. Austin Powers^n")     add(body,sizeof(body),"2. Will Smith - Switch^n")     add(body,sizeof(body),"3. Happy Music o.o^n")     add(body,sizeof(body),"4. Sad Music :(^n")     add(body,sizeof(body),"5. Pulp Fiction^n")     add(body,sizeof(body),"6. What is love?")     add(body,sizeof(body),"^n0. Close Menu^n")     client_cmd(id, "play Pimplordz/Music/gman.wav")      //here I put the command                                                                                     //if I open the menu "Music Player" then the sound plays!     show_menu(id,key,body)     return PLUGIN_HANDLED }


All times are GMT -4. The time now is 16:47.

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