AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to change this plugin? (https://forums.alliedmods.net/showthread.php?t=159956)

Splifer 06-23-2011 16:19

How to change this plugin?
 
I want to use this plugin:
https://forums.alliedmods.net/showthread.php?t=46636

Music starts to play when player is connecting to server.
But stops when player is connected (he sees MOTD).
How do I change plugin to play Music until player Respawn OR join to team? (Without any breaks)

Here is code:

Code:

/* Loading Music (easy to use directory version)
by Andrew Penry (Andrax2000)
*/
#include <amxmodx>
#define Maxsounds 5
#define DEBUG 0

new soundlist[Maxsounds][64]
new soundCount = 0

public plugin_init() {
    register_plugin("Loading Music","0.9","Andrax2000")
    return PLUGIN_CONTINUE
}

public plugin_precache() {
        new dh
        new nameFull[64], name[64], nameExt[32]

        dh = open_dir("sound/misc/loading", nameFull, 63)

        do
    {
                strtok(nameFull,name,63,nameExt,31,'.')
                if (equali(nameExt, "mp3")) {
#if DEBUG==1
                        server_print("[AMXX LOADING MUSIC] Found %s ", nameFull)
#endif
                        soundlist[soundCount] = name
                        soundCount++
                }
        }
    while(soundCount<Maxsounds && next_file(dh, nameFull, 63))
       
    close_dir(dh)
    server_print("[AMXX LOADING MUSIC] Found %i mp3s", soundCount)
    for (new i = 0; i < soundCount; i++)
    {
        format(name, 63, "sound/misc/loading/%s.mp3",soundlist[i])
#if DEBUG==1
        server_print("[AMXX LOADING MUSIC] Precaching %s ", name)
#endif
        precache_generic(name)       
    }
    return PLUGIN_CONTINUE
}

public client_connect(id) {
    new i
    i = random_num(0,soundCount-1)
    client_cmd(id,"mp3 play sound/misc/loading/%s",soundlist[i])
    return PLUGIN_CONTINUE
}


2reason2kill 06-23-2011 17:33

Re: How to change this plugin?
 
Quote:

Originally Posted by Splifer (Post 1494363)
I want to use this plugin:
https://forums.alliedmods.net/showthread.php?t=46636

Music starts to play when player is connecting to server.
But stops when player is connected (he sees MOTD).
How do I change plugin to play Music until player Respawn OR join to team? (Without any breaks)

Here is code:

Code:

/* Loading Music (easy to use directory version)
by Andrew Penry (Andrax2000)
*/
#include <amxmodx>
#define Maxsounds 5
#define DEBUG 0

new soundlist[Maxsounds][64]
new soundCount = 0

public plugin_init() {
    register_plugin("Loading Music","0.9","Andrax2000")
    return PLUGIN_CONTINUE
}

public plugin_precache() {
        new dh
        new nameFull[64], name[64], nameExt[32]

        dh = open_dir("sound/misc/loading", nameFull, 63)

        do
    {
                strtok(nameFull,name,63,nameExt,31,'.')
                if (equali(nameExt, "mp3")) {
#if DEBUG==1
                        server_print("[AMXX LOADING MUSIC] Found %s ", nameFull)
#endif
                        soundlist[soundCount] = name
                        soundCount++
                }
        }
    while(soundCount<Maxsounds && next_file(dh, nameFull, 63))
       
    close_dir(dh)
    server_print("[AMXX LOADING MUSIC] Found %i mp3s", soundCount)
    for (new i = 0; i < soundCount; i++)
    {
        format(name, 63, "sound/misc/loading/%s.mp3",soundlist[i])
#if DEBUG==1
        server_print("[AMXX LOADING MUSIC] Precaching %s ", name)
#endif
        precache_generic(name)       
    }
    return PLUGIN_CONTINUE
}

public client_connect(id) {
    new i
    i = random_num(0,soundCount-1)
    client_cmd(id,"mp3 play sound/misc/loading/%s",soundlist[i])
    return PLUGIN_CONTINUE
}


Make a boolean?

Plox correct me If i where Wrong


Example:

PHP Code:

new bool:music[33]
public 
plugin_init()
{
       
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn"1)
}
Public 
Client_Connect (id)
{
        
music[id] = True;
}

public 
fw_PlayerSpawn (id)
{
       
music[id] = false;



Splifer 06-23-2011 19:11

Re: How to change this plugin?
 
I'm really Noob in scripting :P
Now the script looks like this:

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#define Maxsounds 10

new soundlist[Maxsounds][64]
new 
soundCount 0
new bool:music[33]

public 
plugin_init() {
    
register_plugin("Loading Music","0.9","Andrax2000")
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn"1)
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
        new 
dh
        
new nameFull[64], name[64], nameExt[32]

        
dh open_dir("sound/mindtricks"nameFull63)

        do
    {
                
strtok(nameFull,name,63,nameExt,31,'.')
                if (
equali(nameExt"mp3")) {

                        
soundlist[soundCount] = name
                        soundCount
++
                }
        }
    while(
soundCount<Maxsounds && next_file(dhnameFull63))
        
    
close_dir(dh)
    
server_print("[AMXX LOADING MUSIC] Found %i mp3s"soundCount)
    for (new 
0soundCounti++)
    {
        
format(name63"sound/mindtricks/%s.mp3",soundlist[i])
        
        
precache_generic(name)        
    }
    return 
PLUGIN_CONTINUE
}

public 
client_connect(id) {
    
music[id] = true;
    new 
i
    i 
random_num(0,soundCount-1)
    
client_cmd(id,"mp3 play sound/mindtricks/%s",soundlist[i])
    
}

public 
fw_PlayerSpawn(id) {
       
music[id] = false;


And doesn't work - of course :oops: Music stops when a player is connected.
Help please?

fysiks 06-23-2011 22:57

Re: How to change this plugin?
 
I don't think that it is possible because there is nothing in the plugin that stops the music (to remove), it is the client program (game) that stops the music on it's own.

2reason2kill 06-24-2011 04:06

Re: How to change this plugin?
 
Quote:

Originally Posted by fysiks (Post 1494604)
I don't think that it is possible because there is nothing in the plugin that stops the music (to remove), it is the client program (game) that stops the music on it's own.

You can Typ stopsound in consol is it same?

Splifer 06-24-2011 04:19

Re: How to change this plugin?
 
Hmmm... Fysiks is right, I think.
I tried to play song by console command (mp3 play) and join to server - music stops in connecting moment.

So, if it's impossible - I will change this plugin to play music after player connect to server (when player see MOTD, team choose etc.).
What command is for this event?

public client_putinserver NO...
public client_authorized NO...

// Sorry for My English !

fysiks 06-24-2011 05:22

Re: How to change this plugin?
 
putinserver is probably the closest without actually hooking the MOTD itself.

Quote:

Originally Posted by 2reason2kill (Post 1494860)
You can Typ stopsound in consol is it same?

The same as what? . . . You should probably refrain from trying to help others as your coding skill not so good.

Splifer 06-25-2011 13:16

Re: How to change this plugin?
 
This part of the code doesn't work :(

PHP Code:

public  client_putinserver(id) {
    new 
i
    i 
random_num(0,soundCount-1)
    
client_cmd(id,"mp3 play sound/mindtricks/%s",soundlist[i])
    



And full script:
PHP Code:

#include <amxmodx>
#define Maxsounds 10

new soundlist[Maxsounds][64]
new 
soundCount 0

public plugin_init() {
    
register_plugin("Loading Music","0.9","Andrax2000")
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache() {
        new 
dh
        
new nameFull[64], name[64], nameExt[32]

        
dh open_dir("sound/mindtricks"nameFull63)

        do
    {
                
strtok(nameFull,name,63,nameExt,31,'.')
                if (
equali(nameExt"mp3")) {

                        
soundlist[soundCount] = name
                        soundCount
++
                }
        }
    while(
soundCount<Maxsounds && next_file(dhnameFull63))
        
    
close_dir(dh)
    
server_print("[AMXX LOADING MUSIC] Found %i mp3s"soundCount)
    for (new 
0soundCounti++)
    {
        
format(name63"sound/mindtricks/%s.mp3",soundlist[i])
        
        
precache_generic(name)        
    }
    return 
PLUGIN_CONTINUE
}

public 
client_putinserver(id) {
    new 
i
    i 
random_num(0,soundCount-1)
    
client_cmd(id,"mp3 play sound/mindtricks/%s",soundlist[i])
    


How to change this plugin to play music when player is already on server?


All times are GMT -4. The time now is 23:26.

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