Raised This Month: $114 Target: $400
 28% 

TFC Nades for Flag Capture


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Team Fortress Classic        Category:   Gameplay        Approver:   BAILOPAN (72)
White Bishop
Junior Member
Join Date: Apr 2008
Old 04-12-2008 , 08:12   TFC Nades for Flag Capture
Reply With Quote #1

This pluging is for use with TFC. When enabled using the cvar
amx_nadesforcap_enable, capping the flag will restock your grenades.

by Bishop


CVARS
=============
amx_nadesforcap_enable [1|0] - Enable/Disable grenade restock for flag capture (Default: 1)

nadesforcap.sma code:
Code:
/* *============================================================================================= *  AMX Mod X script * *       This pluging is for use with TFC.  When enabled using the cvar *       amx_nadesforcap_enable, capping the flag will restock your grenades. * *       by Bishop * * *  CVARS *  ============= *  amx_nadesforcap_enable [1|0] - Enable/Disable grenade refill for flag capture (Default: 1) * * *  VERSIONS *  ======== *  1.0   (4-11-2008) * *============================================================================================= */ #include <amxmodx> #include <amxmisc> #include <tfcx> #include <engine> #define PLUGIN "TFC Nades for Flag Cap" #define VERSION "1.0" #define AUTHOR "Bishop" new enabled               // cvar variable for enabling nade refill for flag cap public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_logevent("nadesforcap", 3, "1=triggered", "2&dropoff");     enabled = register_cvar("amx_nadesforcap_enable","1")  } public nadesforcap() {     if (get_pcvar_num(enabled) == 0) return PLUGIN_HANDLED        // Check enabled cvar     new loguser[80], cappername[64]     read_logargv(0,loguser,79)                                    // Get id from log message     parse_loguser(loguser, cappername, 63)     new capperid = get_user_index(cappername);     new class = entity_get_int(capperid, EV_INT_playerclass)      // Gets the player class     switch(class)     {         case 1:                                                   // Scout         {             tfc_setbammo(capperid, TFC_AMMO_NADE1, 3);             tfc_setbammo(capperid, TFC_AMMO_NADE2, 3);         }         case 2:                                                   // Sniper         {             tfc_setbammo(capperid, TFC_AMMO_NADE1, 4);         }         case 3, 4, 6:                                             // Solly, Demo, HW         {             tfc_setbammo(capperid, TFC_AMMO_NADE1, 4);             tfc_setbammo(capperid, TFC_AMMO_NADE2, 2);         }         case 5:                                                   // Medic         {             tfc_setbammo(capperid, TFC_AMMO_NADE1, 4);             tfc_setbammo(capperid, TFC_AMMO_NADE2, 3);         }                case 7, 8, 9:                                             // Pyro, Spy, Engy         {             tfc_setbammo(capperid, TFC_AMMO_NADE1, 4);             tfc_setbammo(capperid, TFC_AMMO_NADE2, 4);         }     }     client_print(capperid, print_chat, "%s, restocking your grenades for flag capture.", cappername);     return PLUGIN_CONTINUE; }
Attached Files
File Type: sma Get Plugin or Get Source (nadesforcap.sma - 1704 views - 2.6 KB)

Last edited by White Bishop; 04-20-2008 at 00:29.
White Bishop is offline
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 04-13-2008 , 18:16   Re: TFC Nades for Flag Capture
Reply With Quote #2

You should use the switch - case statement, rather than a long list of if / else if.

Look it up in the Scripting section of the docs. Other than that, nice idea.

Edit:
Also, I find the get_user_class() -function quite inefficient, since it's just a function that only calls one function. In another words,
Code:
new class = entity_get_int(id, EV_INT_playerclass);

... should do.
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
Old 04-13-2008, 18:58
Hawk552
This message has been deleted by BAILOPAN.
White Bishop
Junior Member
Join Date: Apr 2008
Old 04-15-2008 , 04:52   Re: TFC Nades for Flag Capture
Reply With Quote #3

I made all the changes you suggested and updated the first post.

Thanks for the tips on the switch statement.

Last edited by White Bishop; 04-20-2008 at 00:30.
White Bishop is offline
Pro Patria Finland
Senior Member
Join Date: Apr 2006
Location: BaronPub.com
Old 04-17-2008 , 15:31   Re: TFC Nades for Flag Capture
Reply With Quote #4

http://wiki.amxmodx.org/Pawn_Tutorial#Switch_Statements

Check that, you can make it way shorter.

Otherwise, looks good to me.
__________________
I am not a number. I am Gordon Freeman!
Pro Patria Finland is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 03-25-2015 , 14:30   Re: TFC Nades for Flag Capture
Reply With Quote #5

Sharing my findings:

Code:
#include <amxmodx>

#define PLUGIN "test plugin"
#define VERSION "1"
#define AUTHOR "pizzahut"

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_event("HudText", "test1", "be")
	register_event("9", "test2", "be")
	register_logevent("test3", 3, "1=triggered")
}

public test1(id)
{
	static text[32]
	read_data(1, text, charsmax(text))
	client_print(0, print_chat, "HudText: id=%d, message=%s", id, text)
}

public test2(id)
{
	static text[32]
	read_data(1, text, charsmax(text))
	client_print(0, print_chat, "ClientExec: id=%d, message=%s", id, text)
}

public test3()
{
	static user[80], name[64], id, text[32]
	read_logargv(0, user, charsmax(user))
	parse_loguser(user, name, 63)
	id = get_user_index(name);
	read_logargv(2, text, charsmax(text))
	client_print(0, print_chat, "Log event: id=%d triggered %s", id, text)
}
Code:
#define ClientExec "9"

monkey_l

Log event: id=1 triggered Red Flag
HudText: id=1, message=You have the ENEMY flag!
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered Blue Cap Point
HudText: id=1, message=You captured the
ClientExec: id=1, message=spk "!CTF_YOUCAP"

mulch_trench_lg

Log event: id=1 triggered Red Flag
HudText: id=1, message=You have the ENEMY flag!
ClientExec: id=1, message=spk "mulch/buzwarn youhave"

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#2fort_you_capped_flag
ClientExec: id=1, message=spk "mulch/doop youcap"

2fort

Log event: id=1 triggered Red Flag
HudText: id=1, message=#2fort_you_take_enemy_flag
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#2fort_you_capped_flag
ClientExec: id=1, message=spk "!CTF_YOUCAP"

avanti

HudText: id=1, message=#italy_attacker_1
Log event: id=1 triggered Flag 1
HudText: id=1, message=#italy_take_flag_to_1

Log event: id=1 triggered Capture Point 1
HudText: id=1, message=#italy_you_secure_cp1

badlands

Log event: id=1 triggered Red Flag
HudText: id=1, message=#ctf_yougotflag
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#2fort_you_capped_flag
ClientExec: id=1, message=spk "!CTF_YOUCAP"

casbah

Log event: id=1 triggered Red Flag
HudText: id=1, message=#ctf_yougotflag
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#2fort_you_capped_flag
ClientExec: id=1, message=spk "!CTF_YOUCAP"

crossover2

Log event: id=1 triggered Red Flag
HudText: id=1, message=#ctf_yougotflag
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#2fort_you_capped_flag
ClientExec: id=1, message=spk "!CTF_YOUCAP"

cz2

Log event: id=1 triggered blue flag 3

Log event: id=1 triggered #cz_bcap1
ClientExec: id=1, message=spk "!CZ_GOTCP1"

dustbowl

Log event: id=1 triggered Flag 1
HudText: id=1, message=#dustbowl_take_flag_one

Log event: id=1 triggered Capture Point 1
Log event: id=1 triggered #dustbowl_blue_secures_one
ClientExec: id=1, message=spk "!DUST_CP1"
HudText: id=1, message=#dustbowl_you_secure_one

epicenter

Log event: id=1 triggered Blue Flag
HudText: id=1, message=#dblmint_you_got_flag

Log event: id=1 triggered Team 1 dropoff
HudText: id=1, message=#dblmint_you_capped_flag
ClientExec: id=1, message=spk "!DBLMINT_YOUCAP"

flagrun

stealing red flag

Log event: id=1 triggered spawn resupply
Log event: id=1 triggered flag 1 red
HudText: id=1, message=#war_u_stole_1
ClientExec: id=1, message=spk "!WAR_STOLE_1"
Log event: id=1 triggered flag 1
Log event: id=1 triggered neutral 1 on
Log event: id=1 triggered red 1 off

capping red flag

Log event: id=1 triggered blue 1 capture point
Log event: id=1 triggered blue steals 1 result
HudText: id=1, message=#war_usec_flag1
ClientExec: id=1, message=spk "!WAR_YSEC_1"
Log event: id=1 triggered neutral 1 off
Log event: id=1 triggered blue 1 on
Log event: id=1 triggered call blue endgame check 1

getting neutral flag

Log event: id=1 triggered flag 2 neutral
HudText: id=1, message=#war_uhave_flag_2
ClientExec: id=1, message=spk "!WAR_HAVE_2"
Log event: id=1 triggered flag 2

failing to get another neutral flag while carrying one

Log event: id=1 triggered flag 3 neutral
Log event: id=1 triggered flag 3 neutral
Log event: id=1 triggered flag 3 neutral
[...]

capping neutral flag

Log event: id=1 triggered blue 2 capture point
Log event: id=1 triggered blue 2 capture result
HudText: id=1, message=#war_usec_flag2
ClientExec: id=1, message=spk "!WAR_YSEC_2"
Log event: id=1 triggered blue 2 on
Log event: id=1 triggered neutral 2 off
Log event: id=1 triggered call blue endgame check 2

hunted

Log event: id=1 triggered #hunted_target_scores
HudText: id=1, message=#hunted_target_scores

push

Log event: id=1 triggered flag

Log event: id=1 triggered blue score trigger
Log event: id=1 triggered #football_blue_netname_scores
HudText: id=1, message=#football_blue_scores
ClientExec: id=1, message=spk "!FBALL_BSCORE"

ravelin

Log event: id=1 triggered Blue Flag
HudText: id=1, message=You have the FLAG! Take it to t

Log event: id=1 triggered Red Capture Point
Log event: id=1 triggered  captured the RED base!
ClientExec: id=1, message=spk "!FBALL_BSCORE"
HudText: id=1, message=YOU captured the ENEMY base!

rock2

Log event: id=1 triggered goalitem
HudText: id=1, message=#rock_you_got_key
ClientExec: id=1, message=spk "!RK_TAKEKEY"

Log event: id=1 triggered rhand
ClientExec: id=1, message=spk "!RK_BSCORE"
HudText: id=1, message=#rock_blue_scores

warpath

Log event: id=1 triggered #cz_bcap2
ClientExec: id=1, message=spk "!CZ_GOTCP2"
Log event: id=1 triggered #blue cap, move red
Log event: id=1 triggered #blue cap, move blue

well

Log event: id=1 triggered team two flag
HudText: id=1, message=#well_got_enemy_flag
ClientExec: id=1, message=spk "!CTF_YOUGOTFLAG"

Log event: id=1 triggered team one dropoff
HudText: id=1, message=#well_capture
ClientExec: id=1, message=spk "!CTF_YOUCAP"

Last edited by pizzahut; 04-07-2015 at 08:45.
pizzahut is offline
Old 03-25-2015, 19:25
pizzahut
This message has been deleted by pizzahut. Reason: Removing alternate plugin from this thread.
White Bishop
Junior Member
Join Date: Apr 2008
Old 04-06-2015 , 04:39   Re: TFC Nades for Flag Capture
Reply With Quote #6

The original plugin works without error and is used in several TFC servers. If you are adding features or making a new plugin perhaps you should start a new thread or at least clarify why you are changing the original code.
__________________

Last edited by White Bishop; 04-06-2015 at 04:39.
White Bishop is offline
pizzahut
Senior Member
Join Date: Oct 2004
Old 04-07-2015 , 09:11   Re: TFC Nades for Flag Capture
Reply With Quote #7

The reason is that your plugin doesn't work with all maps, as the log message can vary. It's not a big deal though, the vast majority of regular CTF maps (2fort style) work fine. Great plugin btw, players like it a lot!

Last edited by pizzahut; 04-08-2015 at 08:56.
pizzahut is offline
White Bishop
Junior Member
Join Date: Apr 2008
Old 10-22-2017 , 02:46   Re: TFC Nades for Flag Capture
Reply With Quote #8

Version 1.1 added support for these TFC maps: monkey_l, avanti, ravelin, flagrun, rock2
(Thanks to pizzahut)
Attached Files
File Type: sma Get Plugin or Get Source (nadesforcap.sma - 545 views - 3.0 KB)
__________________
White Bishop is offline
Relaxing
Veteran Member
Join Date: Jun 2016
Location: Catlands, NY
Old 10-22-2017 , 11:27   Re: TFC Nades for Flag Capture
Reply With Quote #9

1.1 update took 9 years. BTW this is gr8.
__________________
Relaxing 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 11:58.


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