AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved c4 experience (https://forums.alliedmods.net/showthread.php?t=320602)

DJEarthQuake 12-30-2019 10:06

c4 experience
 
C4 time is adjusted based on experience (frags).


Script adjusts the c4 time based on frags. It was off until I used Cstrike module. Adjusting mp_c4timer wasn't in real life.

https://play-lh.googleusercontent.co...w2458-h1217-rw

RaZ_HU 12-31-2019 12:42

Re: c4 experience
 
You should really ident your code.
What happens if 2 or more player gets to C4?
Team filtering is missing too.

DJEarthQuake 12-31-2019 14:08

Re: c4 experience
 
Hey buddy first off thanks for responding. I hope you like the 'concept'.

Quote:

Originally Posted by RaZ_HU (Post 2678560)
You should really ident your code.

ident or indent?
The code is indented to 4. Post what you think is indented with the same code please. Indentation can be whatever you want. Complaints about it really need examples furnished.
Quote:

Originally Posted by RaZ_HU (Post 2678560)
What happens if 2 or more player gets to C4?

Bartime controls this so it's locked down to solely the defuser's frags.
Quote:

Originally Posted by RaZ_HU (Post 2678560)
Team filtering is missing too.

The planter can have the converse and obtained via bartime and or parsing the log. Subtract time when planting based on frags or added if negative kills exist etc.

Source has an 'ideas section' and this does not so I pasted here as it is not a 'request' nor a 'snippets/tutorial' piece. This is more of a unfinished spinoff idea I wanted to share with the community to develop into whatever.

RaZ_HU 12-31-2019 15:34

Re: c4 experience
 
Quote:

Originally Posted by DJEarthQuake (Post 2678566)
ident or indent?
The code is indented to 4. Post what you think is indented with the same code please. Indentation can be whatever you want. Complaints about it really need examples furnished.

Sorry, typo, I meant indent of course: tabs and spaces and empty line to keep it readable.

IDENTIFY should be ran even if there is no bomb on the map (outside of the check), to keep the plugin list organized.
COLOR is not used.
Why do search for vehicles in precache if you don't do anything with the value returned by the search?

Code:

        #include amxmodx
        #include amxmisc
        #include engine
        #include fakemeta
        #define COLOR random_num(0,255)  // Not used
        ///C4 time is adjusted based on defuser's experience. # frags.
        #define IDENTIFY register_plugin("c4 Experience","1.0","SPiNX")
       
        static Float:g_fProtected_VIP = 300.0;
        static Float:g_fNormal_Armor = 100.0;
        static Float:g_fExperience_offset = 1.03;
        static Float:g_fUninhibited_Walk = 272.0;
        new g_iC4_base_time, g_szName[33], g_sprite;
       
        public plugin_init()
        {
                IDENTIFY; // We need to keep the plugin list readable
                if(engfunc(EngFunc_FindEntityByString, -1, "classname","func_bomb_target") || engfunc(EngFunc_FindEntityByString, -1, "classname","info_bomb_target"))
                {
                        register_logevent("fnReset_C4",2,"1=Round_Start");
                        register_event("Money","fnReset_C4", "b")
                        register_event("BarTime", "fnDefusal", "be", "1=5", "1=10");
                        g_iC4_base_time = get_cvar_num("mp_c4timer");
                }
                else
                {
                        pause( "a" );
                }
        }
       
        public plugin_precache()
        {
                find_ent_by_class(-1,"func_vehicle"); // Why do you get a value if not used?
                g_sprite = precache_model("sprites/smoke.spr");
        }
       
        public fnReset_C4(id)
        {
                set_cvar_num("mp_c4timer",g_iC4_base_time);
                if( (get_user_armor(id)) > g_fNormal_Armor)
                {
                        entity_set_float(id, EV_FL_armorvalue, g_fNormal_Armor );
                }
        }
       
        public fnDefusal(id)
        {
                new Float:fC4_factor = get_user_frags(id)*g_fExperience_offset;
                new iSatchel_timer = floatround(g_iC4_base_time+fC4_factor);
                new iCar = find_ent_by_tname( -1, "func_vehicle");
               
                fn_iC4_proximity(id,iCar);
                entity_set_float(id, EV_FL_maxspeed, g_fUninhibited_Walk);
                set_cvar_num("mp_c4timer",iSatchel_timer);
                get_user_name(id,g_szName,charsmax (g_szName));
                client_print(0, print_chat, "C4 timer is now %i seconds due to the expertise of %s.", iSatchel_timer,g_szName);
        }
       
        public fn_iC4_proximity(id, iCar)
        {
                if(entity_range(id, iCar) <= 2000)
                {
                        entity_set_float(id, EV_FL_armorvalue, g_fProtected_VIP);
                        message_begin(0,23);
                        write_byte(TE_BEAMRING)
                        write_short(id)
                        write_short(iCar)
                        write_short(g_sprite)
                        write_byte(10)  //starting frame
                        write_byte(1) //frame rate in 0.1's
                        write_byte(50) //life in 0.1's
                        write_byte(200) //line width in 0.1's
                        write_byte(random_num(1,12)) //noise amplitude in 0.01's
                        write_byte(255)  //Red
                        write_byte(100) //Green
                        write_byte(25) //blue
                        write_byte(300) //brightness
                        write_byte(1) //scroll speed in 0.1's
                        message_end();
                }
        }
       
        ///NOTES:::
        //const m_bIsDefusing = 949;
        //set_pdata_bool(id, m_bIsDefusing, false)


Yes, the idea is good and unique, but most of the players are go by their head even if you tell them to do by objectives :D

OciXCrom 01-01-2020 09:17

Re: c4 experience
 
Quote:

Originally Posted by DJEarthQuake (Post 2678566)
Hey buddy first off thanks for responding. I hope you like the 'concept'.

The code is indented to 4. Post what you think is indented with the same code please. Indentation can be whatever you want. Complaints about it really need examples furnished.

I don't think that putting 4 blank spaces in front of every line counts as indentation and helps the human eye in any way.

PHP Code:

if(some_check)
{
can
if(some_check)
{
you
if(some_check)
{
read
}
else if(
some_check)
{
this
}
else
{
without
if(some_check)
{
struggling
}
huh?
}
}
else
{
random code here...
}


=>

PHP Code:

if(some_check)
{
    
can
    
if(some_check)
    {
        
you
        
if(some_check)
        {
            
read
        
}
        else if(
some_check)
        {
            
this
        
}
        else
        {
            
without
            
if(some_check)
            {
                
struggling
            
}
            
huh?
        }
    }
    else
    {
        
random code here...
    }




All times are GMT -4. The time now is 15:09.

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