AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [ANY] Random Skybox (https://forums.alliedmods.net/showthread.php?t=336882)

painkiller 03-15-2022 15:17

[ANY] Random Skybox
 
I would like to have a skybox plugin that displays a new skybox every round.
and the plugin should load all files from the materials/skybox folder.
So that you only enter the name of the skybox in the cfg and not all the files individually.

Just one question: can the skybox rotate in the game?
Would that be possible somehow?

Greeting Painkiller

iDini 03-16-2022 16:58

Re: [ANY] Random Skybox
 
https://forums.alliedmods.net/showthread.php?t=285353

painkiller 03-16-2022 17:05

Re: [ANY] Random Skybox
 
That is not what I want.

I want a different skybox to come automatically for all clients after each mapchange.

In this plugin he writes
"Allows clients to change their skybox".

Marttt 03-16-2022 17:44

Re: [ANY] Random Skybox
 
You want something ready to use.
You should try messing a little with the plugin linked, probably with few lines can achieve what you want.

painkiller 03-16-2022 18:45

Re: [ANY] Random Skybox
 
If I were a sourcemod scripter I could.
That's why I made a request here.

`666 03-17-2022 07:55

Re: [ANY] Random Skybox
 
1 Attachment(s)
I tested only in the insurgency game. You have to add sky name for a game you want yourself. Add/remove sky names under "char ga_sSkyName[][] = {" no scripting knowledge required. You can get sky names from here https://developer.valvesoftware.com/wiki/Sky_List

Admin commands:
sm_randomskysetting - Print default & current sky setting for this map
sm_randomskyrandom - Set sky to new random
sm_randomskydefault - Set sky to default setting
Setting:
The plugin will make randomsky.cfg.
sm_randomsky - 0.0 = disable | 1.0 = on map start | 2.0 = on round start

painkiller 03-17-2022 09:36

Re: [ANY] Random Skybox
 
Hello,
cool, thank you.

So just tested I have seen that in the plugin no materials / skybox for the download.
But apparently it doesn't work, the skies are all washed out.

I want to use it with these: https://gamebanana.com/mods/cats/561

Example:

Code:

# Path to the '../hl2dm/materials/skybox/' folder.
SKYBOX_PATH = GAME_PATH / 'materials' / 'skybox'

downloads = Downloadables()
# Go through all the skybox names.
for skybox in skyboxes:
    # Find all the necessary files for this skybox.
    for file in SKYBOX_PATH.files(f'{skybox}*'):
        base_name = file.basename()

        # Exclude the file if it's compressed.
        if base_name.endswith('.ztmp'):
            continue

        # Make sure the players download the file when connecting.
        downloads.add(f'materials/skybox/{base_name}')

Edit: I have since added it to my download_adder from eventscripts.

But maybe it's still possible for you that the plugin of yours can do that on its own.
Great work thank you

`666 03-17-2022 13:48

Re: [ANY] Random Skybox
 
PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

//custom skies from https://gamebanana.com/mods/cats/561
char ga_sSkyName[][] = {
    
"mr_58",            //https://gamebanana.com/mods/334824
    
"sky_universe",        //https://gamebanana.com/mods/350042
    
"doom",                //https://gamebanana.com/mods/323263
    
"mr_22b"            //https://gamebanana.com/mods/218297
};

bool    g_bEventHooked false;
char    g_sDefaultSky[32];
ConVar    g_cvWhenToSet;

public 
Plugin myinfo = {
    
name        "randomsky",
    
author        "Nullifidian & idea by painkiller",
    
description    "set random sky",
    
version        "1.1",
    
url            ""
};

public 
void OnPluginStart() {
    
RegAdminCmd("sm_randomskysetting"cmd_CheckSkyADMFLAG_RCON"Print default & current sky setting for this map");
    
RegAdminCmd("sm_randomskyrandom"cmd_RandomSkyADMFLAG_RCON"Set sky to new random");
    
RegAdminCmd("sm_randomskydefault"cmd_DefaultSkyADMFLAG_RCON"Set sky to default setting");

    
g_cvWhenToSet CreateConVar("sm_randomsky""1.0""0.0 = disable | 1.0 = on map start | 2.0 = on round start"_true0.0true2.0);
    
AutoExecConfig(true"randomsky");
    
HookConVarChange(g_cvWhenToSetConVarChanged);
}

public 
void OnMapStart() {
    
DownloadFiles();
    
CreateTimer(1.0Timer_CheckSetting);
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast) {
    
SetRandomSky();
}

void SetRandomSky() {
    
ServerCommand("sv_skyname %s"ga_sSkyName[GetRandomInt(0, ((sizeof(ga_sSkyName)) - 1))]);
}

Action Timer_CheckSetting(Handle timer) {
    
GetConVarString(FindConVar("sv_skyname"), g_sDefaultSkysizeof(g_sDefaultSky));
    switch (
g_cvWhenToSet.FloatValue) {
        case 
0.0: {
            if (
g_bEventHooked) {
                
SetupHookEvent(false);
            }
        }
        case 
1.0: {
            if (
g_bEventHooked) {
                
SetupHookEvent(false);
            }
            
SetRandomSky();
        }
        case 
2.0: {
            if (!
g_bEventHooked) {
                
SetupHookEvent();
            }
        }
    }
}

void SetupHookEvent(bool bHook true) {
    if (
bHook) {
        
HookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
        
g_bEventHooked true;
    } else {
        
UnhookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
        
g_bEventHooked false;
    }
}

public 
Action cmd_CheckSky(int clientint args) {
    
char sBuffer[32];
    
GetConVarString(FindConVar("sv_skyname"), sBuffersizeof(sBuffer));
    
ReplyToCommand(client"sv_skyname = %s | default = %s"sBufferg_sDefaultSky);
    return 
Plugin_Handled;
}

public 
Action cmd_RandomSky(int clientint args) {
    
SetRandomSky();
    
ReplyToCommand(client"Done!");
    return 
Plugin_Handled;
}

public 
Action cmd_DefaultSky(int clientint args) {
    
ServerCommand("sv_skyname %s"g_sDefaultSky);
    
ReplyToCommand(client"Set sky to default: %s"g_sDefaultSky);
    return 
Plugin_Handled;
}

void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
    if (
StringToFloat(newValue) == 2.0) {
        if (!
g_bEventHooked) {
            
SetupHookEvent();
        }
    }
    else if (
g_bEventHooked) {
        
SetupHookEvent(false);
    }
}

void DownloadFiles() {
    
char sBuffer[PLATFORM_MAX_PATH];

    
char sLower[][] = {
        
"bk",
        
"dn",
        
"ft",
        
"lf",
        
"rt",
        
"up"
    
};

    
char sUpper[][] = {
        
"BK",
        
"DN",
        
"FT",
        
"LF",
        
"RT",
        
"UP"
    
};

    for (
int i 0sizeof(ga_sSkyName); i++) {
        for (
int j 06j++) {
            
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vmt"ga_sSkyName[i], sLower[j]);
            if (
FileExists(sBufferfalse)) {
                
AddFileToDownloadsTable(sBuffer);
            } else {
                
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vmt"ga_sSkyName[i], sUpper[j]);
                if (
FileExists(sBufferfalse)) {
                    
AddFileToDownloadsTable(sBuffer);
                } else {
                    
LogError("Can't find: %s"sBuffer);
                }
            }

            
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vtf"ga_sSkyName[i], sLower[j]);
            if (
FileExists(sBufferfalse)) {
                
AddFileToDownloadsTable(sBuffer);
            } else {
                
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vtf"ga_sSkyName[i], sUpper[j]);
                if (
FileExists(sBufferfalse)) {
                    
AddFileToDownloadsTable(sBuffer);
                } else {
                    
LogError("Can't find: %s"sBuffer);
                }
            }
        }
    }



painkiller 03-17-2022 14:27

Re: [ANY] Random Skybox
 
Quote:

Originally Posted by `666 (Post 2774487)
PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

//custom skies from https://gamebanana.com/mods/cats/561
char ga_sSkyName[][] = {
    
"mr_58",            //https://gamebanana.com/mods/334824
    
"sky_universe",        //https://gamebanana.com/mods/350042
    
"doom",                //https://gamebanana.com/mods/323263
    
"mr_22b"            //https://gamebanana.com/mods/218297
};

bool    g_bEventHooked false;
char    g_sDefaultSky[32];
ConVar    g_cvWhenToSet;

public 
Plugin myinfo = {
    
name        "randomsky",
    
author        "Nullifidian & idea by painkiller",
    
description    "set random sky",
    
version        "1.1",
    
url            ""
};

public 
void OnPluginStart() {
    
RegAdminCmd("sm_randomskysetting"cmd_CheckSkyADMFLAG_RCON"Print default & current sky setting for this map");
    
RegAdminCmd("sm_randomskyrandom"cmd_RandomSkyADMFLAG_RCON"Set sky to new random");
    
RegAdminCmd("sm_randomskydefault"cmd_DefaultSkyADMFLAG_RCON"Set sky to default setting");

    
g_cvWhenToSet CreateConVar("sm_randomsky""1.0""0.0 = disable | 1.0 = on map start | 2.0 = on round start"_true0.0true2.0);
    
AutoExecConfig(true"randomsky");
    
HookConVarChange(g_cvWhenToSetConVarChanged);
}

public 
void OnMapStart() {
    
DownloadFiles();
    
CreateTimer(1.0Timer_CheckSetting);
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast) {
    
SetRandomSky();
}

void SetRandomSky() {
    
ServerCommand("sv_skyname %s"ga_sSkyName[GetRandomInt(0, ((sizeof(ga_sSkyName)) - 1))]);
}

Action Timer_CheckSetting(Handle timer) {
    
GetConVarString(FindConVar("sv_skyname"), g_sDefaultSkysizeof(g_sDefaultSky));
    switch (
g_cvWhenToSet.FloatValue) {
        case 
0.0: {
            if (
g_bEventHooked) {
                
SetupHookEvent(false);
            }
        }
        case 
1.0: {
            if (
g_bEventHooked) {
                
SetupHookEvent(false);
            }
            
SetRandomSky();
        }
        case 
2.0: {
            if (!
g_bEventHooked) {
                
SetupHookEvent();
            }
        }
    }
}

void SetupHookEvent(bool bHook true) {
    if (
bHook) {
        
HookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
        
g_bEventHooked true;
    } else {
        
UnhookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
        
g_bEventHooked false;
    }
}

public 
Action cmd_CheckSky(int clientint args) {
    
char sBuffer[32];
    
GetConVarString(FindConVar("sv_skyname"), sBuffersizeof(sBuffer));
    
ReplyToCommand(client"sv_skyname = %s | default = %s"sBufferg_sDefaultSky);
    return 
Plugin_Handled;
}

public 
Action cmd_RandomSky(int clientint args) {
    
SetRandomSky();
    
ReplyToCommand(client"Done!");
    return 
Plugin_Handled;
}

public 
Action cmd_DefaultSky(int clientint args) {
    
ServerCommand("sv_skyname %s"g_sDefaultSky);
    
ReplyToCommand(client"Set sky to default: %s"g_sDefaultSky);
    return 
Plugin_Handled;
}

void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue) {
    if (
StringToFloat(newValue) == 2.0) {
        if (!
g_bEventHooked) {
            
SetupHookEvent();
        }
    }
    else if (
g_bEventHooked) {
        
SetupHookEvent(false);
    }
}

void DownloadFiles() {
    
char sBuffer[PLATFORM_MAX_PATH];

    
char sLower[][] = {
        
"bk",
        
"dn",
        
"ft",
        
"lf",
        
"rt",
        
"up"
    
};

    
char sUpper[][] = {
        
"BK",
        
"DN",
        
"FT",
        
"LF",
        
"RT",
        
"UP"
    
};

    for (
int i 0sizeof(ga_sSkyName); i++) {
        for (
int j 06j++) {
            
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vmt"ga_sSkyName[i], sLower[j]);
            if (
FileExists(sBufferfalse)) {
                
AddFileToDownloadsTable(sBuffer);
            } else {
                
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vmt"ga_sSkyName[i], sUpper[j]);
                if (
FileExists(sBufferfalse)) {
                    
AddFileToDownloadsTable(sBuffer);
                } else {
                    
LogError("Can't find: %s"sBuffer);
                }
            }

            
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vtf"ga_sSkyName[i], sLower[j]);
            if (
FileExists(sBufferfalse)) {
                
AddFileToDownloadsTable(sBuffer);
            } else {
                
FormatEx(sBuffersizeof(sBuffer), "materials/skybox/%s%s.vtf"ga_sSkyName[i], sUpper[j]);
                if (
FileExists(sBufferfalse)) {
                    
AddFileToDownloadsTable(sBuffer);
                } else {
                    
LogError("Can't find: %s"sBuffer);
                }
            }
        }
    }



That's great, thank you very much, it works perfectly.

Is there a possibility that you could make another plugin I don't know how far your skills go.
But I think it would not be that easy.
Unfortunately, we can't write to you privately.

`666 03-17-2022 14:32

Re: [ANY] Random Skybox
 
Just make new thread, I'm sure others want to help too.


All times are GMT -4. The time now is 23:35.

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