AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   FRC v12.0 [Team Flash, Detector, Tool] (https://forums.alliedmods.net/showthread.php?t=74091)

Maurice 08-03-2008 18:58

Re: Flashbang Remote Control
 
Quote:

Originally Posted by ot_207 (Post 662640)
1. It will be possible, but it will take some time becouse the plugin disables the flash before a player is flashed, so it is impossible to know wether he was fully flashed or not. I will look into it ;).

Oki, it would be great if it could be added but without it is alse a fantastic plugin, the best one released so far. I've removed all anti TF and TF punish plugins form my servers because this one take care of it all however i noticed the dynamic light also happens when the flashlight is turned on.

ot_207 09-15-2008 04:03

Re: Flashbang Remote Control v9.0
 
New version v9.0

Need new translations!!!

New Features:
14. Control Pannel -> you can customize all the settings of the plugin exept the colors of the flash

New Commands:
amx_flash_control_menu (ADMIN_CFG flag) Shows settings menu for flashbang remote control
amx_fcm (ADMIN_CFG flag) Shows settings menu for flashbang remote control

Changelog:
PHP Code:

*  9.0  control pannel last improvements
*  8.5  - new punish system
*  8.1  cvar bug fixflashlight bug fix 


andyD 01-18-2009 11:09

Re: Flashbang Remote Control v9.1
 
I ve tested it and found some bugs,

When i put in the option "block throw" and allowed team flashes 0 i can not throw a flash , even when it s gonna fall behind a wall.

When i put in option block throw and allowed flashes 0 i can not flash myself .

When i put in the option block throw and allowed flashes 1 i can flash myself for as many times as i want.

In the above examples all the other cvars where set to no or o exept the ones below flash punish.

Seems there are still some bugs there.

i guess the reason for not being able to throww the flash when set to o is because it punishes everyone , the only curious thing there is that i was alone on the server.

andyD 01-19-2009 13:10

Re: Flashbang Remote Control v9.1
 
Seems i was a bit to fast with my complaints, never mind

to excuse myself and because my teammates dont understand english i made a french version of the menu and translated the cvar explaination,
this might come in handy for others so here it is,

Code:

/*
*  Team Flash Control
*
*  Author: OT

*  Changelog:
*
*  9.1  - last improvements + the plugin can now be seen on servers.
*  9.0  - control pannel + last improvements
*  8.5  - new punish system
*  8.1  - cvar bug fix, flashlight bug fix
*  8.0  - new feature -> color flashbangs
*  7.0  - updated all the features, now work 100% + new dynamic light feature
*  6.5  - improvement to the player origin, now the plugin gets the players head
*  6    - major improvement to all the blocks (including the new feature)
*  5.5  - small improvement to the moment a player is flashed (when a player is flashed for a long time the flash will count)
*  5.3  - big improvement to the bug detection
*  5    - improvement to the new feature
*  5.0b - new feature added -> block flash when you flashed a teammate and a enemy together
*  4.5  - bugfix feature added
*  4    - multilang
*  3.5  - added more features, the plugin has a new name "Team Flash Control"
*  3    - optimized plugin (pcvars + new forwards) -> now works 100% (2008-07-11)
*  2    - optimized plugin -> now works > 70% (2008-07-08)
*  1.1  - fixed bug: more than one player can get a message from the same teamflash event
*        new cvar: tfc_adminchat (2007-11-04)
*  1.0  - sound on/off cvar: tfc_sound 1/0 (2006-04-14)
*  0.3  - fixed bug: dead spectators will nog get message about teamflash (2006-03-16)
*  0.2  - changed flash owner code, a timer is added, "[Team Flash Snitch]" in green text (2006-03-12)
*  0.1  - initial release (2006-01-25)
*
*  Credits:
*
*  Tender for Team Flash Snitch
*  MpNumb for Bugfix feature
*  xxAvalanchexx for Dynamiclight
*  v3x for Colored Flashbangs
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

// The defines that hold info on how the user has been blinded
#define BLINDED_FULLY    255
#define BLINDED_PARTLY    200

// Maximum entities
#define MAX_ENT        1126

// Task unique id
#define REMAIN_TASK        642354

// The bones of a player
#define BONE_HEAD        8

// Private data

#if cellbits == 32
#define OFFSET_TEAM        114
#else
#define OFFSET_TEAM        139
#endif

#define OFFSET_LINUX    5

// Message events
new saytext
new scrfade

// Entity owner remember
new g_ent_owner[MAX_ENT] = {0,...}

// Flasher id
new g_flasher = 0

// Flash entity index
new g_flash_ent = 0

// Player info
new g_flash_mon[33] = {0,...}
new bool:g_block_flash[33] = {false, ...}
new g_team_pl[33]
new bool:g_counter_in_effect[33] = {true, ...}
new bool:g_reset_counter[33] = {false, ...}
new g_round_lock[33]
new Float:g_time_lock[33]

// Forward info
new bool:g_allow_forward = true

// Colors
new g_color_red
new g_color_green
new g_color_blue

// Pcvars
enum OptionType
{
    OPTION_TOGGLE = 1,
    OPTION_CELL,
    OPTION_FLOAT
}

enum Option
{
    pc_frc_sound,
    pc_frc_admin,
    pc_frc_block,
    pc_frc_selfb,
    pc_frc_blocka,

    pc_frc_count,
    pc_frc_punish,
    pc_frc_limit,
    pc_frc_warn,
    pc_frc_mode,
    pc_frc_type,
    pc_frc_nr_ctr,

    pc_frc_mcolor,
    pc_frc_rcolor,
    pc_frc_gcolor,
    pc_frc_bcolor,

    pc_frc_dlight,

    pc_frc_bug,
}

new pcvars[Option]
new OptionType:option_type[Option]
new option_value[Option][100]
new option_information[Option][300]

new settingsmenu
new callbacks[2]

new const CFG_FILE_NAME[] = "flash_remote_control.cfg"
new CFG_FILE[300]

public plugin_init()
{
    // Let's register the plugin
    register_plugin("Flash Remote Control","9.1","OT")
    register_cvar("flash_remote_version","9.1",FCVAR_SERVER)
   
    // The basic cvars
    register_option(pc_frc_sound,"frc_sound","0") // son envoyer au flasheur
    register_option(pc_frc_admin,"frc_adminchat","1") // les messages admins
    register_option(pc_frc_block,"frc_block_team_flash","0") // blocker la possibiliter de flash team
    register_option(pc_frc_selfb,"frc_block_self_flash","1") // blocker la possibiliter de se flasher soi meme
    register_option(pc_frc_blocka,"frc_block_team_all_flash","0") // enlever d etre flasher pour tout le monde quand qqn flash team
   
    // The punish system cvars
    register_option(pc_frc_punish,"frc_flasher_punish","1") // punir le joueur qui flash team de trop
    register_option(pc_frc_count,"frc_flasher_counter","0") // 0 -> compter uniquement les flash complet 1 -> compter tout les flash
    register_option(pc_frc_limit,"frc_flasher_mistake_allow","0",OPTION_CELL) // nombre de flash team avant d etre puni
    register_option(pc_frc_warn,"frc_flasher_warn","0") // warn the player
    register_option(pc_frc_mode,"frc_flasher_punish_mode","1",OPTION_CELL) // mode de punition: 0 -> fin de map, 1 -> rounds, 2 -> temps
    register_option(pc_frc_type,"frc_flasher_punish_type","0",OPTION_CELL) // type de punition: 0 -> blocker de pouvoir jeter, 1 -> kill, 2 -> flasher le team flasheur
    register_option(pc_frc_nr_ctr,"frc_flasher_punish_control","0",OPTION_FLOAT) // mode de punition controlle combien de round/minutes le joueur sera puni (ne fonctionne pas avec mode de punition 0)
   
    // Flash color cvars
    register_option(pc_frc_mcolor,"frc_color_mode","0",OPTION_CELL) // 0 -> off, 1 -> couleur specifier, 2 -> couleur variable(meme pour tout les joueurs), 3 -> couleur variable par joueur
    register_option(pc_frc_rcolor,"frc_red_color","100") // couleur rouge cvar
    register_option(pc_frc_gcolor,"frc_green_color","100") // couleur vert cvar
    register_option(pc_frc_bcolor,"frc_blue_color","255") // couleur bleu cvar
   
    // Flash lumiere dynamic cvars, la lumiere dynamique depend des cvars des couleurs flash
    register_option(pc_frc_dlight,"frc_dynamic_light","1") // lumiere dynamic
   
    // Bug fix cvar
    register_option(pc_frc_bug,"frc_bug_fix","1") // activer ou desactiver bug lash
   
    // Special option values
    register_option_value(pc_frc_limit,"0;1;2;3;4")
    register_option_value(pc_frc_mode,"0;1;2")
    register_option_value(pc_frc_type,"0;1;2")
    register_option_value(pc_frc_mcolor,"0;1;2;3")
   
    // Control panel menu
    register_clcmd("amx_flash_control_menu", "conjure_menu", ADMIN_CFG, "Shows settings menu for flashbang remote control.")
    register_clcmd("amx_fcm", "conjure_menu", ADMIN_CFG, "Shows settings menu for flashbang remote control.")
   
    // The events
    register_event("ScreenFade", "event_blinded", "be", "1>4096", "4=255", "5=255", "6=255", "7>199")
    register_event("ScreenFade", "event_override", "be", "4=255", "5=255", "6=255", "7>199")
    register_logevent("event_round_end", 2, "1=Round_End")
   
    // The message constants
    saytext = get_user_msgid("SayText")
    scrfade = get_user_msgid("ScreenFade")
   
    // The fakemeta forwards
    register_forward(FM_SetModel, "fw_setmodel",1)
    register_forward(FM_EmitSound,"fw_emitsound")
    register_forward(FM_Think, "fw_think")
    register_forward(FM_PlayerPreThink,"fw_player_prethink")
    register_forward(FM_FindEntityInSphere,"fw_findentityinsphere")
   
    // Control pannel
    callbacks[0] = menu_makecallback("callback_disabled")
    callbacks[1] = menu_makecallback("callback_enabled")
   
    // The dictionary
    register_dictionary("flashbang_remote_control.txt")
   
    // Config file
    new config[200]
    get_configsdir(config,199)
    format(CFG_FILE,299,"%s/%s",config,CFG_FILE_NAME)
   
    exec_cfg()
}

// Control Pannel

// Cfg save system
public exec_cfg()
{
    if(file_exists(CFG_FILE))
        server_cmd("exec %s",CFG_FILE)
}

public save_cfg()
{
    new file[2000]
    format(file,1999,"echo [Flashbang Remote Control] Executing config file ...^n")
   
    add_to_file(file,1999,pc_frc_sound)
    add_to_file(file,1999,pc_frc_admin)
    add_to_file(file,1999,pc_frc_selfb)
    add_to_file(file,1999,pc_frc_block)
    add_to_file(file,1999,pc_frc_blocka)
    add_to_file(file,1999,pc_frc_punish)
    add_to_file(file,1999,pc_frc_count)
    add_to_file(file,1999,pc_frc_limit)
    add_to_file(file,1999,pc_frc_warn)
    add_to_file(file,1999,pc_frc_mode)
    add_to_file(file,1999,pc_frc_type)
    add_to_file(file,1999,pc_frc_nr_ctr)
    add_to_file(file,1999,pc_frc_mcolor)
    add_to_file(file,1999,pc_frc_rcolor)
    add_to_file(file,1999,pc_frc_gcolor)
    add_to_file(file,1999,pc_frc_bcolor)
    add_to_file(file,1999,pc_frc_dlight)
    add_to_file(file,1999,pc_frc_bug)
   
    format(file,1999,"%secho [Flashbang Remote Control] Settings loaded from config file",file)
   
    delete_file(CFG_FILE)
    write_file(CFG_FILE,file)
}

stock add_to_file(file[], size_of_file, Option:option)
{
    switch (option_type[option])
    {
        case OPTION_TOGGLE,OPTION_CELL: format(file,size_of_file,"%s%s %d^n",file,option_information[option],get_option(option))
        case OPTION_FLOAT: format(file,size_of_file,"%s%s %f^n",file,option_information[option],get_option_float(option))
    }
}

// Control Pannel Menu system
public conjure_menu(id, level, cid)
{
    if (cmd_access(id, level, cid, 1))
    {
        menu_adjust(id)
    }
    return PLUGIN_HANDLED
}

// Let's create the menu!
stock menu_adjust(id, page = 0)
{
    settingsmenu = menu_create("Flash Remote Control Pannel", "menu_handler")
   
    add_option_toggle(pc_frc_admin,"Envoyer message text admin","Oui","Non")
    add_option_toggle(pc_frc_sound,"Jouer le son ^"I'm blind^" ","On","Off")
    add_option_toggle(pc_frc_block,"Blocker flash team","Oui","Non")
    add_option_toggle(pc_frc_selfb,"Blocker de se flasher soi meme","Oui","Non")
    add_option_toggle(pc_frc_blocka,"Blocker flash pour tous quand team flash","Oui","Non")
    add_option_toggle(pc_frc_bug,"Blocker le bug flash","Oui","Non")
    add_option_toggle(pc_frc_dlight,"Lumiere dynamique","Oui","Non")
    add_option_quatrotoggle(pc_frc_mcolor,"couleur de flash","Normal","Couleurs specifier","Couleur par hasard (la meme pour tout les joueurs)","Couleur par hasard par joueur")
   
    add_option_toggle(pc_frc_punish,"Systeme de punition","On","Off")
   
    if (get_option(pc_frc_punish))
    {
        add_option_toggle(pc_frc_warn,"Prevenir celui qui flash","Oui","Non")
        add_option_tritoggle(pc_frc_mode,"Mode de punition","Jusqua fin de map","Par round","Par temps")
        add_option_tritoggle(pc_frc_type,"Type de punition","Impossible de jeter", "Kill", "Auto flash")
        add_cell_option(pc_frc_limit,"Nombre de flash team","Flash team")
       
       
        switch (get_option(pc_frc_mode))
        {
            case 1:
            {
                register_option_value(pc_frc_nr_ctr,"1;2;3;4;5;6;7;8;9;10")
                add_float_cell_option(pc_frc_nr_ctr,"Nombre de round punition","round")
            }
            case 2:
            {   
                register_option_value(pc_frc_nr_ctr,"1;1.5;2;2.5;3;3.5;4;4.5;5;5.5;6;7;8;9;10")
                add_float_option(pc_frc_nr_ctr,"Temps de punition","minutes")
            }
        }
       
    }
   
    menu_display(id, settingsmenu, page)
    return PLUGIN_CONTINUE
}

stock add_option_toggle(Option:control_option, const basetext[], const yestext[], const notext[], Option:displayif = Option:-1)
{
    new cmd[3], itemtext[100]
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s: %s%s", basetext, (get_option(control_option) ? "\y" : "\r" ), (get_option(control_option) ? yestext : notext))
    menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
}

stock add_option_tritoggle(Option:control_option, const basetext[], const text[], const text2[], const text3[], Option:displayif = Option:-1)
{
    new cmd[3], itemtext[100]
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s:\y %s%s%s", basetext, (get_option(control_option) == 0 ? text : "" ), (get_option(control_option) == 1 ? text2 : "" ), (get_option(control_option) == 2 ? text3 : "" ))
    menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
}

stock add_option_quatrotoggle(Option:control_option, const basetext[], const text[], const text2[], const text3[], const text4[], Option:displayif = Option:-1)
{
    new cmd[3], itemtext[100]
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s:\y %s%s%s%s", basetext, (get_option(control_option) == 0 ? text : "" ), (get_option(control_option) == 1 ? text2 : "" ), (get_option(control_option) == 2 ? text3 : "" ), (get_option(control_option) == 3 ? text4 : "" ))
    menu_additem(settingsmenu, itemtext, cmd, _, (displayif != Option:-1 && !get_option(displayif)) ? callbacks[0] : callbacks[1])
}

stock add_float_option(Option:control_option, const basetext[], const unit[])
{
    new cmd[3], itemtext[100]
    new value[20]
   
    format(value,19,"%0.2f",get_option_float(control_option))
   
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s: \y%s \r%s", basetext, value, unit)
    menu_additem(settingsmenu, itemtext, cmd, _, _)
}

stock add_float_cell_option(Option:control_option, const basetext[], const unit[])
{
    new cmd[3], itemtext[100]
    new value[20]
   
    format(value,19,"%d",floatround(get_option_float(control_option)))
   
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s: \y%s \r%s", basetext, value, unit)
    menu_additem(settingsmenu, itemtext, cmd, _, _)
}

stock add_cell_option(Option:control_option, const basetext[], const unit[])
{
    new cmd[3], itemtext[100]
    new value[20]
   
    format(value,19,"%d",get_option(control_option))
   
    num_to_str(_:control_option, cmd, 2)
    format(itemtext, 99, "%s: \y%s \r%s", basetext, value, unit)
    menu_additem(settingsmenu, itemtext, cmd, _, _)
}

public callback_disabled(id, menu, item)
{
    return ITEM_DISABLED
}

public callback_enabled(id, menu, item)
{
    return ITEM_ENABLED
}


// Base cvar change system
public menu_handler(id, menu, item)
{
    new access, info[5], callback
    menu_item_getinfo(menu, item, access, info, 4, _, _, callback)
   
    if (item < 0)
    {
        save_cfg()
        return PLUGIN_HANDLED
    }
   
    new cvar = str_to_num(info)
   
    switch (option_type[Option:cvar])
    {
        case OPTION_TOGGLE:
        {
            toggle_option(Option:cvar)
        }
        case OPTION_CELL:
        {
            new value_string[100]
            format(value_string,99,"%s;",option_value[Option:cvar])
           
            new values[20][10]
            new true_value[20]
           
            new last = 0,newpos = 0, k = 0;
           
            for (new i=0;i<100;i++)
            {
                if(equal(value_string[i],";",1))
                {
                    newpos = i
                }
               
                if (newpos > last)
                {                   
                    for (new j=last;j<newpos;j++)
                    {
                        format(values[k],9,"%s%s",values[k],value_string[j])
                    }
                   
                    last = newpos + 1
                    k++
                }
            }
           
            new bool:ok = false
            new counter = 0
           
            for (new i=0;i<k;i++)
            {
                counter++
               
                true_value[i] = str_to_num(values[i])
               
                if (ok == true)
                {
                    set_pcvar_num(pcvars[Option:cvar],true_value[i])
                    counter = 0
                    break
                }
               
                if (true_value[i] == get_option(Option:cvar))
                    ok = true
            }
           
            if (counter == k)
                set_pcvar_num(pcvars[Option:cvar],true_value[0])
        }
        case OPTION_FLOAT:
        {
            new value_string_float[100]
            format(value_string_float,99,"%s;",option_value[Option:cvar])
           
            new values_float[20][10]
            new Float:true_value_float[20]
           
            new last = 0,newpos = 0, k = 0;
           
            for (new i=0;i<100;i++)
            {
                if(equal(value_string_float[i],";",1))
                {
                    newpos = i
                }
               
                if (newpos > last)
                {                   
                    for (new j=last;j<newpos;j++)
                    {
                        format(values_float[k],9,"%s%s",values_float[k],value_string_float[j])
                    }
                   
                    last = newpos + 1
                    k++
                }
            }
           
            new bool:ok=false
            new counter = 0
           
            for (new i=0;i<k;i++)
            {
                counter++
               
                true_value_float[i] = str_to_float(values_float[i])
               
                if (ok == true)
                {
                    set_pcvar_float(pcvars[Option:cvar],true_value_float[i])
                    counter = 0
                    break
                }
               
                if (true_value_float[i] == get_option_float(Option:cvar))
                    ok = true
            }
           
            if (counter == k)
                set_pcvar_float(pcvars[Option:cvar],true_value_float[0])
        }
    }
   
    menu_destroy(menu)
    menu_adjust(id, floatround(float(item)/7.0,floatround_floor))
    save_cfg()
    return PLUGIN_HANDLED
}

// Cache the sound
public plugin_precache()
{
    engfunc(EngFunc_PrecacheSound,"radio/bot/im_blind.wav")
}

// Round end
public event_round_end()
{
    static players[32],num,id
    get_players(players, num)
   
    for (new i=0;i<num;i++)
    {
        id = players[i]
       
        if (g_round_lock[id] > 0  && g_counter_in_effect[id] == false)
            g_round_lock[id] -= 1
       
        if (g_round_lock[id] == 0 && get_option(pc_frc_mode) == 1 && g_counter_in_effect[id] == false)
        {
            g_reset_counter[id] = false
            g_counter_in_effect[id] = true
            g_flash_mon[id] = 0
        }
    }
}

// Reset the monitor when a player connects or disconnects
public client_disconnect(id)
{
    g_reset_counter[id] = true
}

public client_connect(id)
{
    g_reset_counter[id] = true
}

// Damn you!!! You flashed me!!!
public event_blinded(id)
{
    new alpha = read_data(7)
   
    if (!is_user_alive(id) || g_flasher == 0)
        return PLUGIN_CONTINUE
   
    // And now the news!
    return show_news(id,alpha,g_flasher)
}

public event_override(id)
{
    if (get_option(pc_frc_mcolor) == 0)
        return PLUGIN_CONTINUE
   
    if (get_option(pc_frc_mcolor) != 3)
        flash(id,read_data(1),read_data(2),read_data(3),g_color_red,g_color_green,g_color_blue,read_data(7))
    else
        flash(id,read_data(1),read_data(2),read_data(3),random_num(0,255),random_num(0,255),random_num(0,255),read_data(7))
   
    return PLUGIN_CONTINUE
}

// Show the news!
public show_news(id,alpha,id_fl)
{   
    // If you flash a teammate
    if (g_team_pl[id] == g_team_pl[id_fl] && id != id_fl)
    {
        new message1[128], message2[128]
        new flasher[32], name[32]
       
        get_user_name(id_fl, flasher, 31)
        get_user_name(id, name, 31)
       
        format(message1, 127, "^x04[Team Flash Control]^x01 %L ^x03%s", id, "THE_FLASHED_MSG", flasher)
        format(message2, 127, "^x04[Team Flash Control]^x01 %L ^x03(%s)",id_fl,alpha == BLINDED_FULLY ? "FLASHER_MSG_TOTAL" : "FLASHER_MSG_PART", name)
       
        colored_msg(id,message1)
        colored_msg(id_fl,message2)
       
        if (!is_user_bot(id_fl) && get_option(pc_frc_punish) && g_counter_in_effect[id_fl] == true && (alpha == BLINDED_FULLY || (get_option(pc_frc_count) && alpha != BLINDED_FULLY)))
        {
            g_flash_mon[id_fl] += 1
           
            if (g_flash_mon[id_fl] == get_option(pc_frc_limit))
            {
                g_counter_in_effect[id_fl] = false
                switch (get_option(pc_frc_mode))
                {
                    case 1: g_round_lock[id_fl] = floatround(get_option_float(pc_frc_nr_ctr),floatround_round)
                    case 2: g_time_lock[id_fl]  = get_gametime() + (get_option_float(pc_frc_nr_ctr) * 60.0)
                }
               
                if(get_option(pc_frc_admin) && get_option(pc_frc_punish))
                {
                    new msg[128]
                    format(msg,127,"%L",LANG_SERVER,"BLOCK_USER_FLASH_MSG",flasher)
                    admin_message("[Team Flash Control]",msg)
                }
               
            }
        }
       
        if (g_flash_mon[id_fl] == get_option(pc_frc_limit) && alpha == BLINDED_FULLY)
            switch (get_option(pc_frc_type))
            {
                case 1: user_kill(id_fl)
                case 2: eflash(id_fl, 10<<12, 1<<12, 0x0000 , 255, 255, 255, 255)
            }
       

        if(get_option(pc_frc_sound))
            client_cmd(id_fl,"spk sound/radio/bot/im_blind.wav")
       
        if(alpha == BLINDED_FULLY && get_option(pc_frc_admin))
        {
            new msg[128]
            format(msg,127,"%L",LANG_SERVER,"ADMIN_MSG",flasher,name)
            admin_message("[Team Flash Control]",msg)
        }
    }
   
    return PLUGIN_CONTINUE
}

// Player prethink
public fw_player_prethink(id)
{
    if (!is_user_alive(id))
        return FMRES_IGNORED
   
    // Get the team of the player
    new team = get_pdata_int(id,OFFSET_TEAM,OFFSET_LINUX)
   
    if (team != g_team_pl[id])
        g_team_pl[id] = team
   
    if (g_reset_counter[id] == true)
    {
        g_reset_counter[id] = false
        g_counter_in_effect[id] = true
        g_flash_mon[id] = 0
    }
   
    if (get_gametime() >= g_time_lock[id] && get_option(pc_frc_mode) == 2 && g_counter_in_effect[id] == false)
    {
        g_reset_counter[id] = false
        g_counter_in_effect[id] = true
        g_flash_mon[id] = 0
    }
   
    if (get_user_weapon(id) == CSW_FLASHBANG && pev(id,pev_button) & IN_ATTACK && g_flash_mon[id] == get_option(pc_frc_limit) && get_option(pc_frc_punish) && get_option(pc_frc_type) == 0)
    {
        set_pev(id,pev_button,pev(id,pev_button) & ~IN_ATTACK)
        return FMRES_HANDLED
    }
   
    return FMRES_IGNORED
}

// The moment the flash is thrown
public fw_setmodel(ent,const model[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED
   
    // Not yet thrown
    if (pev_float(ent,pev_gravity) == 0.0)
        return FMRES_IGNORED
   
    if (containi(model,"w_flashbang.mdl") == -1)
        return FMRES_IGNORED
   
    // Get the owner   
    g_ent_owner[ent] = pev(ent,pev_owner)
   
    return FMRES_IGNORED
}

// The grenade thinks ... quiet!!!
public fw_think(ent)
{
    if (!is_flash(ent) || g_flash_ent == ent)
        return FMRES_IGNORED
   
    // The flash has not kaboomed
    if (pev_float(ent,pev_dmgtime) > get_gametime())
        return FMRES_IGNORED
   
    g_flasher = g_ent_owner[ent]
    g_flash_ent = ent
    new Float:origin[3]
    pev(ent,pev_origin,origin)
   
    if (get_option(pc_frc_selfb) != 0)
        g_block_flash[g_flasher] = true
   
    if (get_option(pc_frc_block) != 0)
    {
        for (new i=0;i<33;i++)
        {
            if (i != g_flasher && g_team_pl[i] == g_team_pl[g_flasher])
                g_block_flash[i] = true
        }
    }
   
    if (get_option(pc_frc_blocka) != 0)
    {
        new Float:user_origin[3],Float:angles[3]
        new hit,trace
       
        while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, 1500.0)))
        {
            if (!is_user_alive(hit) || g_team_pl[hit] != g_team_pl[g_flasher] || g_flasher == hit)
                continue
           
            // Get the origin of the players head
            engfunc(EngFunc_GetBonePosition, hit, BONE_HEAD, user_origin, angles)
           
            // Traceline from the player origin to the grenade origin
            engfunc(EngFunc_TraceLine, origin, user_origin, DONT_IGNORE_MONSTERS, ent, trace)
           
            if (get_tr2(trace,TR_pHit) == hit)
            {
                g_allow_forward = false
                break
            }
        }
    }
   
    switch (get_option(pc_frc_mcolor))
    {
        case 1:
        {
            g_color_red  = get_option(pc_frc_rcolor)
            g_color_green = get_option(pc_frc_gcolor)
            g_color_blue  = get_option(pc_frc_bcolor)
        }
        case 2:
        {
            g_color_red  = random_num(0,255)
            g_color_green = random_num(0,255)
            g_color_blue  = random_num(0,255)
        }
        default:
        {
            g_color_red  = 255
            g_color_green = 255
            g_color_blue  = 255
        }
    }
   
    return FMRES_IGNORED
}

// The grenade emits the explosion sound
public fw_emitsound(ent,chan,const sound[])
{
    if (!pev_valid(ent))
        return FMRES_IGNORED
   
    if (contain(sound, "flash") == -1)
        return FMRES_IGNORED
   
    static classname[32]
    pev(ent, pev_classname, classname, 31)
    if (!equal(classname, "grenade"))
        return FMRES_IGNORED
   
    // Good time to reset the flasher and the ent id
    g_flash_ent = 0
    g_flasher = 0
    g_allow_forward = true
   
    if (task_exists(g_ent_owner[ent] + REMAIN_TASK))
        remove_task(g_ent_owner[ent] + REMAIN_TASK)
   
    // Show the user how many flashes he has left to throw before before beeing blocked
    set_task(0.2,"remaining_flashes",g_ent_owner[ent] + REMAIN_TASK)
   
    // Good time to reset the owner of the entity and the flashed players
    g_ent_owner[ent] = 0
   
    for (new i=0;i<33;i++)
    {
        g_block_flash[i] = false
    }
   
    if (get_option(pc_frc_dlight) != 0)
    {
        new Float:origin[3]
        pev(ent,pev_origin,origin)
       
        switch (get_option(pc_frc_mcolor))
        {
            case 0,3:
            {
                dynamic_light(origin)
            }
            case 1,2:
            {
                dynamic_light(origin,g_color_red,g_color_green,g_color_blue)
            }
            default:
            {
                dynamic_light(origin)
            }
        }
    }
   
    return FMRES_IGNORED
}

// Let's find the victims
public fw_findentityinsphere(start, Float:origin[3], Float:radius)
{
    if (radius != 1500.0 || g_flash_ent == 0)
        return FMRES_IGNORED
   
    if (g_allow_forward == false)
    {
        forward_return(FMV_CELL,-1)
        return FMRES_SUPERCEDE
    }
   
    static hit, trace, Float:user_origin[3], Float:fraction, Float:angles[3]
   
    if (get_option(pc_frc_bug) != 0)
    {
        while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, radius)))
        {
            // Hit a non- or dead-player
            if (!is_user_alive(hit))
            {
                forward_return(FMV_CELL, hit)
                return FMRES_SUPERCEDE
            }
           
            // Get the origin of the players head
            engfunc(EngFunc_GetBonePosition, hit, BONE_HEAD, user_origin, angles)
           
            // Traceline from the player origin to the grenade origin
            engfunc(EngFunc_TraceLine, user_origin, origin, DONT_IGNORE_MONSTERS, hit, trace)
           
            get_tr2(trace, TR_flFraction, fraction)
           
            // If the trace didn't hit anything in it's way then we're cool!
            if (fraction == 1.0 && g_block_flash[hit] == false)
            {
                forward_return(FMV_CELL, hit)
                return FMRES_SUPERCEDE
            }
        }
    }
    else
    {
        while ((hit = engfunc(EngFunc_FindEntityInSphere, hit, origin, radius)))
        {
            if (!is_user_alive(hit))
            {
                forward_return(FMV_CELL, hit)
                return FMRES_SUPERCEDE
            }
           
            if (g_block_flash[hit] == false)
            {
                forward_return(FMV_CELL, hit)
                return FMRES_SUPERCEDE
            }
        }
    }
   
    // Cancel the check, if nothing was hit
    forward_return(FMV_CELL, -1)
    return FMRES_SUPERCEDE
}

// We are in trouble!
public remaining_flashes(id)
{
    id -= REMAIN_TASK
   
    if (!(get_option(pc_frc_admin) != 0 && get_option(pc_frc_limit) >= g_flash_mon[id] >= (get_option(pc_frc_limit) - 2) && get_option(pc_frc_punish) != 0 && get_option(pc_frc_warn) != 0))
        return PLUGIN_CONTINUE
   
    new message[128]
   
    format(message,127,"^x04[Team Flash Control] ^x01%L ^x03%d ", id, "FLASHER_MSG_LEFT1",get_option(pc_frc_limit) - g_flash_mon[id] + 1)
    format(message,127,"%s^x01%L",message, id, "FLASHER_MSG_LEFT2")
   
    colored_msg(id,message)
   
    return PLUGIN_CONTINUE
}

// Is the entity a flash grenade??? hmmm...
public bool:is_flash(ent)
{
    if (!pev_valid(ent)) return false
    static classname[32]
    static model[32]
    pev(ent, pev_classname, classname, 31)
    pev(ent,pev_model,model,31)
    return (equal(classname, "grenade") && containi(model,"w_flashbang.mdl") != -1) ? true : false
}

// The dynamic light of the flashbang, it adds a little bit of realism
dynamic_light(Float:origin[3], red = 255, green = 255, blue = 255)
{
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    write_byte(TE_DLIGHT) // The light effect
    engfunc(EngFunc_WriteCoord,origin[0]) // x
    engfunc(EngFunc_WriteCoord,origin[1]) // y
    engfunc(EngFunc_WriteCoord,origin[2]) // z
    write_byte(75) // radius
    write_byte(red) // r
    write_byte(green) // g
    write_byte(blue) // b
    write_byte(4) // life
    write_byte(120) // decay rate
    message_end()
}

// The colored flash! The more colors the better
flash(id, duration, holdtime, flags, red = 255, green = 255, blue = 255, alpha)
{
    message_begin(MSG_ONE, scrfade, {0,0,0}, id)
    write_short(duration)
    write_short(holdtime)
    write_short(flags)
    write_byte(red)
    write_byte(green)
    write_byte(blue)
    write_byte(alpha)
    message_end()
}

eflash(id, duration, holdtime, flags, red = 255, green = 255, blue = 255, alpha)
{
    emessage_begin(MSG_ONE, scrfade, {0,0,0}, id)
    ewrite_short(duration)
    ewrite_short(holdtime)
    ewrite_short(flags)
    ewrite_byte(red)
    ewrite_byte(green)
    ewrite_byte(blue)
    ewrite_byte(alpha)
    emessage_end()
}

// Just the colored message ...  don't you like colors?
public colored_msg(id,msg[])
{
    message_begin(MSG_ONE, saytext, {0,0,0}, id)
    write_byte(id)
    write_string(msg)
    message_end()
}

// Similar to pev() just returns a float value
public Float:pev_float(index,type)
{
    new Float:nr
    pev(index,type,nr)
    return nr
}

// Message to admins, they need to know ...
public admin_message(const name[], const message[])
{
    new message2[192]
    static players[32],num
    get_players(players, num)
   
    format(message2, 191, "(ADMINS) %s : %s", name, message)
   
    for (new i = 0; i < num; ++i)
    {
        if (access(players[i], ADMIN_CHAT))
            client_print(players[i], print_chat, "%s", message2)
    }
}

// Control panel system functions/stocks
register_option(Option:option, const name[300], const string[], OptionType:type = OPTION_TOGGLE, flags = 0, Float:value = 0.0)
{
    pcvars[option] = register_cvar(name, string, flags, value)
    option_type[option] = type
    option_information[option] = name
}

register_option_value(Option:option, values[100])
{
    if (option_type[option] == OPTION_TOGGLE)
        return
   
    option_value[option] = values
}

public get_option(Option:option)
{
    return get_pcvar_num(pcvars[option])
}

public toggle_option(Option:option)
{
    set_pcvar_num(pcvars[option], !get_option(option))
}

public Float:get_option_float(Option:option)
{
    return get_pcvar_float(pcvars[option])
}

public set_option_float(Option:option, Float:set_to)
{
    set_pcvar_float(pcvars[option], set_to)
}


public set_option_cell(Option:option, set_to)
{
    set_pcvar_num(pcvars[option], set_to)
}


ot_207 02-23-2009 10:41

Re: Flashbang Remote Control v9.1
 
Thanks :). Will add multilang support to that menu in the future.

crazyeffect 03-11-2009 13:17

Re: Flashbang Remote Control v9.1
 
Dutch translation:

Quote:

[en]
FLASHER_MSG_PART = Je heb een teammaat blind gemaakt
FLASHER_MSG_TOTAL = Je hebt een teammade helemaal blind gemaakt
THE_FLASHED_MSG = Je bent geblindeerd door
ADMIN_MSG = %s heeft een teammaat verblind (%s)
BLOCK_USER_FLASH_MSG = %s is gestraft omdat hij te veel teammaten verblind heeft
FLASHER_MSG_LEFT1 = Als je nog 1
FLASHER_MSG_LEFT2 = teammaat verblind word je gestraft!

ot_207 04-03-2009 09:42

Re: Flashbang Remote Control v9.1
 
Quote:

Originally Posted by crazyeffect (Post 778552)
Dutch translation:

Thanks :)

3JIou-TaTapuH 06-07-2009 20:40

Re: Flashbang Remote Control v9.1
 
This plugin is outstanding

Alexik 08-09-2009 05:41

Re: Flashbang Remote Control v9.1
 
I just got some error that made my server crash.

Code:

L 08/09/2009 - 06:01:57: Start of error session.
L 08/09/2009 - 06:01:57: Info (map "fy_snow_orange") (file "addons/amxmodx/logs/error_20090809.log")
L 08/09/2009 - 06:01:57: [AMXX] Displaying debug trace (plugin "flashbang_remote_control.amxx")
L 08/09/2009 - 06:01:57: [AMXX] Run time error 4: index out of bounds
L 08/09/2009 - 06:01:57: [AMXX]    [0] 31789.attach::fw_setmodel (line 698)
L 08/09/2009 - 06:01:58: [AMXX] Displaying debug trace (plugin "flashbang_remote_control.amxx")
L 08/09/2009 - 06:01:58: [AMXX] Run time error 4: index out of bounds
L 08/09/2009 - 06:01:58: [AMXX]    [0] 31789.attach::fw_think (line 713)
L 08/09/2009 - 06:01:58: [AMXX]    [1] 31789.attach::fw_think (line 710)
L 08/09/2009 - 06:01:58: [AMXX] Displaying debug trace (plugin "flashbang_remote_control.amxx")
L 08/09/2009 - 06:01:58: [AMXX] Run time error 4: index out of bounds
L 08/09/2009 - 06:01:58: [AMXX]    [0] 31789.attach::fw_think (line 713)
L 08/09/2009 - 06:01:58: [AMXX]    [1] 31789.attach::fw_think (line 710)
L 08/09/2009 - 06:01:58: [AMXX] Displaying debug trace (plugin "flashbang_remote_control.amxx")
L 08/09/2009 - 06:01:58: [AMXX] Run time error 4: index out of bounds
L 08/09/2009 - 06:01:58: [AMXX]    [0] 31789.attach::fw_emitsound (line 798)

The thing is the sound is disabled (even though, the sound is where it should be). Everything except the "block_team_flash" option is disabled (the dynamic light, the colors, everything except that options).

What is there to do ? (I know this might not be answered, but who knows).

Thank you,

Alex.

Jack86 08-09-2009 05:59

Re: Flashbang Remote Control v9.1
 
If u want only that feature use some plugin like this one http://forums.alliedmods.net/showthread.php?t=16992


All times are GMT -4. The time now is 10:25.

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