Code:
#include < amxmodx >
#include < zombieplague >
#include < engine >
#define PLUGIN "[ZP] Custom lights"
#define VERSION "1.0"
#define AUTHOR "Doomsday"
enum cvar
{
infection,
nemesis,
survivor,
swarm,
multi,
plague
}
new cvars[cvar]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
cvars[infection] = register_cvar("zp_lights_infection", "c");
cvars[nemesis] = register_cvar("zp_lights_nemesis", "a");
cvars[survivor] = register_cvar("zp_lights_survivor", "z");
cvars[swarm] = register_cvar("zp_lights_swarm", "b");
cvars[multi] = register_cvar("zp_lights_multi", "d");
cvars[plague] = register_cvar("zp_lights_plague", "b");
}
public zp_round_started (GameMode, id)
{
if(GameMode == MODE_INFECTION)
{
set_lights("get_pcvar_string(cvars[infection])")
}
else if(GameMode == MODE_NEMESIS)
{
set_lights("get_pcvar_string(cvars[nemesis])")
}
else if(GameMode == MODE_SURVIVOR)
{
set_lights("get_pcvar_string(cvars[survivor])")
}
else if(GameMode == MODE_SWARM)
{
set_lights("get_pcvar_string(cvars[swarm])")
}
else if(GameMode == MODE_MULTI)
{
set_lights("get_pcvar_string(cvars[multi])")
}
else if(GameMode == MODE_PLAGUE)
{
set_lights("get_pcvar_string(cvars[multi])")
}
}
Code:
#include <amxmodx>
#include <zombieplague>
// Used in indexing the cvar
#define ROUND_START 0
// Global Variables
new cvar_light[ MODE_PLAGUE + 1 ]
new cvar_plugin_on, cvar_pointer_lighting
public plugin_init( )
{
// Register the plugin and some natives
register_plugin( "[ZP] Lightings At Start", "1.1", "@bdul!" )
register_event( "HLTV", "event_round_start", "a", "1=0", "2=0" )
// Register some cvars
cvar_plugin_on = register_cvar( "zp_lights_at_start" , "1" )
cvar_light[ ROUND_START ] = register_cvar( "zp_starting_lights" , "f" )
cvar_light[ MODE_INFECTION ] = register_cvar( "zp_infection_lighting" , "a" )
cvar_light[ MODE_NEMESIS ] = register_cvar( "zp_nem_lighting" , "m" )
cvar_light[ MODE_SURVIVOR ] = register_cvar( "zp_surv_lighting" , "b" )
cvar_light[ MODE_SWARM ] = register_cvar( "zp_swarm_lighting" , "c" )
cvar_light[ MODE_MULTI ] = register_cvar( "zp_multi_lighting" , "d" )
cvar_light[ MODE_PLAGUE ] = register_cvar( "zp_plague_lighting" , "a" )
cvar_pointer_lighting = get_cvar_pointer( "zp_lighting" )
}
// Set the lighting level on round start
public event_round_start( )
{
// Make sure the plugin is on !
if ( get_pcvar_num( cvar_plugin_on ) )
{
// Retrieve the value at which the lighting will be set
static sz_starting_lights[ 2 ]
get_pcvar_string( cvar_light[ ROUND_START ], sz_starting_lights, charsmax( sz_starting_lights ) )
// Set the lighting level
if ( sz_starting_lights[ 0 ] ) set_pcvar_string( cvar_pointer_lighting, sz_starting_lights )
}
}
// Set the lighting level after a mode starts
public zp_round_started( mode, unused )
{
// Make sure its a valid mode
if ( !( MODE_INFECTION <= mode <= MODE_PLAGUE ) )
return;
// Make sure the plugin is on !
if ( get_pcvar_num( cvar_plugin_on ) )
{
// Retrieve the value at which the lighting will be set
static sz_mode_lights[ 2 ]
get_pcvar_string( cvar_light[ mode ], sz_mode_lights, charsmax( sz_mode_lights ) )
// Set the lighting level
if ( sz_mode_lights[ 0 ] ) set_pcvar_string( cvar_pointer_lighting, sz_mode_lights )
}
}
You can now see which is better and by the way his plugin wont even work cause of this