Quote:
Originally Posted by Excalibur.007
Lol? Changing on zp_lighting CVar. Useless.
But anyway, you used so many if and else, why not use switch? Or I'm wrong...
|
he's making it so it changes based on what the game mode is, and using arrays you can make this plugin alot smaller
PHP Code:
#include <amxmodx>
#include <zombieplague>
new const num_to_flag[7][] = { "a", "b", "c", "d", "f", "m", "z" }
new pcvar_light[8];
new cvar_plugin_on, pointer_lighting;
#if !defined MODE_NONE
#define MODE_NONE 0
#endif
public plugin_init()
{
register_plugin("[ZP] Lightings At Start", "1.1", "abdul@");
register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
cvar_plugin_on = register_cvar("zp_lights_at_start", "1");
pcvar_light[MODE_NONE] = register_cvar("zp_starting_lights", "5");
pcvar_light[MODE_INFECTION] = register_cvar("zp_infection_lighting", "1");
pcvar_light[MODE_NEMESIS] = register_cvar("zp_nem_lighting", "6");
pcvar_light[MODE_SURVIVOR] = register_cvar("zp_surv_lighting", "2");
pcvar_light[MODE_SWARM] = register_cvar("zp_swarm_lighting", "3");
pcvar_light[MODE_PLAGUE] = register_cvar("zp_plague_lighting", "4");
pointer_lighting = get_cvar_pointer("zp_lighting");
}
public event_round_start()
zp_round_started(MODE_NONE, 0);
public zp_round_started(mode, unused)
if ( get_pcvar_num(cvar_plugin_on) && MODE_NONE <= mode <= MODE_PLAGUE )
{
if ( mode == MODE_MULTI ) mode = MODE_INFECTION; //if you include a cvar to handle multi infection then you can remove this
set_light(get_pcvar_num(pcvar_light[mode]));
}
set_light(level)
set_pcvar_string(pointer_lighting, level > 7 ? "z" : num_to_flag[level-1]); //if for some reason someone sets a higher value then 7 we need to change so we don't get that annoying index out of bounds error
__________________
If at first you don't succeed, then skydiving isn't for you.