Raised This Month: $120 Target: $400
 30% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-25-2018 , 18:34   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #11

Added new code user "Celena Luna" gave me to loop the audio,but still cant get it to work.
Right now the code is set up like this:
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_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(GetSomeoneUnworthy)   
{  
  
    
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")  
    } 
}   
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 100 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,100); //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(); 

Tried the following:

:public ambience_loop()
:public ambience_loop(i)
:public ambience_loop(id)
:changing task duration to more than 50sec, audio files are exactly 50 sec long now.

Still cant find where im wrong,ill like to learn to solve it with reasoning to where im mistaken

thanks to everyone

Ed
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-26-2018 , 12:30   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #12

If thats the plugin then why not post in that plugins thread.
__________________

[MOD] CS Weapon Mod V1.7 (Report | 1.7.1 - 80%)
[MM] MetaMod-C V0.99B (Report )(1.0 - 43%)

Last edited by Ghosted; 09-26-2018 at 12:31.
Ghosted is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-26-2018 , 16:18   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #13

Already did on 09-15-18:

https://forums.alliedmods.net/showth...=42151&page=20

Nobody replied,so i continued by asking in suggestions,then someone pointed me out to ask for it on scripting help...a few users have given me some clues about how it should be written,but no one seems to give me a final fix for the code.

Also,both original creators havenīt been active for many years

https://forums.alliedmods.net/member.php?u=5648

https://forums.alliedmods.net/member.php?u=4078

I know that you all have your own interests on your own work and i respect that,but as i told earlier im not just asking for someone to help my a.. out,i want to learn how the missing part of the code that activates the loop function works on the script with the rest of the plugin so in later projects i have learned a bit more about coding.

Thanks all

Cheers!!
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-26-2018 , 16:51   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #14

If you want to loop sound for rain, there's already support for that in gamedll. This code is working.

Code:
public plugin_precache()
{
	precache_sound("ambience/rain.wav");
	
	new Entity = create_entity("ambient_generic");
	Set_KVD(Entity, "message", "ambience/rain.wav", "ambient_generic");
	Set_KVD(Entity, "spawnflags", "1", "ambient_generic");
	Set_KVD(Entity, "health", "10", "ambient_generic");
	Set_KVD(Entity, "pitch", "100", "ambient_generic");
	Set_KVD(Entity, "pitchstart", "100", "ambient_generic");
	Set_KVD(Entity, "volstart", "10", "ambient_generic");
	Set_KVD(Entity, "angles", "0 0 0", "ambient_generic");
	DispatchSpawn(Entity);
}

stock Set_KVD(EntityID, const K[], const V[], const C[])
{
	set_kvd(0, KV_ClassName, C);
	set_kvd(0, KV_KeyName, K);
	set_kvd(0, KV_Value, V);
	set_kvd(0, KV_fHandled, 0);
	
	dllfunc(DLLFunc_KeyValue, EntityID, 0);
}
__________________

[MOD] CS Weapon Mod V1.7 (Report | 1.7.1 - 80%)
[MM] MetaMod-C V0.99B (Report )(1.0 - 43%)

Last edited by Ghosted; 09-26-2018 at 17:04.
Ghosted is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 11:44   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #15

would that loop "rain.wav" sound only when event "weather_type", "1" from plugin is working or all the time even if rain is not present on map??
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-27-2018 , 11:45   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #16

Quote:
Originally Posted by chuttenjr View Post
would that loop "rain.wav" sound only when event "weather_type", "1" from plugin is working or all the time even if rain is not present on map??
It will sound all time, but you can remove entity to stop the sound.
__________________

[MOD] CS Weapon Mod V1.7 (Report | 1.7.1 - 80%)
[MM] MetaMod-C V0.99B (Report )(1.0 - 43%)
Ghosted is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 11:50   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #17

is it impossible to loop sounds "rain.wav" and "rainroof.wav" already precached on plugin??

tried adding this but did not do anything:

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")  
    } 
chuttenjr is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-27-2018 , 13:59   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #18

client_cmd(players[i], ...)
__________________
HamletEagle is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 17:05   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #19

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(players, iNum)

for(new i; i<iNum;i++)
{
client_cmd(players[i], "speak ambience/rain.wav")
client_cmd(players[i], "speak ambience/rainroof.wav")

still not working...i dont know what i am doing wrong-....
chuttenjr is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-28-2018 , 19:26   Re: Make rain sound to loop on RainySnowy (Enables CS weather) v2.0y by OneEyed & tea
Reply With Quote #20

anybody??
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 00:13.


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