AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Radio (https://forums.alliedmods.net/showthread.php?t=221741)

Randomize 07-25-2013 20:28

Radio
 
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? :shock:
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



Black Rose 07-26-2013 10:49

Re: Radio
 
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?

Randomize 07-27-2013 21:19

Re: Radio
 
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.

Black Rose 07-27-2013 22:17

Re: Radio
 
Quote:

Originally Posted by Randomize (Post 2000270)
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.

Randomize 07-28-2013 02:06

Re: Radio
 
Sorry, I forgot the command, I thought it was radio_message but actual command is team_message & team_request

Black Rose 07-28-2013 09:00

Re: Radio
 
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.

Randomize 07-28-2013 09:11

Re: Radio
 
Thank you Black Rose, it solved now. :) btw, menu can only show 7 item, can we make it 8?

Black Rose 07-28-2013 09:25

Re: Radio
 
Quote:

Originally Posted by Randomize (Post 2000550)
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.

Randomize 07-28-2013 09:39

Re: Radio
 
Oh, I bet the old one must be difficult.

bibu 07-28-2013 11:02

Re: Radio
 
Quote:

Originally Posted by Randomize (Post 2000550)
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.


All times are GMT -4. The time now is 06:24.

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