Raised This Month: $ Target: $400
 0% 

Solved "Force" rain or snow?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GasmoN
Member
Join Date: Jul 2014
Old 09-09-2018 , 09:15   "Force" rain or snow?
Reply With Quote #1

Is it possible to make rain with command AFTER map is loaded?
For example, I change the map and currently there is no rain, then I type amx_start_rain and now rain starts to fall.
Also, if I type amx_stop_rain rain will stop to fall.

Last edited by GasmoN; 09-09-2018 at 17:51.
GasmoN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-09-2018 , 09:18   Re: "Force" rain or snow?
Reply With Quote #2

§earch
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
GasmoN
Member
Join Date: Jul 2014
Old 09-09-2018 , 11:17   Re: "Force" rain or snow?
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Thanks but I won't us it anyway becouse I can't unregister think with 1.8.2 version of amx mod x.

Last edited by GasmoN; 09-09-2018 at 11:18.
GasmoN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-09-2018 , 11:29   Re: "Force" rain or snow?
Reply With Quote #4

Quote:
Originally Posted by GasmoN View Post
Thanks but I won't us it anyway becouse I can't unregister think with 1.8.2 version of amx mod x.
You can replace with fakemeta or ham which has support to unhook/disabling.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 09-09-2018 , 13:23   Re: "Force" rain or snow?
Reply With Quote #5

Simply update to 1.9.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
GasmoN
Member
Join Date: Jul 2014
Old 09-09-2018 , 13:24   Re: "Force" rain or snow?
Reply With Quote #6

I tried and it's only play sound, but there is no rain.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <engine>
#include <fakemeta>

#define PLUGIN "[SC] Weather System"
#define VERSION "1.0"
#define AUTHOR "."

#define MAX_LIGHT_POINTS 3
#define SET_FLOAT(%1,%2,%3)        set_pev(%1,pev_%2,%3)
#define NEXTTHINK(%1,%2)    SET_FLOAT(%1,nextthink,get_gametime()+%2)
#define IS_VALID_ENT(%1)    is_valid_ent(%1)
#define GET_ORIGIN(%1,%2)    GET_VECTOR(%1,origin,%2)
#define GET_VECTOR(%1,%2,%3)    entity_get_vector(%1,EV_VEC_%2,%3)
#define SET_INT(%1,%2,%3)       set_pev(%1,pev_%2,%3)
#define SET_MODEL(%1,%2)    entity_set_model(%1,%2)
#define SET_VECTOR(%1,%2,%3)     set_pev(%1,pev_%2,%3) 
#define POINTCONTENTS(%1)    point_contents(%1)
#define DISPATCH_KEYVALUE(%1,%2,%3)    DispatchKeyValue(%1,%2,%3) 
#define MDLL_SPAWN(%1)            dllfunc(DLLFunc_Spawn,%1)
#define SET_STRING(%1,%2,%3)    set_pev(%1,pev_%2,%3)
#define FAKE_TOUCH(%1,%2)        dllfunc(DLLFunc_Touch,%1,%2)

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

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /rain""cmd_rain")
    
register_clcmd("say /srain""cmd_srain")
    
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
g_fxbeam precache_model("sprites/laserbeam.spr");
    
precache_model("models/chick.mdl");
    
precache_sound("ambience/rain.wav");    
}

public 
cmd_srain()
{
    
DisableHamForward(g_Think)
    
remove_entity(weather_ent)
}

public 
cmd_rain()
{
    
weather_ent create_entity("env_rain")
    
g_Think RegisterHam(Ham_Think"env_rain""think_rain")
    
NEXTTHINK(weather_ent,1.0)    
    
EnableHamForward(g_Think)
}

public 
think_rain(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 NULL")
            }
    
    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;
}

stock FAKE_DAMAGE(idvictim,szClassname[],Float:takedmgdamage,damagetype)
{
    new 
entity create_entity("trigger_hurt")
    if (
entity)
    {
        new 
szDamage[16]
        
format(szDamage,15,"%f",takedmgdamage 2)
        
DISPATCH_KEYVALUE(entity,"dmg",szDamage)
        
format(szDamage,15,"%i",damagetype)
        
DISPATCH_KEYVALUE(entity,"damagetype",szDamage)
        
MDLL_SPAWN(entity)
        
SET_STRING(entity,classname,szClassname)
        
FAKE_TOUCH(entity,idvictim)
        
remove_entity(entity)
        return 
1
    
}
    return 
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();

@OciXCrom
Quote:
Originally Posted by GasmoN View Post
Thanks but I won't us it anyway becouse I can't unregister think with 1.8.2 version of amx mod x.
I see that you didn't undrestood what that message means. That message means that I DON'T WANT to update to 1.9 (reason is not important at all) so now when you know what that means, I will kindly ask you to post here only if you know how to help me, otherwise you are not helping me at all, thanks.

Last edited by GasmoN; 09-09-2018 at 13:34.
GasmoN is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-09-2018 , 14:04   Re: "Force" rain or snow?
Reply With Quote #7

Wait if you are removing the entity, then hooking it wont be a problem with register_think, it will never be called if you are hooking it with a specified entity classname which is env_rain if its nolonger existed.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-09-2018 at 14:05.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
GasmoN
Member
Join Date: Jul 2014
Old 09-09-2018 , 15:53   Re: "Force" rain or snow?
Reply With Quote #8

But I first create it and then hook it, the trick is that when I create entity the rain doesn't fall at all.
It's only work when I create rain entitny in plugin_precache but I don't need that.
I need to start and stop rain with console command so that code is my fail try to do that. Can you explain me how can I make this?
GasmoN is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-09-2018 , 15:59   Re: "Force" rain or snow?
Reply With Quote #9

ReceiveW is message which informs client about rain/snow, you can hook updateclientdata and send this message (size is 1 byte (1=rain/2=snow)) (Code from regamedll (what a poor code they use UTIL_FindEntityByClassname in UpdateClientData...))
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 09-09-2018 at 16:03.
Ghosted is offline
GasmoN
Member
Join Date: Jul 2014
Old 09-09-2018 , 16:04   Re: "Force" rain or snow?
Reply With Quote #10

Quote:
Originally Posted by Ghosted View Post
ReceiveW is message which informs client about rain/snow, you can hook updateclientdata and send this message (size is 1 byte (1=rain/2=snow)) (Code from regamedll)
That's great dude but i still using hlds
GasmoN is offline
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 04:18.


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