Raised This Month: $219 Target: $400

Make Rain default on map start

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 11-01-2019 , 10:27   Make Rain default on map start
Reply With Quote #1

I've found this script here in the forums and I would like to change the start behavior of it.
Right now it changes the weather with !weather which works well, but I would like to have "rain" already selected when the round starts.

Any smart way to implement this?

I tried to use a hook on round_start but it gave me:
Exception reported: Cannot create new entity when no map is running

Here is the original script:

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#define PLUGIN_NAME		 	"Weather"
#define PLUGIN_AUTHOR	   	"Erreur 500"
#define PLUGIN_DESCRIPTION	"Control map weather"
#define PLUGIN_VERSION	  	"1.0"
#define PLUGIN_CONTACT	  	"[email protected]"

new Handle:c_density;

public Plugin:myinfo =
	name		= PLUGIN_NAME,
	author	  	= PLUGIN_AUTHOR,
	description = PLUGIN_DESCRIPTION,
	version	 	= PLUGIN_VERSION,

public OnPluginStart()
	CreateConVar("weather_version", PLUGIN_VERSION, "weather version", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_DONTRECORD);
	c_density = CreateConVar("weather_density", "255", "Density of the precipitation", FCVAR_PLUGIN, true, 1.0, true, 255.0);
	RegAdminCmd("weather", ConsoleCmdWeather, ADMFLAG_GENERIC);


public Action:ConsoleCmdWeather(client, Args)
	if(!IsValidClient(client)) return;
	new Handle:menu = CreateMenu(Menu_Weather_Ans);

	SetMenuTitle(menu, "Select a sky:");

	AddMenuItem(menu, "0", "Normal");
	AddMenuItem(menu, "1", "Rain ");
	AddMenuItem(menu, "3", "Ash");
	DisplayMenu(menu, client, MENU_TIME_FOREVER);

public Menu_Weather_Ans(Handle:menu, MenuAction:action, client, args)
	if(action == MenuAction_End)
	else if(action == MenuAction_Select)
		new entity = -1;
		while( (entity = FindEntityByClassname(entity, "func_precipitation")) != INVALID_ENT_REFERENCE )
			AcceptEntityInput(entity, "Kill");
		if(args != 0)
			decl String:WeatherID[2];
			GetMenuItem(menu, args, WeatherID, sizeof(WeatherID));


	//PrintToChatAll(" %s WeatherID ", WeatherID);

	new value, entity = -1;
	while( (entity = FindEntityByClassname(entity, "func_precipitation")) != INVALID_ENT_REFERENCE )
		value = GetEntProp(entity, Prop_Data, "m_nPrecipType");
		if( value < 0 || value == 4 || value > 5 )
			AcceptEntityInput(entity, "Kill");
	decl String:Density[8];
	GetConVarString(c_density, Density, sizeof(Density));
	entity = CreateEntityByName("func_precipitation");
	if( entity != -1 )
		decl String:buffer[128];
		GetCurrentMap(buffer, sizeof(buffer));
		Format(buffer, sizeof(buffer), "maps/%s.bsp", buffer);
		DispatchKeyValue(entity, "model", buffer);
		DispatchKeyValue(entity, "targetname", "silver_rain");
		DispatchKeyValue(entity, "preciptype", WeatherID);
		DispatchKeyValue(entity, "renderamt", Density);
		DispatchKeyValue(entity, "minSpeed", "25");
		DispatchKeyValue(entity, "maxSpeed", "35");

		new Float:vMins[3], Float:vMaxs[3];
		GetEntPropVector(0, Prop_Data, "m_WorldMins", vMins);
		GetEntPropVector(0, Prop_Data, "m_WorldMaxs", vMaxs);
		SetEntPropVector(entity, Prop_Send, "m_vecMins", vMins);
		SetEntPropVector(entity, Prop_Send, "m_vecMaxs", vMaxs);
		decl Float:vBuff[3];
		vBuff[0] = vMins[0] + vMaxs[0];
		vBuff[1] = vMins[1] + vMaxs[1];
		vBuff[2] = vMins[2] + vMaxs[2];
		TeleportEntity(entity, vBuff, NULL_VECTOR, NULL_VECTOR);
		LogError("Failed to create 'func_precipitation'");

stock bool:IsValidClient(iClient)
	if (iClient <= 0) return false;
	if (iClient > MaxClients) return false;
	return IsClientInGame(iClient);
finishlast is offline
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 11-01-2019 , 15:36   Re: Make Rain default on map start
Reply With Quote #2

Use this: https://forums.alliedmods.net/showthread.php?p=1619374
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is online now

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 16:45.

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