AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Special task? (https://forums.alliedmods.net/showthread.php?t=153924)

bibu 03-31-2011 11:41

Special task?
 
I want to have a function, which does in a small way change the light of the map, I thought about using set_task with that, but then, I would need to make all the letters from a-z (set_lights) with set_task, is there another easy way?

drekes 03-31-2011 11:59

Re: Special task?
 
I don't understand what you mean...

bibu 03-31-2011 12:27

Re: Special task?
 
If I want that the light should go slightly to dark, something like that:

PHP Code:

set_task(2.0light_change_m)

public 
light_change_m()
{
     
set_lights("m")
     
set_task(0.5light_change_l)


And so on, doing it like this would be stupid I think, hope you understood me now. :)

drekes 03-31-2011 13:10

Re: Special task?
 
I got it now, will think about this.

EDIT: This works, but it sets the light to the brighest first.
Maybe you can work with this:

PHP Code:

#include <amxmodx>
#include <engine>

#pragma semicolon    1

#define TASK_LIGHT     4841

new const g_szAlphabet[][] =
{
    
"""a""b""c""d""e""f""g""h""i""j""k""l""m",    
    
"n""o""p""q""r""s""t""u""v""w""x""y""z"
};

new 
g_iLightLvl;

public 
plugin_init()
    
register_clcmd("say /changelights""CmdChangeLights");
    

public 
CmdChangeLights(id)
{
    
g_iLightLvl sizeof(g_szAlphabet);
    
    
set_task(0.1"TaskChangeLights"TASK_LIGHT, .flags "b");
}
    
public 
TaskChangeLights()
{
    if(!--
g_iLightLvl)
    {
        if(!
task_exists(TASK_LIGHT))
            
g_iLightLvl sizeof(g_szAlphabet);
        
        else
            
remove_task(TASK_LIGHT);
    }
    
    
set_lights(g_szAlphabet[g_iLightLvl]);



Hunter-Digital 03-31-2011 22:07

Re: Special task?
 
I don't really understand what you are trying to do but, just to offer more options:

You can use looped sequenced lights:
Code:

set_lights("aaaaaaaaaaabcdeeeeeefg")
It holds on light A for some time then goes to B,C and D then holds some time on E and then goes to F an G and then again from A... I don't really know how to end the loop but you can just set a task and set the lights to a fixed value.


Or if you just want to increase or decrease lightning:
Code:

#include <amxmodx>
#include <engine>

new const g_szLights[][] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" }

new g_iLight

public plugin_init()
{
    //g_iLight = 12 // I don't remember how to get the light level
}

stock adjustLights(iVal)
{
    if(iVal == 0)
    {
        set_lights("#OFF")
        //g_iLight = -1 // I don't remember how to get the light level
        return
    }

    g_iLight = clamp(g_iLight + iVal, 0, sizeof g_szLights)

    set_lights(g_szLights[g_iLight])

    client_print(0, print_chat, "[debug] %s%d lights - light is now %s ", (iVal > 0 ? "+" : ""), iSet, g_szLights[g_iLight])
}

Use adjustLights(value) to adjust the lights, give it positive or negative values, 0 resets light level.
Ex:
adjustLights(1) increases the light level by 1
adjustLights(-5) decreases the light level by 5
adjustLights(0) resets light level to map default.


All times are GMT -4. The time now is 14:41.

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