AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin crashing server (https://forums.alliedmods.net/showthread.php?t=299172)

InteX01 07-05-2017 18:33

Plugin crashing server
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define PLUGIN "SoundMenu"
#define VERSION "v1.0"
#define AUTHOR "InteX"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_soundmenu""soundmenu"ADMIN_RCON"- otvara se menu slican speech meniju.")
}

public 
plugin_precache()
{
    
precache_sound("soundmenu/championsleague.mp3")
    
precache_sound("soundmenu/bashenga.mp3")
    
precache_sound("soundmenu/waka.mp3")
    
precache_sound("soundmenu/moja_vila.mp3")
    
precache_sound("soundmenu/ego.mp3")
    
precache_sound("soundmenu/gadafi.mp3")
}

public 
settask(id)
{
    
set_task(0.1"soundmenu")
}
public 
soundmenu(idlevelcid){
    if(!
cmd_access(idlevelcid1))
    return 
PLUGIN_HANDLED
    
new menu menu_create("\wSoundMenu v1.0\y by InteX""sound_meni");
    
menu_additem(menu"\yZaustavi muziku");
    
menu_additem(menu"Champions League");
    
menu_additem(menu"Vivo - Bashenga");
    
menu_additem(menu"Vivo - Waka");
    
menu_additem(menu"Juice - Moja Vila")
    
menu_additem(menu"Milan Stankovic - Ego")
    
menu_additem(menu"Maus Maki - Gadafi")
    
menu_display(idmenu);
    return 
PLUGIN_HANDLED
}
public 
sound_meni(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu);
        return 
PLUGIN_CONTINUE;
    }
    
    new 
dst[33]
    
get_user_name(iddstcharsmax(dst))
    
    switch(
item)
    {
        case 
0:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je zaustavio muziku."dst)
            
client_cmd(0,"mp3 stop")
            
settask(id)
        }
        case 
1:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 pustio pesmu ^4'Champions League Anthem'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/championsleague.mp3")
            
settask(id)
        }
        case 
2:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je pustio pesmu ^4'Vivo - Bashenga'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/bashenga.mp3")
            
settask(id)
        }
        case 
3:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je pustio pesmu ^4'Vivo - Waka'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/waka.mp3")
            
settask(id)
        }
        case 
4:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je pustio pesmu ^4'Juice - Moja Vila'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/moja_vila.mp3")
            
settask(id)
        }
        case 
5:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je pustio pesmu ^4'Milan Stankovic - Ego'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/ego.mp3")
            
settask(id)
        }
        case 
6:
        {
            
ColorChat(0TEAM_COLOR"^4[MILF-JB]^1 Admin^3 %s^1 je pustio pesmu ^4'Maus Maki - Gadafi'"dst)
            
client_cmd(0,"mp3 play sound/soundmenu/gadafi.mp3")
            
settask(id)
        }

    }
    return 
PLUGIN_CONTINUE;


Why is this plugin crashing my server, everytime i play any music.

CrazY. 07-05-2017 19:30

Re: Plugin crashing server
 
I think you don't need use "set_task" to show menu.

When you're precaching .mp3 SOUND, I think you need add sound/...example.mp3.

Example: precache_sound("sound/soundmenu/gadafi.mp3")

InteX01 07-05-2017 19:34

Re: Plugin crashing server
 
It plays... .. But what causes server to crash :o :/ ?

wickedd 07-05-2017 20:19

Re: Plugin crashing server
 
Use precache_generic( ) for Mp3 files. Plus, try adding the "sound/" to the path.

PHP Code:

precache_generic"sound/soundmenu/championsleague.mp3" 


Natsheh 07-06-2017 09:26

Re: Plugin crashing server
 
set_task(0.1, "soundmenu")

:arrow:
set_task(0.1, "soundmenu", id)


Destroy the menu in the handler fwd if you are recreating it..
And always return plugin handled in menu handler forward..

SpawnerF 07-06-2017 09:54

Re: Plugin crashing server
 
Why did you even used set_task? I'm pretty sure that calling the function directly is more faster than set_task ...
You are showing a menu not passing a parameter to an object( player or whatever ) don't use
(id, level, cid) use (id) and to check the admin flag use get_user_flags(id) & ADMIN_RCON ...


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

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