Skip to content

Commit 6e947c3

Browse files
authored
0.0.16
Fixed some loops skipping the last player that connected More arena stability !walkspeed can now be reset by asking. (!walkspeed <reset/0/normal>) Added the command sm_fbmedic and sm_fbdrawline sm_fbmedic - Return the amount of medics on both teams sm_fbdrawline - Draw a ray from your eyes, returning the rays distance in your chat
1 parent 4faf537 commit 6e947c3

File tree

1 file changed

+81
-15
lines changed

1 file changed

+81
-15
lines changed

scripting/feedback2.sp

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
sm_fb_time :
99
>add : add time in seconds
1010
>set : set time in seconds
11+
sm_fb_drawline
1112
Cvars:
1213
fb2_timer : How long these rounds should be by default. (DEFAULT: 2 MINUTES)
1314
fb2_triggertime : How long till map end should we trigger last round fb round.
@@ -22,18 +23,12 @@
2223
TODOs:
2324
-Look into why spawnpoints are not showing up in !fb_spawn
2425
25-
-Fix 5CP midgame FB rounds running into timelimit ends.
2626
-Look into having FB rounds always in tournament mode.
2727
-----------------------------------------------
2828
//Over engineering:
2929
Otherwise useless shit.
3030
-Add Drawline command
3131
Return value to user of how long a sightline is
32-
33-
-Info_Targets mappers can place for spacific playtests
34-
Read these targets and run commands.
35-
ex: Force scramble after every round if an info_target is named "TF2M_FORCESCRAMBLE"
36-
This is just streamlining things, last priority.
3732
3833
-----------------------------------------------
3934
@@ -45,7 +40,7 @@
4540

4641
/* Defines */
4742
#define PLUGIN_AUTHOR "PigPig"
48-
#define PLUGIN_VERSION "0.0.15b"
43+
#define PLUGIN_VERSION "0.0.16"
4944

5045

5146
#include <sourcemod>
@@ -198,9 +193,10 @@ public void OnPluginStart()
198193
//Round ends
199194
HookEvent("teamplay_round_win", Event_Round_End, EventHookMode_Pre);
200195
HookEvent("teamplay_round_stalemate", Event_Round_End, EventHookMode_Pre);
201-
HookEvent("arena_win_panel", Event_Round_End, EventHookMode_Pre);//Arena mode. (oh god...)
196+
//HookEvent("arena_win_panel", Event_Round_End, EventHookMode_Pre);//Arena mode. (oh god...)
202197

203198
HookEvent("teamplay_round_active", Event_Teamplay_RoundActive);//When we can walk
199+
HookEvent("arena_round_start", Event_Teamplay_RoundActive);//When we can walk in arena
204200

205201
//Round start
206202
HookEvent("teamplay_round_start", Event_Round_Start);
@@ -235,6 +231,9 @@ public void OnPluginStart()
235231
RegConsoleCmd("sm_fbrh", Command_FBround_Help, "Tellme tellme.");
236232
RegConsoleCmd("sm_walkspeed", Command_walkspeed, "Change your walk speed during a fb round (HU)");
237233

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)");
235+
RegConsoleCmd("sm_fbdrawline",Command_Drawline, "Return the length in hammer units of how long a sightline is.");
236+
238237
#if defined DEBUG
239238
RegConsoleCmd("sm_fbquack", Command_FBQuack, "The characteristic harsh sound made by a duck");
240239
#endif
@@ -851,7 +850,7 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
851850

852851

853852
/* Force respawn everyone, Under the force next round condition: Players will not spawn properly! This is a bodge to get around that xdd */
854-
for(int ic = 0; ic < MaxClients; ic++)
853+
for(int ic = 0; ic <= MaxClients; ic++)
855854
{
856855
if(IsValidClient(ic))
857856
{
@@ -872,7 +871,7 @@ public Action:Event_Round_Start(Event event, const char[] name, bool dontBroadca
872871
public Action CountdownTimer(Handle timer, any serial)
873872
{
874873
/*Hud Stuff*/
875-
for(int iClient = 0; iClient < MaxClients; iClient++)
874+
for(int iClient = 0; iClient <= MaxClients; iClient++)
876875
{
877876
if(IsValidClient(iClient))
878877
{
@@ -951,7 +950,7 @@ void FeedbackTimerExpired()
951950
#endif
952951
}
953952
//Remove conditions
954-
for(int iClient = 0; iClient < MaxClients; iClient++)
953+
for(int iClient = 0; iClient <= MaxClients; iClient++)
955954
{
956955
if(IsValidClient(iClient))
957956
{
@@ -979,13 +978,16 @@ void CleanUpTimer()
979978
*/
980979
void UpdateHud(client)
981980
{
982-
if(!IsValidClient(client) || !IsPlayerAlive(client) || !ShowFeedbackRoundHud)
981+
982+
983+
if(!IsValidClient(client) || !IsPlayerAlive(client)|| !ShowFeedbackRoundHud)
983984
return;//if they are not real or alive, dont draw for them.
984985
//One thing to note is players connecting can be told to draw hud. so checking if they are alive is important.
985986
//Can cause error if i remember correctly.
986987
SetHudTextParams(-1.0, 0.80, 1.25, 198, 145, 65, 255); //Vsh hud location
987988
ShowSyncHudText(client, feedbackHUD, "| Time left %s |", ConvertFromMicrowaveTime(FeedbackTimer));//Current time is below, Super suspect thing i wrote like 2 years ago lol.
988989
}
990+
989991
public OnGameFrame()
990992
{
991993
//Quick and dirty implementation
@@ -1368,6 +1370,65 @@ public int MenuHandler1(Menu menu, MenuAction action, int param1, int param2)
13681370
delete menu;
13691371
}
13701372
}
1373+
public Action Command_Medics(int client,int args)
1374+
{
1375+
int RedMedics;
1376+
int BlueMedics;
1377+
//Find medics
1378+
for(int iClient = 0; iClient <= MaxClients; iClient++)
1379+
{
1380+
if(IsValidClient(iClient))
1381+
{
1382+
if(TF2_GetPlayerClass(iClient) == TFClass_Medic)
1383+
{
1384+
if(TF2_GetClientTeam(iClient) == TFTeam_Blue)
1385+
{
1386+
BlueMedics++;
1387+
}
1388+
else
1389+
{
1390+
RedMedics++;
1391+
}
1392+
}
1393+
}
1394+
}
1395+
1396+
//Print to client.
1397+
if(IsValidClient(client))
1398+
{
1399+
CPrintToChat(client, "{gold}[Feedback]{default} There are: {red} %i Red medic(s) {default}| {blue}%i Blue medic(s)", RedMedics, BlueMedics);
1400+
}
1401+
}
1402+
1403+
public Action Command_Drawline(int client, int args)
1404+
{
1405+
decl Float:eyePosistion[3];
1406+
decl Float:eyeAngles[3];
1407+
1408+
1409+
GetClientEyePosition(client,eyePosistion);
1410+
GetClientEyeAngles(client, eyeAngles);
1411+
1412+
new Handle:raycast = TR_TraceRayFilterEx(eyePosistion, eyeAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
1413+
1414+
if(TR_DidHit(raycast))
1415+
{
1416+
decl Float:eyeEndPosistion[3];
1417+
TR_GetEndPosition(eyeEndPosistion, raycast);
1418+
1419+
CReplyToCommand(client, "{gold}[Feedback]{default} Line distance is: %i ", RoundFloat(GetVectorDistance(eyePosistion, eyeEndPosistion, false)));
1420+
}
1421+
else
1422+
{
1423+
CReplyToCommand(client, "{gold}[Feedback]{default} ERROR!!! Line has no end!");
1424+
}
1425+
1426+
CloseHandle(raycast);
1427+
}
1428+
public bool:TraceEntityFilterPlayer(entity, contentsMask)//Ripped from pumpkinbombs plugin.
1429+
{
1430+
return entity > MaxClients || !entity;
1431+
}
13711432
/* Change FB round walk speed */
13721433
public Action Command_walkspeed(int client, int args)
13731434
{
@@ -1376,12 +1437,17 @@ public Action Command_walkspeed(int client, int args)
13761437
RespondToAdminCMD(client, "Usage: sm_walkspeed <number>");
13771438
return Plugin_Handled;
13781439
}
1379-
char arg1[32];
1440+
char arg1[128];
13801441
GetCmdArg(1, arg1, sizeof(arg1));
1442+
13811443
float clSpeed = StringToFloat(arg1);
1382-
if(clSpeed == 0.0)//Error
1444+
if(StrEqual(arg1,"reset",false) || StrEqual(arg1,"normal",false) || StrEqual(arg1,"cancel",false) || StrEqual(arg1,"zero",false) || clSpeed == 0.0)
13831445
{
1384-
RespondToAdminCMD(client, "Usage: sm_walkspeed <number>");
1446+
CReplyToCommand(client, "{gold}[Feedback]{default} Reset walk speed!");
1447+
decl String:sCookieValue[16];
1448+
FloatToString(0.0, sCookieValue, sizeof(sCookieValue));
1449+
SetClientCookie(client, clFbRoundWalkSpeed, sCookieValue);
1450+
FbRoundWalkSpeed[client] = 0.0;
13851451
}
13861452
else if(clSpeed < WALKSPEED_MIN)
13871453
{

0 commit comments

Comments
 (0)