Raised This Month: $7 Target: $400
 1% 

C4 Taker


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Gameplay        Approver:   HamletEagle (36)
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-26-2016 , 16:14   C4 Taker
Reply With Quote #1

C4 TAKER v1.09
(For lack of a better name)

Description:
Enables you to take the C4 from a teammate by aiming at him/her and pressing the USE key. (default 'E')
This is especially useful when playing with bots either for gameplay or debug purposes...

Requires:
amxmodx | fakemeta_util | hamsandwich

CVARs:
  • c4t_admin_only [default 1] - limits the plugin for admin use only. Set to '0' so that everyone can take the C4. Set to '2' and admin gets the C4 automatically every start of a round.
  • c4t_take_from_humans [default 0 ]- set to '1' to enable to take C4 from human players
  • c4t_max_distance [default 120] - max distance for the take
  • c4t_hud [default 5] - number of instances the HUD Message appears. Set to '0' to disable. Can be set to '9999...'.

Notes:
  • Only Admins can take C4 by default
  • Max distance of the HUD message are the same which means it may serve as an indicator of sorts.
  • HUD message appears for certain amount of instances (set by a cvar) for each human player. After that it is disabled.
    I did this because I found the HUD message annoying after a couple of rounds.
  • Based off joaquimandrade's and ConnorMcLeod's "EasyWeaponsTrade" plugin.
  • First submitted plugin. Please don't hang me. Just take my bacon if you want.
Changelog:

v1.09
  • Removed a potential infinite loop
v1.08
  • More optimization
  • A few more inconsistencies fixed
v1.07
  • Code consistency. Courtesy for those wanting to learn the script.
v1.06
  • Code optimization.
v1.05
  • c4t_admin_only cvar now has 3 modes
0 - Disables admin_only. Everyone can take the C4.
1 - Enabled. Only admin gets to take the C4 from a teammate.
2 - Every start of a round, the admin always gets the C4.
  • Carrier gets a HUD message when C4 is taken from them and who took it.
v1.04
  • Added CVAR 'admin_only' which limits use for admins only. It is set to '1' by default
  • HUD Message disappears immediately when you've stopped looking at the bomb carrier
  • Changed max distance default from 200 to 120
v1.03
  • New plugin name
  • Removed unused 'MaxSlots' variable
  • Removed some redundancies on EventStatusValue_PlayerID
  • EventStatusValue_PlayerID now checks first if aiming player is alive
  • Switched from CVARS to PCVARS because my code is horrible
  • HUD Message now enabled when 'c4t_take_from_human' cvar is enabled
v1.02
  • Replaced getLookingAt function with native get_user_aiming
v1.01
  • Added 3 cvars
  • Fixed code to prevent dead players from getting the C4
  • Added code that resets the HUD Message limiter when player disconnects
v1.0 - First release.

SPECIAL THANKS:

To joaquimandrade & ConnorMcLeod for their EasyWeaponsTrade that inspired the idea.
To wickked & JusTGo for helping me with the HUD message.
To VEN for his bomb scripting tutorial.
To HamletEagle for helping me optimize the script.
Attached Images
File Type: jpg screencap.jpg (75.5 KB, 2177 views)
Attached Files
File Type: sma Get Plugin or Get Source (c4_taker.sma - 3318 views - 4.6 KB)

Last edited by hellmonja; 06-27-2016 at 19:48. Reason: Update v1.09
hellmonja is offline
ComedyShotsGamer
Senior Member
Join Date: Mar 2016
Old 05-26-2016 , 16:34   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #2

Good Job!
ComedyShotsGamer is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-26-2016 , 16:52   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #3

const MaxSlots = 32
get_maxplayers(), unless pHit only returns players, then it's not even necessary to check.

new Float:MaxDistance = 200.0
cvar is never a bad idea, no big deal though.

num[] is never reset for new players that might inherit an old id.

Is it possible to aim at a dead player in StatusValue? (I don't actually know. I'm just checking if you checked)

Other than that, afaik, looks good.
__________________
Black Rose is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-26-2016 , 17:33   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #4

Nothing for say, just two words:

Nice job
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 05-26-2016 , 18:12   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #5

PHP Code:
public Use_Button(id//Function when you press 'E' or the USE key
{
    if(
is_user_connected(id))
        if(
pev(id,pev_button) & IN_USE//Checks if you pressed the USE key
            
Take_C4(id); //Calls function to take C4

>>>

PHP Code:
public Use_Button(id//Function when you press 'E' or the USE key
{
    if(
is_user_alive(id))
        if(
pev(id,pev_button) & IN_USE//Checks if you pressed the USE key
            
Take_C4(id); //Calls function to take C4

or dead players may get the c4 lol.
__________________
JusTGo is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-26-2016 , 19:10   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #6

Will be perfectly if we can take c4 with players, no only bots.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-27-2016 , 14:35   Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
Reply With Quote #7

Hey guys! I'm glad you liked the idea. Unfortunately it's going to be a busy week at work. I'll try to find some time edit the plugin.

I'm gonna add a couple of cvars for in game customization but as for anything in the 'getLookingAt' function, I'm going to need a bit help because that's the part I didn't write. I got straight from the EasyWeaponsTrade plugin. Don't worry, I'll just drop a few lines here if I run into problems.

Probably I'll start with the cvars tomorrow. Till then ...
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-27-2016 , 15:44   Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
Reply With Quote #8

getLookingAt can be replaced with get_user_aiming. In fact, it's [almost] the same code.
__________________

Last edited by HamletEagle; 05-27-2016 at 15:45.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-27-2016 , 21:40   Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
Reply With Quote #9

UPDATE 1.01
Ok guys I added 3 cvars for your gaming pleasure:

Quote:
c4bt_take_from_humans [default 0 ]- set to '1' to enable to take C4 from human players
c4bt_max_distance [default 200] - max distance for the take
c4bt_hud [default 5] - number of instances the HUD Message appears. Set to '0' to disable. Can be set to '9999...'.
Now it is possible for it to work with humans.

Use_Button function now looks like this, like JusTGo suggested:
PHP Code:
public Use_Button(id//Function when you press 'E' or the USE key
{
    if(
is_user_alive(id))
        if(
pev(id,pev_button) & IN_USE//Checks if you pressed the USE key
            
Take_C4(id); //Calls function to take C4

Added a code when player disconnects resets num[] to 0 just as Black Rose advised:
PHP Code:
public client_disconnect(idnum[id] = //Resets 'num' to 0 when a player disconnects 
I studied some codes involving player disconnections. Is it really this simple? Sorry, still a noob.

StatusValue, as far as I know, do not trigger on dead players. The names and health percentages just don't show up.

As for this:
Quote:
const MaxSlots = 32
get_maxplayers(), unless pHit only returns players, then it's not even necessary to check.
I have no idea as of now...

EDIT:
====

In light of what Hamlet has just told me, I will next attempt to replace getLookingAt with get_user_aiming in an effort to make the plugin more efficient...

UPDATE v1.02
Replaced getLookingAt function with native get_user_aiming.

Last edited by hellmonja; 05-28-2016 at 02:13.
hellmonja is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-28-2016 , 03:45   Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
Reply With Quote #10

Can you add a feature (for admins) to take c4 from a player and give to another.
amx_takebmb player_with_bomb target_player

Because if a noob doesn't plant it's annoying to find him and take c4 with aim.

BTW, nice plugin.
siriusmd99 is offline
Reply


Thread Tools
Display Modes

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 00:43.


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