Raised This Month: $ Target: $400
 0% 

[ZP] Addon: Custom Lighting Levels !! Updated v1.3 !!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
G-Dog
Senior Member
Join Date: Dec 2005
Location: Thunderstorm Central
Old 01-30-2010 , 03:09   Re: [ZP]Addon: Lighting At Start
Reply With Quote #4

Quote:
Originally Posted by Excalibur.007 View Post
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_onpointer_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_NONE0);

public 
zp_round_started(modeunused)
    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_lightinglevel "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.

Last edited by G-Dog; 01-30-2010 at 05:49. Reason: forgot that MODE_NONE was truncated, fixed so it'll compile with 4.3
G-Dog is offline
Send a message via AIM to G-Dog
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:18.


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