Raised This Month: $12 Target: $400
 3% 

Solved Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & teame06


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-23-2018 , 08:39   Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & teame06
Reply With Quote #1

im really green into this community,could someone point me on how to make the rain sound to loop on this plugin : https://forums.alliedmods.net/showthread.php?t=42151 ??
The idea is to have the sound playing and looping while player is either alive or spectating,problem is that the code as it is will only play the rain.wav( by speak commands)which lasts 50 sec or so,then it suddenly stops and leave you with a silent rain ambient .

Btw i first posted this in "requests",but i feel like this shouldnt be asked there,i only need help to add loop function to those :

g_soundstate[id] = 1;client_cmd(id, "speak ambience/rain.wav"); and rainroof.wav;

Any help is really appreciated as i already try adding some code "generalmermer" gave me but im getting 7-8 compiling errors....im hitting my head with a wall

Cheers

Eduardo


PHP Code:
#include <amxmodx>

/* Choose One */
//#include <engine>
#include <fakemeta>

#include "ojos.inc"

#define MAX_LIGHT_POINTS 3


new weather_ent
new Float:g_strikedelay
new g_lightpoints[MAX_LIGHT_POINTS]
new 
g_fxbeam;
new 
g_soundstate[33]
new 
g_maxplayers;
new 
g_stormintensity;


public 
plugin_precache() 
{
    
register_plugin("RainySnowy""2.0y""OneEyed & teame06");
    
register_cvar("rainysnowy""2.0y"FCVAR_SERVER);
    
register_cvar("weather_type""3");
    
register_cvar("weather_storm""60");
    
    
g_maxplayers get_maxplayers();
    
    new 
type get_cvar_num("weather_type");
    if(
type == 3)
        
type random_num(0,2);
        
    switch(
type) {
        case 
1
        {    
            
g_fxbeam precache_model("sprites/laserbeam.spr");
            
precache_model("models/chick.mdl");
            
precache_sound("ambience/rain.wav");
            
precache_sound("ambience/rainroof.wav");
            
precache_sound("ambience/thunder_clap.wav");
            
weather_ent CREATE_ENTITY("env_rain")
            
THINK("env_rain","WeatherSystem")
            
NEXTTHINK(weather_ent,1.0)
        }
        case 
2
        {
            
weather_ent CREATE_ENTITY("env_snow");
        }
    }    
}

public 
client_putinserver(id)
    
client_cmd(id,"cl_weather 1");    

//This is only for rain.
public WeatherSystem(entid) {
    if(
entid == weather_ent
    {
        
//Is weather_storm activated? ( 0 = OFF ) -- ( 1-100 = INTENSITY )
        
g_stormintensity get_cvar_num("weather_storm");
        
        
//Do our soundstate and picks random player.
        
new victim GetSomeoneUnworthy(); 
        
        if(
g_stormintensity
        {
            
//Is the delay up?
            
if(g_strikedelay get_gametime()) 
            {
                
//We got player to create lightning from?
                
if(victim)
                {
                    
//Do our Lightning Technique.
                    
CreateLightningPoints(victim);
                }
            }
        }
        
NEXTTHINK(weather_ent,2.0)
    }
    return 
PLUGIN_CONTINUE
}

GetSomeoneUnworthy() {
    new 
cntidtotal[33];
    for(
id=1;id<g_maxplayers;id++)
        if(
is_user_alive(id))
            if(
is_user_outside(id)) 
            {
                
total[cnt++] = id;    
                
                if(!
g_soundstate[id]) {
                    
g_soundstate[id] = 1;
                    
client_cmd(id"speak ambience/rain.wav");
                }    
            }
            else if(
g_soundstate[id]) 
            {
                
g_soundstate[id] = 0;
                
client_cmd(id"speak ambience/rainroof.wav")
            }
    
    if(
cnt)
        return 
total[random_num(0, (cnt-1))];
    return 
0;
    
}

CreateLightningPoints(victim
{
    if(
IS_VALID_ENT(g_lightpoints[0]))
        return 
0;
        
    new 
entxFloat:tVel[3];
    new 
Float:vOrig[3];
    new 
Float:mins[3] = { -1.0, -1.0, -1.0 };
    new 
Float:maxs[3] = { 1.01.01.0 };
    new 
Float:dist is_user_outside(victim)-5//Get distance to set ents at.
    
    
GET_ORIGIN(victim,vOrig)
    if(
dist 700.0) { //cap distance.
        
dist 700.0;
    }
    
vOrig[2] += dist;

    
//Create lightning bolts by spreading X entities randomly with velocity
    
for(x=0;x<MAX_LIGHT_POINTS;x++) 
    {
        
ent CREATE_ENTITY("env_sprite")
        
SET_INT(ent,movetype,MOVETYPE_FLY)
        
SET_INT(ent,solid,SOLID_TRIGGER)
        
SET_FLOAT(ent,renderamt,0.0)
        
SET_INT(ent,rendermode,kRenderTransAlpha)
        
SET_MODEL(ent,"models/chick.mdl")
        
        
SET_VECTOR(ent,mins,mins)
        
SET_VECTOR(ent,maxs,maxs)
        
tVel[0] = random_float(-500.0,500.0);
        
tVel[1] = random_float(-500.0,500.0);
        
tVel[2] = random_float((dist<=700.0?0.0:-100.0),(dist<=700.0?0.0:50.0));
        
        
SET_VECTOR(ent,origin,vOrig)
        
SET_VECTOR(ent,velocity,tVel)
        
g_lightpoints[x] = ent;
    }
    
emit_sound(entCHAN_STREAM"ambience/thunder_clap.wav"1.0ATTN_NORM0PITCH_NORM)
    
set_task(random_float(0.6,2.0),"Lightning",victim);
    return 
1;
}

// Creating a beam at each entity consecutively.
// Player has 1 in 1000 chance of getting struck !
public Lightning(victim
{
    new 
xabrand;
    new 
endpoint MAX_LIGHT_POINTS-1;
    while(
endpoint) {
        
g_lightpoints[x];
        
g_lightpoints[x+1];
        
x++
        if(
== endpoint) {
            
rand random_num(1,1000); //One unlucky son of a bish.
            
if(rand == 1) {
                
victim;
                
FAKE_DAMAGE(victim,"Lightning",100.0,1);
            }
        }
        
CreateBeam(a,b);
    }
    
    for(
x=0;x<MAX_LIGHT_POINTS;x++)
        if(
IS_VALID_ENT(g_lightpoints[x]))
            
REMOVE_ENTITY(g_lightpoints[x])
    
    
    
//Set up next lightning.
    
if(g_stormintensity 100) {
        
set_cvar_num("weather_storm"100);
        
g_stormintensity 100;    
    }
    new 
Float:mins 50.0-float(g_stormintensity/2);
    new 
Float:maxs 50.0-float(g_stormintensity/3);
    
g_strikedelay get_gametime() + random_float(minsmaxs);
}

//return distance above us to sky
Float:is_user_outside(id) {
    new 
Float:origin[3], Float:dist;
    
GET_ORIGIN(idorigin)
    
    
dist origin[2];
    
    while (
POINTCONTENTS(origin) == -1)
        
origin[2] += 5.0;

    if (
POINTCONTENTS(origin) == -6) return (origin[2]-dist);
    return 
0.0;
}

CreateBeam(entAentB)
{
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byte);
    
write_shortentA );
    
write_shortentB );
    
write_shortg_fxbeam );
    
write_byte(0);      //start frame
    
write_byte(10);     //framerate
    
write_byte(5);         //life
    
write_byte(8);      //width
    
write_byte(100);     //noise
    
write_byte(255);    //red
    
write_byte(255);    //green
    
write_byte(255);    //blue
    
write_byte(255);    //brightness
    
write_byte(10);        //scroll speed
    
message_end();


Last edited by chuttenjr; 09-29-2018 at 17:21. Reason: quote to php editing
chuttenjr is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-23-2018 , 10:46   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #2

I tried adding this line:

PHP Code:
public ambience_loop() 
{
 {
  
set_task(1.0"ambience_loop")
 }
 
 
client_cmd(1"speak ambience/rain.wav")
 
client_cmd(0"speak ambience/rainroof.wav")
 
 return 
PLUGIN_CONTINUE

after:

PHP Code:
GetSomeoneUnworthy() {
new 
cntidtotal[33];
for(
id=1;id<g_maxplayers;id++)
if(
is_user_alive(id))
if(
is_user_outside(id)) 
{
total[cnt++] = id;    

if(!
g_soundstate[id]) {
g_soundstate[id] = 1;
client_cmd(id"speak ambience/rain.wav");
}    
}
else if(
g_soundstate[id]) 
{
g_soundstate[id] = 0;
client_cmd(id"speak ambience/rainroof.wav")
}

if(
cnt)
return 
total[random_num(0, (cnt-1))];
return 
0;


but it doesnt work....

Last edited by chuttenjr; 09-23-2018 at 14:58. Reason: quote to php editing
chuttenjr is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-23-2018 , 12:23   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #3

put the code in [php] not [code] first. That will make it easier to see
__________________
My plugin:

Last edited by Celena Luna; 09-23-2018 at 12:24.
Celena Luna is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-23-2018 , 12:45   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #4

[code] tag is fine as well. He put it in [quote] for some reason.
__________________

Last edited by OciXCrom; 09-23-2018 at 12:45.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-24-2018 , 09:09   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #5

PHP Code:
public ambience_loop()  

 
    
set_task(50.0"ambience_loop"// Lasts 50s then loop after 50s

    //Go through all players
    
new players[32], iNum
    get_players
(playersiNum)

    for(new 
ii<iNum;i++)
    {
         
client_cmd(i"speak ambience/rain.wav"
         
client_cmd(i"speak ambience/rainroof.wav"
    }

__________________
My plugin:

Last edited by Celena Luna; 09-24-2018 at 09:38.
Celena Luna is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2018 , 09:22   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #6

Just set task with flag "b".
__________________








CrazY. is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-24-2018 , 09:41   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #7

flag "b" could work but fixing from his code is easier for him to understand
__________________
My plugin:
Celena Luna is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-24-2018 , 11:02   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #8

Added code,compiled ok but its not working.

code now is set like this:

PHP Code:
GetSomeoneUnworthy() {
    new 
cntidtotal[33];
    for(
id=1;id<g_maxplayers;id++)
        if(
is_user_alive(id))
            if(
is_user_outside(id)) 
            {
                
total[cnt++] = id;    
                
                if(!
g_soundstate[id]) {
                    
g_soundstate[id] = 1;
                    
client_cmd(id"speak ambience/rain.wav");
                }    
            }
            else if(
g_soundstate[id]) 
            {
                
g_soundstate[id] = 0;
                
client_cmd(id"speak ambience/rainroof.wav")
            }
    
    if(
cnt)
        return 
total[random_num(0, (cnt-1))];
    return 
0;

}
public 
ambience_loop()  

 
    
set_task(50.0"ambience_loop"// Lasts 50s then loop after 50s

    //Go through all players
    
new players[32], iNum
    get_players
(playersiNum)

    for(new 
ii<iNum;i++)
    {
         
client_cmd(i"speak ambience/rain.wav"
         
client_cmd(i"speak ambience/rainroof.wav"
    }

shouldnt ambience loop new players be "33" like new cnt in "Get Someone Unworthy"??

Thanks for all your help

Eduardo

Last edited by chuttenjr; 09-24-2018 at 11:09. Reason: sintax error
chuttenjr is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 09-24-2018 , 11:12   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #9

You haven't put ambience_loop() anywhere to run it.
Also, should be 33, I think (?)
__________________
My plugin:
Celena Luna is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-24-2018 , 11:33   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #10

PHP Code:
public ambience_loop(GetSomeoneUnworthy)  

 
    
set_task(50.0"ambience_loop"// Lasts 50s then loop after 50s

    //Go through all players
    
new players[33], iNum
"line 116" get_players(playersiNum)

    for(new 
ii<iNum;i++)
    {
         
client_cmd(i"speak ambience/rain.wav"
         
client_cmd(i"speak ambience/rainroof.wav"
    }
}  ] 
Error: Array sizes do not match, or destination array is too small on line 116
chuttenjr is offline
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 15:47.


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