Raised This Month: $ Target: $400
 0% 

Radio


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-25-2013 , 20:28   Radio
Reply With Quote #1

I was trying to make custom radio, but there's some bug, when I open the menu, it opened. When it was opened, I tried to open it twice and the radio played. What's wrong?
Also I tried it in LAN connection, other players can't open the menu, only the admin.

PHP Code:
#include <amxmodx>

new g_RadioTimer[33]

stock const male_radio_message_sound[8][] =
{
    
"spk radio/nice_shot.wav",
    
"spk radio/oh_yea.wav",
    
"spk radio/ct_coverme.wav",
    
"spk radio/takepoint.wav",
    
"spk radio/position.wav",
    
"spk radio/regroup.wav",
    
"spk radio/followme.wav",
    
"spk radio/fireassis.wav"
}
stock const female_radio_message_sound[8][] =
{
    
"spk radio/female/nice_shot.wav",
    
"spk radio/female/oh_yea.wav",
    
"spk radio/female/ct_coverme.wav",
    
"spk radio/female/takepoint.wav",
    
"spk radio/female/position.wav",
    
"spk radio/female/regroup.wav",
    
"spk radio/female/followme.wav",
    
"spk radio/female/fireassis.wav"
}
stock const male_radio_request_sound[8][] =
{
    
"spk radio/req_a.wav",
    
"spk radio/req_b.wav",
    
"spk radio/com_go.wav",
    
"spk radio/fallback.wav",
    
"spk radio/sticktog.wav",
    
"spk radio/com_getinpos.wav",
    
"spk radio/stormfront.wav",
    
"spk radio/com_reportin.wav"
}
stock const female_radio_request_sound[8][] =
{
    
"spk radio/female/req_a.wav",
    
"spk radio/female/req_b.wav",
    
"spk radio/female/com_go.wav",
    
"spk radio/female/fallback.wav",
    
"spk radio/female/sticktog.wav",
    
"spk radio/female/com_getinpos.wav",
    
"spk radio/female/stormfront.wav",
    
"spk radio/female/com_reportin.wav"
}
stock const radio_message[8][] =
{
    
"Nice shot!",
    
"Oh! yea",
    
"Cover me",
    
"You take point",
    
"Hold this position",
    
"Regroup team",
    
"Follow me",
    
"Taking fire. Need assistance!"
}
stock const radio_request[8][] =
{
    
"A",
    
"B",
    
"Go Go Go",
    
"Team fall back",
    
"Stick together",
    
"Get in position",
    
"Storm the front",
    
"Report in team"
}

public 
plugin_init()
{
    
register_plugin("Radio","1.1","DavidJr")
    
register_concmd("radio_team""team_message")
    
register_concmd("radio_request""team_request")
    return 
PLUGIN_CONTINUE
}
public 
plugin_precache()
{
    
precache_sound("sound/radio/req_a")
    
precache_sound("sound/radio/req_b")
    
precache_sound("sound/radio/female/req_a")
    
precache_sound("sound/radio/female/req_b")
    
precache_sound("sound/radio/nice_shot")
    
precache_sound("sound/radio/oh_yea")
    
precache_sound("sound/radio/female/nice_shot")
    
precache_sound("sound/radio/female/oh_yea")
}
public 
team_message(id)
{
    new 
menu menu_create("Team message""team_message_cmd")
    
menu_additem(menu"Nice shot!""0"// actually this 0 is set by default, you don't need to write it
    
menu_additem(menu"Oh! yea""1")
    
menu_additem(menu"Cover me""2")  
    
menu_additem(menu"You take point""3")
    
menu_additem(menu"Hold this position""4")    // Add more Options if you wish
    
menu_additem(menu"Regroup team""5")
    
menu_additem(menu"Follow me""6")
    
menu_additem(menu"Taking fire. Need assistance!""7")
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}
public 
team_message_cmd(idmenuitem)
{
    if(
menu == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
menu str_to_num(data)
    
    if(!
is_user_alive(id)) return PLUGIN_HANDLED
    
new players[32], totalteam_name[10]
    
get_user_team(idteam_name9)
    
get_players(playerstotal ,"ce"team_name)
    new 
name[32]
    
get_user_name(idname31)
    for(new 
0total; ++i)
    {
        if (
get_cvar_num("female_sound") == 1)
        {
            
client_cmd(players[i], female_radio_message_sound[menu])
        }
        else
        {
            
client_cmd(players[i], male_radio_message_sound[menu])
        }
        
client_print(players[i],print_chat,"%s (Radio): %s"nameradio_message[menu])
        
g_RadioTimer[id] = 1
        set_task
(2.0,"radio_timer",id)
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
public 
team_request(id)
{
    new 
menu menu_create("Team message""team_request_cmd")
    
menu_additem(menu"A""0"// actually this 0 is set by default, you don't need to write it
    
menu_additem(menu"B""1")
    
menu_additem(menu"Go Go Go""2")  
    
menu_additem(menu"Team fall back""3")
    
menu_additem(menu"Stick together""4")    // Add more Options if you wish
    
menu_additem(menu"Get in position""5")
    
menu_additem(menu"Storm the front""6")
    
menu_additem(menu"Report in team""7")
    
    
menu_display(idmenu0)
    return 
PLUGIN_HANDLED
}
public 
team_request_cmd(idmenuitem)
{
    if(
menu == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64], accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    
menu str_to_num(data)
    
    if(!
is_user_alive(id)) return PLUGIN_HANDLED
    
new players[32], totalteam_name[10]
    
get_user_team(idteam_name9)
    
get_players(playerstotal ,"ce"team_name)
    new 
name[32]
    
get_user_name(idname31)
    for(new 
0total; ++i)
    {
        if (
get_cvar_num("female_sound") == 1)
        {
            
client_cmd(players[i], female_radio_request_sound[menu])
        }
        else
        {
            
client_cmd(players[i], male_radio_request_sound[menu])
        }
        
client_print(players[i],print_chat,"%s (Radio): %s"nameradio_request[menu])
        
g_RadioTimer[id] = 1
        set_task
(2.0,"radio_timer",id)
    }
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}
public 
radio_timer(id)
{
    
g_RadioTimer[id] = 0
    
return PLUGIN_HANDLED
}

public 
client_connect(id)
{
    
g_RadioTimer[id] = 0

Randomize is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-26-2013 , 10:49   Re: Radio
Reply With Quote #2

You have 32 sounds to play but are only precaching 8. Why?
I also don't fully understand. Is the problem that a sound is played when you open the menu if it's already open?
__________________

Last edited by Black Rose; 07-26-2013 at 11:03.
Black Rose is offline
Old 07-26-2013, 13:21
LordOfNothing
This message has been deleted by YamiKaitou. Reason: spam
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-27-2013 , 21:19   Re: Radio
Reply With Quote #3

Because 24 sounds are already default sound, so I don't need to precache it.
Take an example, slow hack. bind z radio_message. When you press z, the menu appears, you press z again, the sound is played without choosing which one I want to use.
Randomize is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-27-2013 , 22:17   Re: Radio
Reply With Quote #4

Quote:
Originally Posted by Randomize View Post
Because 24 sounds are already default sound, so I don't need to precache it.
Take an example, slow hack. bind z radio_message. When you press z, the menu appears, you press z again, the sound is played without choosing which one I want to use.
But you don't have a command named "radio_message". Please be specific about how to reproduce the error so I can try for myself. The clearer you are, the faster I can help you.
__________________

Last edited by Black Rose; 07-27-2013 at 22:17.
Black Rose is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-28-2013 , 02:06   Re: Radio
Reply With Quote #5

Sorry, I forgot the command, I thought it was radio_message but actual command is team_message & team_request
Randomize is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-28-2013 , 09:00   Re: Radio
Reply With Quote #6

Ok, here's your problem:
Code:
if(menu == MENU_EXIT)
should be
Code:
if(item == MENU_EXIT)

You should also remove "menu_destroy(menu)" at the end of the function or it will throw a run time error.
__________________

Last edited by Black Rose; 07-28-2013 at 09:00.
Black Rose is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-28-2013 , 09:11   Re: Radio
Reply With Quote #7

Thank you Black Rose, it solved now. btw, menu can only show 7 item, can we make it 8?
Randomize is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-28-2013 , 09:25   Re: Radio
Reply With Quote #8

Quote:
Originally Posted by Randomize View Post
Thank you Black Rose, it solved now. btw, menu can only show 7 item, can we make it 8?
I've never used the new menu system myself. My guess would be that you have to use the old one to be able to customize it further.
__________________
Black Rose is offline
Randomize
BANNED
Join Date: May 2012
Location: in your heart
Old 07-28-2013 , 09:39   Re: Radio
Reply With Quote #9

Oh, I bet the old one must be difficult.
Randomize is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 07-28-2013 , 11:02   Re: Radio
Reply With Quote #10

Quote:
Originally Posted by Randomize View Post
Thank you Black Rose, it solved now. btw, menu can only show 7 item, can we make it 8?
Simply search, it is possible with new menu system.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Old 07-28-2013, 11:22
akcaliberg
This message has been deleted by akcaliberg. Reason: wrong.
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 06:24.


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