AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   C4 Taker (https://forums.alliedmods.net/showthread.php?t=283154)

hellmonja 05-26-2016 16:14

C4 Taker
 
3 Attachment(s)
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.:bacon!:
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.

ComedyShotsGamer 05-26-2016 16:34

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
Good Job!

Black Rose 05-26-2016 16:52

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
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.

EFFx 05-26-2016 17:33

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
Nothing for say, just two words:

Nice job

JusTGo 05-26-2016 18:12

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
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.

EFFx 05-26-2016 19:10

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
Will be perfectly if we can take c4 with players, no only bots.

hellmonja 05-27-2016 14:35

Re: C4 Bot Taker - joaquimandrade and ConnorMcLeod
 
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 ...

HamletEagle 05-27-2016 15:44

Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
 
getLookingAt can be replaced with get_user_aiming. In fact, it's [almost] the same code.

hellmonja 05-27-2016 21:40

Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
 
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.

siriusmd99 05-28-2016 03:45

Re: C4 Bot Taker - joaquimandrade & ConnorMcLeod
 
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.


All times are GMT -4. The time now is 20:29.

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