Raised This Month: $32 Target: $400
 8% 

Random Skies with config file.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-12-2022 , 22:35   Random Skies with config file.
Reply With Quote #1

is it possible to add a .ini file and put the skynames available for random there?

HTML Code:
#include < amxmodx >

new gPluginMode;

new const gSkies[ ][ ] =
{
	"2desert", "alien1", "alien2", "alien3",
	"black", "city", "cliffe", "desert",
	"dusk", "morning","neb1", "neb6",
	"neb7", "space", "xen10", "xen8",
	"xen9", "night", "black","green",
	"blue", "backalley", "city1", "morningdew",
	"hav", "cliff", "office", "grnplsnt",
	"tornsky", "doom1", "cx", "de_storm",
	"snowlake_", "tornsky", "trainyard", "tsccity_",
	"snow", "2desert", "des"
};

public plugin_init( )
{
	register_plugin( "Random Skies", "2.0.0", "tuty" );
	
	gPluginMode = register_cvar( "sv_skies_mode", "1" );  // 0 - disabled, 1 - random skies
}

public plugin_end( )
{
	if( get_pcvar_num( gPluginMode ) == 1 )
	{
		server_cmd( "sv_skyname %s", gSkies[ random_num( 0, charsmax( gSkies ) ) ] );
	}
}
Ark_Procession is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 06-12-2022 , 23:30   Re: Random Skies with config file.
Reply With Quote #2

Custom Sky - Add a cool new sky to dull maps has an INI file already for each map. There's also a working maintained weather plugin to change sky depending on weather feed and time of day or night. Weather rain or snow is random. Whatever city it is set to it will mimic the weather there along with matching skies.
__________________
DJEarthQuake is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-12-2022 , 23:42   Re: Random Skies with config file.
Reply With Quote #3

Quote:
Originally Posted by DJEarthQuake View Post
Custom Sky - Add a cool new sky to dull maps has an INI file already for each map. There's also a working maintained weather plugin to change sky depending on weather feed and time of day or night. Weather rain or snow is random. Whatever city it is set to it will mimic the weather there along with matching skies.
1 - Option can't randomize skies, that is the main thing i wanted.

2 - not looking for weather plugin tho it seems to be an impressive plugin!

Thanks for answering
Ark_Procession is offline
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 06-13-2022 , 08:08   Re: Random Skies with config file.
Reply With Quote #4

Use this: https://forums.alliedmods.net/showthread.php?t=243202 in your plugin is verry simple, you can use at ZP5.0 mod to see more info and how skyes are applied from a .ini file, done this a lot of times.
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-13-2022 , 12:02   Re: Random Skies with config file.
Reply With Quote #5

Quote:
Originally Posted by CryWolf View Post
Use this: https://forums.alliedmods.net/showthread.php?t=243202 in your plugin is verry simple, you can use at ZP5.0 mod to see more info and how skyes are applied from a .ini file, done this a lot of times.
Thanks Cry! that seems really useful.

Not entirely related question:

https://wiki.alliedmods.net/Configur...p_Config_Files

why using amxx method of configs, they are not applied immediatly? they require a round restart after a few seconds to apply. it's annoying.
also, if the skybox is changed like with the plugin i posted, the skymap won't change at first changelevel, but it requires two changelevels. i think its related.

Last edited by Ark_Procession; 06-13-2022 at 12:03.
Ark_Procession is offline
CryWolf
Veteran Member
Join Date: Jul 2008
Location: Romania
Old 06-13-2022 , 15:07   Re: Random Skies with config file.
Reply With Quote #6

Yes it is releated! look
PHP Code:
#include <amxmodx>
#include <amx_settings_api>

new const ZP_SETTINGS_FILE[] = "skyes.ini"

new const sky_names[][] = { "space, sky2, sky3, etc" }

new 
g_sky_custom_enable 1
new Array:g_sky_names
new g_SkyArrayIndex

#define SKYNAME_MAX_LENGTH 32

public plugin_init()
{
    
register_plugin("[ZP] Effects: Lighting""0.0.1""ZP Dev Team")
    
    
// Set a random skybox?
    
if (g_sky_custom_enable)
    {
        new 
skyname[SKYNAME_MAX_LENGTH]
        
ArrayGetString(g_sky_namesg_SkyArrayIndexskynamecharsmax(skyname))
        
set_cvar_string("sv_skyname"skyname)
    }
    
    
// Disable sky lighting so it doesn't mess with our custom lighting
    
set_cvar_num("sv_skycolor_r"0)
    
set_cvar_num("sv_skycolor_g"0)
    
set_cvar_num("sv_skycolor_b"0)
}

public 
plugin_precache()
{
    
// Initialize arrays
    
g_sky_names ArrayCreate(SKYNAME_MAX_LENGTH1)
    
    
// Load from external file
    
if (!amx_load_setting_int(ZP_SETTINGS_FILE"Custom Skies""ENABLE"g_sky_custom_enable))
        
amx_save_setting_int(ZP_SETTINGS_FILE"Custom Skies""ENABLE"g_sky_custom_enable)
    
amx_load_setting_string_arr(ZP_SETTINGS_FILE"Custom Skies""SKY NAMES"g_sky_names)

    
// If we couldn't load from file, use and save default ones
    
new index
    
if (ArraySize(g_sky_names) == 0)
    {
        for (
index 0index sizeof sky_namesindex++)
            
ArrayPushString(g_sky_namessky_names[index])
        
        
// Save to external file
        
amx_save_setting_string_arr(ZP_SETTINGS_FILE"Custom Skies""SKY NAMES"g_sky_names)
    }

    if (
g_sky_custom_enable)
    {
        
// Choose random sky and precache sky files
        
new path[128], skyname[SKYNAME_MAX_LENGTH]
        
g_SkyArrayIndex random_num(0ArraySize(g_sky_names) - 1)
        
ArrayGetString(g_sky_namesg_SkyArrayIndexskynamecharsmax(skyname))
        
formatex(pathcharsmax(path), "gfx/env/%sbk.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sdn.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sft.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%slf.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%srt.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sup.tga"skyname)
        
precache_generic(path)
    }

Credits goes to MeRcyLeZZ for his awesome Zombie Plague Mod (respect man).
It's applied round by round, im using it on Biohazard Mod.
__________________
I dont walk trough this world with fear in my heart.
www.dark-arena.com L4D, CS1.6, CZ Servers

Last edited by CryWolf; 06-13-2022 at 15:08.
CryWolf is offline
Send a message via MSN to CryWolf Send a message via Yahoo to CryWolf
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 06-13-2022 , 21:48   Re: Random Skies with config file.
Reply With Quote #7

Quote:
Originally Posted by CryWolf View Post
Yes it is releated! look
PHP Code:
#include <amxmodx>
#include <amx_settings_api>

new const ZP_SETTINGS_FILE[] = "skyes.ini"

new const sky_names[][] = { "space, sky2, sky3, etc" }

new 
g_sky_custom_enable 1
new Array:g_sky_names
new g_SkyArrayIndex

#define SKYNAME_MAX_LENGTH 32

public plugin_init()
{
    
register_plugin("[ZP] Effects: Lighting""0.0.1""ZP Dev Team")
    
    
// Set a random skybox?
    
if (g_sky_custom_enable)
    {
        new 
skyname[SKYNAME_MAX_LENGTH]
        
ArrayGetString(g_sky_namesg_SkyArrayIndexskynamecharsmax(skyname))
        
set_cvar_string("sv_skyname"skyname)
    }
    
    
// Disable sky lighting so it doesn't mess with our custom lighting
    
set_cvar_num("sv_skycolor_r"0)
    
set_cvar_num("sv_skycolor_g"0)
    
set_cvar_num("sv_skycolor_b"0)
}

public 
plugin_precache()
{
    
// Initialize arrays
    
g_sky_names ArrayCreate(SKYNAME_MAX_LENGTH1)
    
    
// Load from external file
    
if (!amx_load_setting_int(ZP_SETTINGS_FILE"Custom Skies""ENABLE"g_sky_custom_enable))
        
amx_save_setting_int(ZP_SETTINGS_FILE"Custom Skies""ENABLE"g_sky_custom_enable)
    
amx_load_setting_string_arr(ZP_SETTINGS_FILE"Custom Skies""SKY NAMES"g_sky_names)

    
// If we couldn't load from file, use and save default ones
    
new index
    
if (ArraySize(g_sky_names) == 0)
    {
        for (
index 0index sizeof sky_namesindex++)
            
ArrayPushString(g_sky_namessky_names[index])
        
        
// Save to external file
        
amx_save_setting_string_arr(ZP_SETTINGS_FILE"Custom Skies""SKY NAMES"g_sky_names)
    }

    if (
g_sky_custom_enable)
    {
        
// Choose random sky and precache sky files
        
new path[128], skyname[SKYNAME_MAX_LENGTH]
        
g_SkyArrayIndex random_num(0ArraySize(g_sky_names) - 1)
        
ArrayGetString(g_sky_namesg_SkyArrayIndexskynamecharsmax(skyname))
        
formatex(pathcharsmax(path), "gfx/env/%sbk.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sdn.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sft.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%slf.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%srt.tga"skyname)
        
precache_generic(path)
        
formatex(pathcharsmax(path), "gfx/env/%sup.tga"skyname)
        
precache_generic(path)
    }

Credits goes to MeRcyLeZZ for his awesome Zombie Plague Mod (respect man).
It's applied round by round, im using it on Biohazard Mod.

awesome! thanks!
Ark_Procession 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 07:14.


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