Skip to content

Commit f409dff

Browse files
authored
0.0.17
Added cvar fb2_forceswitch, when set to 1, after every feedback round we switch maps (1 by default) Added command "sm_fbroundnow", Forces the fbround asap, no resets, no delays. Could be buggy, needs testing, Also reacts to the cvar fb2_forceswitch. Removed telefragging during FB rounds Possibly made the initial hud text more consistent.
1 parent bf76954 commit f409dff

File tree

1 file changed

+74
-34
lines changed

1 file changed

+74
-34
lines changed

scripting/feedback2.sp

Lines changed: 74 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/* Defines */
4242
#define PLUGIN_AUTHOR "PigPig"
43-
#define PLUGIN_VERSION "0.0.16"
43+
#define PLUGIN_VERSION "0.0.17"
4444

4545

4646
#include <sourcemod>
@@ -136,6 +136,7 @@ enum
136136
FB_CVAR_DOWNTIME_FORCEFB,
137137
FB_CVAR_DOWNTIME_FORCEFB_ARENA,
138138
FB_CVAR_ALLOWMAP_SETTINGS,
139+
FB_CVAR_FBNEXTROUND_FORCESWITCH,
139140
Version
140141
}
141142
ConVar cvarList[Version + 1];
@@ -217,6 +218,7 @@ public void OnPluginStart()
217218
//Commands
218219
RegAdminCmd("sm_fbround", Command_FB_Round_Enabled, ADMFLAG_KICK, "Enable or disable FB rounds [TRUE/FALSE][1/0][YES/NO]");
219220
RegAdminCmd("sm_fbnextround", Command_Fb_Next_RoundToggle, ADMFLAG_KICK, "Force FB round after this round [TRUE/FALSE][1/0][YES/NO]");
221+
RegAdminCmd("sm_fbroundnow", Command_Fb_Now, ADMFLAG_KICK, "Force a fb round NOW");
220222

221223

222224
RegAdminCmd("sm_fbround_forceend", Command_Fb_Cancel_Round, ADMFLAG_KICK, "Enforce the death of an fb round");
@@ -231,7 +233,7 @@ public void OnPluginStart()
231233
RegConsoleCmd("sm_fbrh", Command_FBround_Help, "Tellme tellme.");
232234
RegConsoleCmd("sm_walkspeed", Command_walkspeed, "Change your walk speed during a fb round (HU)");
233235

234-
RegConsoleCmd("sm_fbmedic",Command_Medics, "Return to any player how many medics are on either team. (Useful if you cannot see the enemy medic count and want to switch to counter theirs)");
236+
RegConsoleCmd("sm_fbmedic", Command_Swag, "Return the medic count of each team");
235237
RegConsoleCmd("sm_fbdrawline",Command_Drawline, "Return the length in hammer units of how long a sightline is.");
236238

237239
#if defined DEBUG
@@ -243,6 +245,7 @@ public void OnPluginStart()
243245
cvarList[FB_CVAR_DOWNTIME_FORCEFB_ARENA] = CreateConVar("fb2_triggertime_arena", "60" , "How many seconds left should we trigger an expected map end FOR ARENA MODE", FCVAR_NOTIFY, true, 30.0, true, 1200.0);//Min / Max (30 seconds / 20 minutes)
244246
cvarList[FB_CVAR_DOWNTIME_FORCEFB] = CreateConVar("fb2_triggertime", "300" , "How many seconds left should we trigger an expected map end.", FCVAR_NOTIFY, true, 30.0, true, 1200.0);//Min / Max (30 seconds / 20 minutes)
245247
cvarList[FB_CVAR_ALLOWMAP_SETTINGS] = CreateConVar("fb2_mapcontrol", "1" , "How much control do we give maps over our plugin.", FCVAR_NOTIFY, true, 0.0, true, 1.0);//false,true.
248+
cvarList[FB_CVAR_FBNEXTROUND_FORCESWITCH] = CreateConVar("fb2_forceswitch", "1" , "If host uses !fbnextround, should we switch maps after that round is over?", FCVAR_NOTIFY, true, 0.0, true, 1.0);//false,true.
246249

247250
//instantiate arrays
248251
SpawnPointNames = new ArrayList(512);
@@ -252,8 +255,18 @@ public void OnPluginStart()
252255

253256

254257
clFbRoundWalkSpeed = RegClientCookie("fb_PlayerWalkSpeed", "The players walk speed during fb rounds.", CookieAccess_Protected);
258+
259+
for(int iClient = 0; iClient < MaxClients + 1; iClient++)
260+
{
261+
if(IsValidClient(iClient))
262+
SDKHook(iClient, SDKHook_OnTakeDamage, Event_OnTakeDamage);
263+
}
255264

256265
}
266+
public OnClientPostAdminCheck(client)//"Called once a client is authorized and fully in-game, and after all post-connection authorizations have been performed." https://sm.alliedmods.net/new-api/clients/OnClientPostAdminCheck
267+
{
268+
SDKHook(client, SDKHook_OnTakeDamage, Event_OnTakeDamage);
269+
}
257270
public OnConfigsExecuted()
258271
{
259272
//Precache
@@ -383,6 +396,19 @@ void SetPlayerFBMode(client, bool fbmode)
383396
SetEntProp(client, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PLAYER);
384397
}
385398
}
399+
public Action:Event_OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
400+
{
401+
if(!IsTestModeActive)
402+
return Plugin_Continue;
403+
404+
if (damagecustom == TF_CUSTOM_TELEFRAG)
405+
{
406+
damage = 0.0; // do no damage to telefragged client.
407+
return Plugin_Changed;
408+
}
409+
410+
return Plugin_Continue;
411+
}
386412
/*
387413
Use: Force a player to respawn
388414
*/
@@ -719,9 +745,8 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
719745
/* FB round setups */
720746
if(IsFBRoundBlocked())
721747
return;
722-
FbMapOverrideListings();
748+
723749
/* Warn players of imminent fb round */
724-
725750
if(ForceNextRoundTest)
726751
{
727752
ShowFeedbackRoundHud = false;
@@ -732,15 +757,24 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
732757
if(ForceNextRoundTest || FeedbackModeActive) //Tell people that FB rounds are a thing.
733758
{
734759
if(!IsTestModeTriggered)
760+
{
735761
CPrintToChatAll("\n{gold}[Feedback]{default} ~ Feedback rounds are active!");//Tell everyone about test mode.
762+
FbMapOverrideListings();
763+
}
736764
}
737765

738766

739767
if(!IsTestModeTriggered)//If not test mode, run normally
740768
{
741769
return;
742770
}
771+
StartFeedbackRound();
772+
773+
}
774+
void StartFeedbackRound()
775+
{
743776

777+
CPrintToChatAll("------------------------ \n{gold}[Feedback]{default} ~ Feedback round started: !sm_fbrh for more info\n\n {gold}>{default}You cannot kill anyone\n {gold}>{default}Leave as much feedback as possible.\n\n ------------------------");//Tell everyone about test mode.
744778
//Alltalk handle
745779

746780
AlltalkBuffer = GetConVarInt(FindConVar("sv_alltalk"));
@@ -753,9 +787,6 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
753787
IsTestModeActive = true;
754788
CreateTimer(1.0,ResetTimeLimit);//Remove tournament
755789

756-
CPrintToChatAll("------------------------ \n{gold}[Feedback]{default} ~ Feedback round started: !sm_fbrh for more info\n\n {gold}>{default}You cannot kill anyone\n {gold}>{default}Leave as much feedback as possible.\n\n ------------------------");//Tell everyone about test mode.
757-
758-
759790
//Set timer
760791
FeedbackTimer = cvarList[FB_CVAR_ALLOTED_TIME].IntValue;//Read the cvar and set the timer to the cvartime.
761792

@@ -855,14 +886,23 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
855886
if(IsValidClient(ic))
856887
{
857888
TF2_RespawnPlayer(ic);
858-
SetHudTextParams(-1.0, -0.5, 10.0, 255, 157, 0, 255); //Hud settings
859-
ShowSyncHudText(ic, feedbackHUD, "| FEEDBACK ROUND TRIGGERED | \n > | You cannot deal damage | Leave as much feedback as possible | <");//client, channel, text
860889
}
861890
}
862-
891+
CreateTimer(0.2,DelayHudText_IntoText);
863892
CleanUpTimer();//Incase it was already running. Clean it up before a new cycle.
864893
fbTimer = CreateTimer(1.0, CountdownTimer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);//DONT CARRY OVER MAP CHANGE! Oh and repeat.
865894
}
895+
public Action DelayHudText_IntoText(Handle timer, any serial)
896+
{
897+
for(int ic = 0; ic <= MaxClients + 1; ic++)
898+
{
899+
if(IsValidClient(ic))
900+
{
901+
SetHudTextParams(-1.0, -0.5, 10.0, 255, 157, 0, 255); //Hud settings
902+
ShowSyncHudText(ic, feedbackHUD, "| FEEDBACK ROUND TRIGGERED | \n > | You cannot deal damage | Leave as much feedback as possible | <");//client, channel, text
903+
}
904+
}
905+
}
866906
/*
867907
Use: Countdown timer logic
868908
Every second we count down and apply anything we need to be constantly true.
@@ -901,7 +941,7 @@ public Action CountdownTimer(Handle timer, any serial)
901941

902942
if(FeedbackTimer == 0)
903943
{
904-
if(GetMapTimeLeftInt() <= ReturnExpectedDowntime() || EndOfRoundFlags & FBFLAG_FORCELASTROUND)//time expired, nextmap.
944+
if(GetMapTimeLeftInt() <= ReturnExpectedDowntime() || EndOfRoundFlags & FBFLAG_FORCELASTROUND || cvarList[FB_CVAR_FBNEXTROUND_FORCESWITCH].IntValue == 1)//time expired, nextmap.
905945
{
906946
new String:mapString[256] = "cp_dustbowl";//If no nextmap, dustbowl
907947
GetNextMap(mapString, sizeof(mapString));
@@ -925,7 +965,7 @@ public Action CountdownTimer(Handle timer, any serial)
925965
void FeedbackTimerExpired()
926966
{
927967
ResetAlltalk();
928-
if(GetMapTimeLeftInt() <= ReturnExpectedDowntime() || EndOfRoundFlags & FBFLAG_FORCELASTROUND)//load next map.
968+
if(GetMapTimeLeftInt() <= ReturnExpectedDowntime() || EndOfRoundFlags & FBFLAG_FORCELASTROUND || cvarList[FB_CVAR_FBNEXTROUND_FORCESWITCH].IntValue == 1)//load next map.
929969
{
930970
new String:mapString[256] = "cp_dustbowl";//If no nextmap, dustbowl
931971
GetNextMap(mapString, sizeof(mapString));
@@ -1048,27 +1088,6 @@ public OnClientDisconnect(int client)
10481088
Use: Countdown timer from microwave seconds to human seconds.
10491089
There has to be a way to do this normally in SM. Just too lazy to look rn.
10501090
*/
1051-
/*
1052-
String:ConvertFromMicrowaveTime()
1053-
{
1054-
int minutes = 0;
1055-
int seconds = FeedbackTimer;
1056-
1057-
minutes = seconds / 60;
1058-
if(minutes > 0)
1059-
seconds -= (minutes * 60);
1060-
1061-
new String:secondsString[32] = "Failed";
1062-
1063-
Format(secondsString,strlen(secondsString), "0%i", seconds);
1064-
if(seconds >= 10)
1065-
Format(secondsString,strlen(secondsString), "%i", seconds);
1066-
1067-
new String:time[512];
1068-
Format(time, 512, "%i:%s",minutes, secondsString);
1069-
return time;
1070-
}
1071-
*/
10721091
String:ConvertFromMicrowaveTime(int tSeconds)
10731092
{
10741093
//Get seconds
@@ -1141,6 +1160,27 @@ void RespondToAdminCMD(client, String:StringText[])
11411160
if(IsValidClient(client))
11421161
CPrintToChat(client, "{gold}[Feedback]{default} | To you | %s", StringText);//Respond to ingame client
11431162
}
1163+
public Action:Command_Fb_Now(int client, int args)
1164+
{
1165+
if(!IsTestModeActive)//FB round is not already in play.
1166+
{
1167+
LogAction(client,-1,"%N Called FB Round | result : accepted",client);
1168+
RespondToAdminCMD(client, "Starting FbRound ASAP!");
1169+
IsTestModeTriggered = true;
1170+
StartFeedbackRound();
1171+
CreateTimer(10.0, FbNowHud_TimerFix);
1172+
EmitSoundToAll(SOUND_HINTSOUND, _, _, SNDLEVEL_DRYER, _, SNDVOL_NORMAL, _, _, _, _, _, _);
1173+
}
1174+
else
1175+
{
1176+
LogAction(client,-1,"%N Called FB Round | result : declined",client);
1177+
RespondToAdminCMD(client, "FBRound is already active, ignoring.");
1178+
}
1179+
}
1180+
public Action FbNowHud_TimerFix(Handle timer, any serial)
1181+
{
1182+
ShowFeedbackRoundHud = true;
1183+
}
11441184
public Action:Command_Fb_Next_RoundToggle(int client, int args)
11451185
{
11461186
LogAction(client,-1,"%N Called FB Nextround",client);
@@ -1370,7 +1410,7 @@ public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
13701410
delete menu;
13711411
}
13721412
}
1373-
public Action Command_Medics(int client,int args)
1413+
public Action Command_Swag(int client,int args)
13741414
{
13751415
int RedMedics;
13761416
int BlueMedics;

0 commit comments

Comments
 (0)