Raised This Month: $ Target: $400
 0% 

Need Some Scripting Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-10-2009 , 07:51   Need Some Scripting Help
Reply With Quote #1

How To make In This Plugin That when round ends and plays roundend music this music will stop playing ?

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Music Plugin"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

new listening[33]

new const music[][] = {
    "sound/Left4Dead/Songs/amb4.mp3",
    "sound/Left4Dead/Songs/amb5.mp3",
    "sound/Left4Dead/Songs/amb10.mp3",
    "sound/Left4Dead/Songs/amb6.mp3",
    "sound/Left4Dead/Songs/amb12.mp3",
    "sound/Left4Dead/Songs/amb7.mp3",
    "sound/Left4Dead/Songs/amb11.mp3",
    "sound/Left4Dead/Songs/amb8.mp3"
}

new const Float:music_lenght[] = {
    139.0,
    304.0,
    200.0,
    125.0,
    200.0,
    255.0,
    200.0,
    118.0
}

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("HLTV", "eFreezeTime", "a", "1=0", "2=0")
    
    register_clcmd("say /stop","stop")
    register_clcmd("say_team /stop","stop")
    
    register_clcmd("say /play","play")
    register_clcmd("say_team /play","play")
}

public stop(id)
{
    if(listening[id])    
    {
        client_cmd(id,"mp3 stop")  
        listening[id] = 0
        
        if(task_exists(id))
            remove_task(id)
    }
    else 
    {
        client_print(id,print_chat,"You are not listening!")
    }
}

public play(id)
{    
    if(!listening[id])
    {
        new abc = random_num(0,sizeof music - 1)
        
        client_cmd(id, "mp3 play %s", music[abc])   
        listening[id] = 1
        
        set_task(music_lenght[abc],"stop",id)
    }
    else
    {
        client_print(id,print_chat,"You are already listening!")
    }
    
}

public plugin_precache() 
{
    for(new i = 0; i < sizeof music; i++)
        precache_sound(music[i])    
}

public eFreezeTime() 
{
    client_cmd(0, "mp3 play %s", music[random_num(0,sizeof music - 1)])
} 

public client_disconnect(id)
{
    listening[id] = 0    
    
    if(task_exists(id))
            remove_task(id)
}
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-10-2009 , 08:52   Re: Need Some Scripting Help
Reply With Quote #2

Hook the roundend event and stop the mp3. See the tutos section.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-10-2009 , 09:54   Re: Need Some Scripting Help
Reply With Quote #3

Like This ?

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Music Plugin"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

new listening[33]

new const music[][] = {
    "sound/Left4Dead/Songs/amb4.mp3",
    "sound/Left4Dead/Songs/amb5.mp3",
    "sound/Left4Dead/Songs/amb10.mp3",
    "sound/Left4Dead/Songs/amb6.mp3",
    "sound/Left4Dead/Songs/amb12.mp3",
    "sound/Left4Dead/Songs/amb7.mp3",
    "sound/Left4Dead/Songs/amb11.mp3",
    "sound/Left4Dead/Songs/amb8.mp3"
}

new const Float:music_lenght[] = {
    139.0,
    304.0,
    200.0,
    125.0,
    200.0,
    255.0,
    200.0,
    118.0
}

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("HLTV", "eFreezeTime", "a", "1=0", "2=0")
    register_event("round_end", "event_end_round", "a", "1=0", "2=0")
    
    register_clcmd("say /stop","stop")
    register_clcmd("say_team /stop","stop")
    
    register_clcmd("say /play","play")
    register_clcmd("say_team /play","play")
}

public stop(id)
{
    if(listening[id])    
    {
        client_cmd(id,"mp3 stop")  
        listening[id] = 0
        
        if(task_exists(id))
            remove_task(id)
    }
    else 
    {
        client_print(id,print_chat,"You are not listening!")
    }
}

public play(id)
{    
    if(!listening[id])
    {
        new abc = random_num(0,sizeof music - 1)
        
        client_cmd(id, "mp3 play %s", music[abc])   
        listening[id] = 1
        
        set_task(music_lenght[abc],"stop",id)
    }
    else
    {
        client_print(id,print_chat,"You are already listening!")
    }
    
}

public plugin_precache() 
{
    for(new i = 0; i < sizeof music; i++)
        precache_sound(music[i])    
}

public eFreezeTime() 
{
    client_cmd(0, "mp3 play %s", music[random_num(0,sizeof music - 1)])
} 

public client_disconnect(id)
{
    listening[id] = 0    
    
    if(task_exists(id))
            remove_task(id)
}
And Whats next ?
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-10-2009 , 10:17   Re: Need Some Scripting Help
Reply With Quote #4

register_event("round_end", "event_end_round", "a", "1=0", "2=0")

It's wrong. There is an available tuto which list such events. PLEASE, search.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 03:27   Re: Need Some Scripting Help
Reply With Quote #5

i can't find it can you tell my pls ?
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-11-2009 , 04:28   Re: Need Some Scripting Help
Reply With Quote #6

No. Use your brain, please. Tutos done by VEN. SEARCH.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 04:54   Re: Need Some Scripting Help
Reply With Quote #7

Like This

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Music Plugin"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

new listening[33]

new const music[][] = {
    "sound/Left4Dead/Songs/amb4.mp3",
    "sound/Left4Dead/Songs/amb5.mp3",
    "sound/Left4Dead/Songs/amb10.mp3",
    "sound/Left4Dead/Songs/amb6.mp3",
    "sound/Left4Dead/Songs/amb12.mp3",
    "sound/Left4Dead/Songs/amb7.mp3",
    "sound/Left4Dead/Songs/amb11.mp3",
    "sound/Left4Dead/Songs/amb8.mp3"
}

new const Float:music_lenght[] = {
    139.0,
    304.0,
    200.0,
    125.0,
    200.0,
    255.0,
    200.0,
    118.0
}

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("HLTV", "eFreezeTime", "a", "1=0", "2=0")
    
    register_clcmd("say /stop","stop")
    register_clcmd("say_team /stop","stop")
    
    register_clcmd("say /play","play")
    register_clcmd("say_team /play","play")
    register_logevent("logevent_round_end", 2, "1=Round_End") 
}

public stop(id)
{
    if(listening[id])    
    {
        client_cmd(id,"mp3 stop")  
        listening[id] = 0
        
        if(task_exists(id))
            remove_task(id)
    }
    else 
    {
        client_print(id,print_chat,"You are not listening!")
    }
}

public play(id)
{    
    if(!listening[id])
    {
        new abc = random_num(0,sizeof music - 1)
        
        client_cmd(id, "mp3 play %s", music[abc])   
        listening[id] = 1
        
        set_task(music_lenght[abc],"stop",id)
    }
    else
    {
        client_print(id,print_chat,"You are already listening!")
    }
    
}

public plugin_precache() 
{
    for(new i = 0; i < sizeof music; i++)
        precache_sound(music[i])    
}

public eFreezeTime() 
{
    client_cmd(0, "mp3 play %s", music[random_num(0,sizeof music - 1)])
} 

public client_disconnect(id)
{
    listening[id] = 0    
    
    if(task_exists(id))
            remove_task(id)
}
Or Like This ?

Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Music Plugin"
#define VERSION "1.0"
#define AUTHOR "DoviuX"

new listening[33]

new const music[][] = {
    "sound/Left4Dead/Songs/amb4.mp3",
    "sound/Left4Dead/Songs/amb5.mp3",
    "sound/Left4Dead/Songs/amb10.mp3",
    "sound/Left4Dead/Songs/amb6.mp3",
    "sound/Left4Dead/Songs/amb12.mp3",
    "sound/Left4Dead/Songs/amb7.mp3",
    "sound/Left4Dead/Songs/amb11.mp3",
    "sound/Left4Dead/Songs/amb8.mp3"
}

new const Float:music_lenght[] = {
    139.0,
    304.0,
    200.0,
    125.0,
    200.0,
    255.0,
    200.0,
    118.0
}

public plugin_init() 
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("HLTV", "eFreezeTime", "a", "1=0", "2=0")
    
    register_clcmd("say /stop","stop")
    register_clcmd("say_team /stop","stop")
    
    register_clcmd("say /play","play")
    register_clcmd("say_team /play","play")
    register_logevent("EventRoundEnd", 2, "1=Round_End");
}

public stop(id)
{
    if(listening[id])    
    {
        client_cmd(id,"mp3 stop")  
        listening[id] = 0
        
        if(task_exists(id))
            remove_task(id)
    }
    else 
    {
        client_print(id,print_chat,"You are not listening!")
    }
}

public play(id)
{    
    if(!listening[id])
    {
        new abc = random_num(0,sizeof music - 1)
        
        client_cmd(id, "mp3 play %s", music[abc])   
        listening[id] = 1
        
        set_task(music_lenght[abc],"stop",id)
    }
    else
    {
        client_print(id,print_chat,"You are already listening!")
    }
    
}

public plugin_precache() 
{
    for(new i = 0; i < sizeof music; i++)
        precache_sound(music[i])    
}

public eFreezeTime() 
{
    client_cmd(0, "mp3 play %s", music[random_num(0,sizeof music - 1)])
} 

public client_disconnect(id)
{
    listening[id] = 0    
    
    if(task_exists(id))
            remove_task(id)
}
DoviuX is offline
Send a message via Skype™ to DoviuX
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 08-11-2009 , 07:43   Re: Need Some Scripting Help
Reply With Quote #8

the 2.

but TEST it & ull see which will work
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-11-2009 , 11:12   Re: Need Some Scripting Help
Reply With Quote #9

Both are the same except the callback. But anyway for both the function is not defined in the code so I don't see how it can work.
__________________
Arkshine is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 08-12-2009 , 10:20   Re: Need Some Scripting Help
Reply With Quote #10

PHP Code:
register_logevent("round_end"2"1=Round_End")

public 
round_end() {
    
//Stop the mp3

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Reply



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 18:30.


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