Hi,
I need to catch a very early moment when server replicate ConVars to client when he joins the server.
So, I should be able to setup different skyboxes for different clients.
Some code:
This one is work OK. I'm overriding client's ConVar OnGameFrame(), so I ensured it is work.
Spoiler
PHP Code:
ConVar g_hCvarSkyName;
public void OnPluginStart()
{
g_hCvarSkyName = FindConVar("sv_skyname");
}
public void OnMapStart()
{
g_hCvarSkyName.SetString("sky_day01_09_hdr"); // let's say it is a custom skybox
}
public void OnGameFrame() // override per-client (for all moments of time), just for test reason
{
ApplyClientSkyAll();
}
void ApplyClientSkyAll()
{
for( int i = 1; i <= MaxClients; i++)
{
if( IsClientConnected(i) && !IsFakeClient(i) )
{
ApplyClientSky(i);
}
}
}
void ApplyClientSky(int client)
{
if( client && !IsFakeClient(client) )
{
SendConVarValue(client, g_hCvarSkyName, "test_moon_hdr");
}
}
Now, I need to do the same without OnGameFrame().
Some attempts:
Spoiler
PHP Code:
ConVar g_hCvarSkyName;
public void OnPluginStart()
{
g_hCvarSkyName = FindConVar("sv_skyname");
}
public void OnMapStart()
{
g_hCvarSkyName.SetString("sky_day01_09_hdr"); // let's say it is a custom skybox
}
public void OnClientConnected(int client)
{
ApplyClientSky(client);
}
bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
{
ApplyClientSky(client);
return true;
}
public void OnClientSettingsChanged(int client)
{
ApplyClientSky(client);
}
public void OnClientPutInServer(int client)
{
ApplyClientSky(client);
}
void ApplyClientSky(int client)
{
if( client && !IsFakeClient(client) )
{
SendConVarValue(client, g_hCvarSkyName, "test_moon_hdr");
}
}
They are not work. Client's ConVar is changed but it was too late and I see custom skybox "sky_day01_09_hdr", defined by OnMapStart.
Thanks for help.
__________________