v1.4 beta test only , unstable
PHP Code:
/*
-------------------------------------------------------------
Cusom SKY Changer
v1.4 by CryWolf
- Provides realtime sky change features
- Auto precache the needed sky texture (bouth .VMT and .VTF files)
- Simple code
- Extra config features (cfg/sourcemod/skychanger.cfg)
- disabled 3d skybox thanks sekac
- removed index
- new download files syntax
- removed new syntax plugin erros on compile
-------------------------------------------------------------
*/
#include < sourcemod >
#include < sdktools >
#include < clientprefs >
#pragma semicolon 1
// Plugin Information
#define PLUGIN_VERSION "1.4 beta"
// pCvarS:
new Handle:cvarEnabled;
new Handle:cvarSkybox;
public Plugin:myinfo =
{
name = "Sky Changer",
author = "CryWolf",
description = "Provides Sky changer feature",
version = PLUGIN_VERSION,
url = "https://forums.alliedmods.net/showthread.php?t=258603"
};
public OnPluginStart()
{
cvarEnabled = CreateConVar ( "sm_custom_sky", "1.0", "Skybox plugin on / off" );
cvarSkybox = CreateConVar ( "sm_skybox_name", "deadend_hdr", "Skybox texture name" );
// Load configuration file
AutoExecConfig(true, "skychanger");
}
public OnMapStart()
{
if ( GetConVarBool (cvarEnabled))
{
PrecacheSkyBoxTexture ( );
ChangeSkyboxTexture ( );
}
}
public PrecacheSkyBoxTexture ( )
{
decl String:newskybox [ 32 ];
GetConVarString ( cvarSkybox, newskybox, sizeof ( newskybox ) );
Handle kv;
static char path[PLATFORM_MAX_PATH];
FileToKeyValues(kv, path);
static char suffix[][] =
{
"bk",
"Bk",
"dn",
"Dn",
"ft",
"Ft",
"lf",
"Lf",
"rt",
"Rt",
"up",
"Up",
};
char sPath[64];
char name[32];
char buffer[PLATFORM_MAX_PATH];
//Get path & name
KvGetString(kv, "path", sPath, sizeof(sPath));
KvGetString(kv, "newskybox", name, sizeof(name));
//Loop through suffixes and add to downloads table
for (int i = 0; i < sizeof(suffix);i++)
{
FormatEx(buffer, sizeof(buffer), "materials/skybox/%s%s.vtf", sPath, suffix[i]);
if(FileExists(buffer, false)) AddFileToDownloadsTable(buffer);
FormatEx(buffer, sizeof(buffer), "materials/skybox/%s%s.vmt", sPath, suffix[i]);
if(FileExists(buffer, false)) AddFileToDownloadsTable(buffer);
}
CloseHandle(kv);
}
public ChangeSkyboxTexture()
{
if ( GetConVarBool (cvarEnabled))
{
decl String:newskybox [ 32 ];
GetConVarString(cvarSkybox, newskybox, sizeof ( newskybox ));
// If there is a convar set, change the skybox to it
if ( strcmp ( newskybox, "", false ) !=0 )
{
// PrintToServer ( "[CSC] Changing the Skybox to %s", newskybox );
DispatchKeyValue ( 0, "skyname", newskybox );
}
}
}
public void OnClientPostAdminCheck(int client)
{
if (!IsFakeClient(client))
{
CreateTimer(1.0, Timer_DisableSkybox, client);
}
}
public Action Timer_DisableSkybox(Handle timer, int client)
{
if (!IsClientInGame(client))
return Plugin_Stop;
SetEntProp(client, Prop_Send, "m_skybox3d.area", 255);
return Plugin_Continue;
}
Test it at first, and then ill upload on main page, but first whanna add external .ini file per map ex
Code:
mapname skybox
mapname skybox
mapname default
__________________