#ifdef CSQC
string got_commandkey;
#define ADD_CSQC_AUTOCVAR(name) var float autocvar_notification_##name = TRUE;
+var float autocvar_notification_ctf_capture_verbose = TRUE;
+var float autocvar_notification_ctf_pickup_team_verbose = TRUE;
+var float autocvar_notification_ctf_pickup_enemy_verbose = TRUE;
#define CHECK_AUTOCVAR(name) if(autocvar_notification_##name)
#define HANDLE_CPID(cpid) ((min(NOTIF_MAX, cpid) == NO_CPID) ? FALSE : cpid)
#define PASS_KEY ((((got_commandkey = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(got_commandkey, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), got_commandkey) : "")
Guidlines (please try and follow these):
-ALWAYS start the string with a color, preferably background.
+ -ALWAYS reset a color after a name (this way they don't set it for the whole string).
-NEVER re-declare an event twice.
-NEVER add or remove fields from the format, it SHOULD already work.
-MSG_INFO messages must ALWAYS end with a new line: \n
// flag.netname = ((teamnumber) ? "^1RED^7 flag" : "^4BLUE^7 flag");
// weaponorder[f1].netname
#define MSG_INFO_NOTIFICATIONS \
- MSG_INFO_NOTIF(INFO_CTF_PICKUP_RED, 2, 1, XPND3(s1, s2, "foobar"), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \
+ MSG_INFO_NOTIF(INFO_EMPTY, 0, 0, NO_STR_ARG, "", "", "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_DROPPED_RED, 0, 0, NO_STR_ARG, "", _("^BGThe ^1RED^BG flag was dropped in the base and returned itself\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_DROPPED_BLUE, 0, 0, NO_STR_ARG, "", _("^BGThe ^5BLUE^BG flag was dropped in the base and returned itself\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_DAMAGED_RED, 0, 0, NO_STR_ARG, "", _("^BGThe ^1RED^BG flag was destroyed and returned to base\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_DAMAGED_BLUE, 0, 0, NO_STR_ARG, "", _("^BGThe ^5BLUE^BG flag was destroyed and returned to base\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_SPEEDRUN_RED, 0, 1, f1/100, "", _("^BGThe ^1RED^BG flag became impatient after ^F1%.2f^BG seconds and returned itself\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_SPEEDRUN_BLUE, 0, 1, f1/100, "", _("^BGThe ^5BLUE^BG flag became impatient after ^F1%.2f^BG seconds and returned itself\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_NEEDKILL_RED, 0, 0, NO_STR_ARG, "", _("^BGThe ^1RED^BG flag fell somewhere it couldn't be reached and returned to base\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_NEEDKILL_BLUE, 0, 0, NO_STR_ARG, "", _("^BGThe ^5BLUE^BG flag fell somewhere it couldn't be reached and returned to base\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_ABORTRUN_RED, 0, 0, NO_STR_ARG, "", _("^BGThe ^1RED^BG flag was returned to base by its owner\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_FLAGRETURN_ABORTRUN_BLUE, 0, 0, NO_STR_ARG, "", _("^BGThe ^5BLUE^BG flag was returned to base by its owner\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_PICKUP_RED, 1, 0, s1, "notify_red_taken", _("^BG%s^BG got the ^1RED^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_PICKUP_BLUE, 1, 0, s1, "notify_blue_taken", _("^BG%s^BG got the ^5BLUE^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_RETURN_RED, 1, 0, s1, "notify_red_returned", _("^BG%s^BG returned the ^1RED^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_RETURN_BLUE, 1, 0, s1, "notify_blue_returned", _("^BG%s^BG returned the ^5BLUE^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_LOST_RED, 1, 0, s1, "notify_red_lost", _("^BG%s^BG lost the ^1RED^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_LOST_BLUE, 1, 0, s1, "notify_blue_lost", _("^BG%s^BG lost the ^5BLUE^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_RED, 1, 0, s1, "notify_red_capture", _("^BG%s^BG captured the ^1RED^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_BLUE, 1, 0, s1, "notify_blue_capture", _("^BG%s^BG captured the ^5BLUE^BG flag\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_TIME_RED, 1, 1, XPND2(s1, f1/100), "notify_red_capture", _("^BG%s^BG captured the ^1RED^BG flag in ^F1%.2f^BG seconds\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_TIME_BLUE, 1, 1, XPND2(s1, f1/100), "notify_blue_capture", _("^BG%s^BG captured the ^5BLUE^BG flag in ^F1%.2f^BG seconds\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_BROKEN_RED, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_red_capture", _("^BG%s^BG captured the ^1RED^BG flag in ^F1%.2f^BG seconds, breaking ^BG%s^BG's previous record of ^F2%.2f^BG seconds\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_BROKEN_BLUE, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_blue_capture", _("^BG%s^BG captured the ^5BLUE^BG flag in ^F1%.2f^BG seconds, breaking ^BG%s^BG's previous record of ^F2%.2f^BG seconds\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_UNBROKEN_RED, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_red_capture", _("^BG%s^BG captured the ^1RED^BG flag in ^F2%.2f^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%.2f^BG seconds\n"), "") \
+ MSG_INFO_NOTIF(INFO_CTF_CAPTURE_UNBROKEN_BLUE, 2, 2, XPND4(s1, f1/100, s2, f2/100), "notify_blue_capture", _("^BG%s^BG captured the ^5BLUE^BG flag in ^F2%.2f^BG seconds, failing to break ^BG%s^BG's previous record of ^F1%.2f^BG seconds\n"), "") \
#undef MSG_INFO_NOTIF
#define MSG_CENTER_NOTIFICATIONS \
MSG_CENTER_NOTIF(CENTER_EMPTY, 0, 0, NO_STR_ARG, NO_CPID, XPND2(0, 0), "", "") \
MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_SHIELDED, 0, 0, NO_STR_ARG, CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \
MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_FREE, 0, 0, NO_STR_ARG, CPID_CTF_CAPTURESHIELD, XPND2(0, 0), _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_PASS_OTHER_RED, 2, 0, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s passed the ^1RED^BG flag to %s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_PASS_OTHER_BLUE, 2, 0, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s passed the ^4BLUE^BG flag to %s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_PASS_OTHER_RED, 2, 0, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s^BG passed the ^1RED^BG flag to %s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_PASS_OTHER_BLUE, 2, 0, XPND2(s1, s2), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s^BG passed the ^4BLUE^BG flag to %s"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_PASS_SENT_RED, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGYou passed the ^1RED^BG flag to %s"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_PASS_SENT_BLUE, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGYou passed the ^4BLUE^BG flag to %s"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_PASS_RECEIVED_RED, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGYou received the ^1RED^BG flag from %s"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_PASS_RECEIVED_BLUE, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGYou received the ^4BLUE^BG flag from %s"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_PASS_REQUESTING, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGRequesting %s to pass you the flag"), "") \
- MSG_CENTER_NOTIF(CENTER_CTF_PASS_REQUESTED, 1, 0, XPND2(s1, PASS_KEY), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s requests you to pass the flag%s"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_PASS_REQUESTING, 1, 0, s1, CPID_CTF_PASS, XPND2(0, 0), _("^BGRequesting %s^BG to pass you the flag"), "") \
+ MSG_CENTER_NOTIF(CENTER_CTF_PASS_REQUESTED, 1, 0, XPND2(s1, PASS_KEY), CPID_CTF_PASS, XPND2(0, 0), _("^BG%s^BG requests you to pass the flag%s"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_RETURN_RED, 0, 0, NO_STR_ARG, CPID_CTF_LOWPRIO, XPND2(0, 0), _("^BGYou returned the ^1RED^BG flag"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_RETURN_BLUE, 0, 0, NO_STR_ARG, CPID_CTF_LOWPRIO, XPND2(0, 0), _("^BGYou returned the ^4BLUE^BG flag"), "") \
MSG_CENTER_NOTIF(CENTER_CTF_CAPTURE_RED, 0, 0, NO_STR_ARG, CPID_CTF_LOWPRIO, XPND2(0, 0), _("^BGYou captured the ^1RED^BG flag"), "") \
float net_name = ReadShort();
float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name));
- float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
+ float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
Local_Notification(net_type, net_name,
((stringcount >= 1) ? ReadString() : ""),
GameLogEcho(strcat(":ctf:", mode, ":", ftos(flagteam), ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
}
-string ctf_CaptureRecord(entity flag, entity player)
+void ctf_CaptureRecord(entity flag, entity player)
{
- float cap_time, cap_record, success;
- string cap_message, refername;
-
- if((autocvar_g_ctf_captimerecord_always) || (player_count - currentbots))
- {
- cap_record = ctf_captimerecord;
- cap_time = (time - flag.ctf_pickuptime);
-
- refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
- refername = ((refername == player.netname) ? "their" : strcat(refername, "^7's"));
-
- if(!ctf_captimerecord)
- { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds"); success = TRUE; }
- else if(cap_time < cap_record)
- { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, breaking ", refername, " previous record of ", ftos_decimals(cap_record, 2), " seconds"); success = TRUE; }
- else
- { cap_message = strcat(" in ", ftos_decimals(cap_time, 2), " seconds, failing to break ", refername, " record of ", ftos_decimals(cap_record, 2), " seconds"); success = FALSE; }
+ entity tmp_entity;
+ float notification, success;
+ float cap_record = ctf_captimerecord;
+ float cap_time = (time - flag.ctf_pickuptime);
+ float f1, f2 = NO_FL_ARG;
+ string s1, s2 = NO_STR_ARG;
+ string refername = db_get(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"));
+
+ // figure shit out
+ if(!ctf_captimerecord)
+ { notification = RED_OR_BLUE(flag, INFO_CTF_CAPTURE_TIME_); s1 = player.netname; f1 = (cap_time * 100); success = TRUE; }
+ else if(cap_time < cap_record)
+ { notification = RED_OR_BLUE(flag, INFO_CTF_CAPTURE_BROKEN_); s1 = player.netname; s2 = refername; f1 = (cap_time * 100); f2 = (cap_record * 100); success = TRUE; }
+ else
+ { notification = RED_OR_BLUE(flag, INFO_CTF_CAPTURE_UNBROKEN_); s1 = player.netname; s2 = refername; f1 = (cap_time * 100); f2 = (cap_record * 100); success = FALSE; }
- if(success)
- {
- ctf_captimerecord = cap_time;
- db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time));
- db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname);
- write_recordmarker(player, (time - cap_time), cap_time);
- }
+ // notify about shit
+ FOR_EACH_REALCLIENT(tmp_entity)
+ {
+ if not(tmp_entity.CAPTURE_VERBOSE) { notification = RED_OR_BLUE(flag, INFO_CTF_CAPTURE_); s2 = NO_STR_ARG; f1 = f2 = NO_FL_ARG; }
+ Send_Notification(tmp_entity, MSG_INFO, notification, s1, s2, f1, f2, NO_FL_ARG);
}
-
- return cap_message;
+
+ // write that shit in the database
+ if(success)
+ {
+ ctf_captimerecord = cap_time;
+ db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/time"), ftos(cap_time));
+ db_put(ServerProgsDB, strcat(GetMapname(), "/captimerecord/netname"), player.netname);
+ write_recordmarker(player, (time - cap_time), cap_time);
+ }
}
void ctf_FlagcarrierWaypoints(entity player)
flag.pass_target = world;
}
}
-#define RED_OR_BLUE(ent,red,blue) ((ent.team == COLOR_TEAM1) ? red : blue)
+
void ctf_Handle_Retrieve(entity flag, entity player)
{
entity tmp_player; // temporary entity which the FOR_EACH_PLAYER loop uses to scan players
FOR_EACH_REALPLAYER(tmp_player)
{
if(tmp_player == sender)
- Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_SENT_RED, CENTER_CTF_PASS_SENT_BLUE), player.netname, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
+ Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_SENT_), player.netname, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
else if(tmp_player == player)
- Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_RECEIVED_RED, CENTER_CTF_PASS_RECEIVED_BLUE), sender.netname, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
+ Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_RECEIVED_), sender.netname, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
else if(!IsDifferentTeam(tmp_player, sender))
- Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_OTHER_RED, CENTER_CTF_PASS_OTHER_BLUE), sender.netname, player.netname, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
+ Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PASS_OTHER_), sender.netname, player.netname, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
}
// create new waypoint
if not(player) { return; } // without someone to give the reward to, we can't possibly cap
// messages and sounds
- Send_KillNotification(player.netname, enemy_flag.netname, ctf_CaptureRecord(enemy_flag, player), INFO_CAPTUREFLAG, MSG_INFO);
+ ctf_CaptureRecord(enemy_flag, player);
sound(player, CH_TRIGGER, flag.snd_flag_capture, VOL_BASE, ATTN_NONE);
switch(capturetype)
void ctf_Handle_Return(entity flag, entity player)
{
// messages and sounds
- Send_Notification(player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_RETURN_RED, CENTER_CTF_RETURN_BLUE), NO_STR_ARG, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
+ Send_Notification(player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_RETURN_), NO_STR_ARG, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
Send_KillNotification(player.netname, flag.netname, "", INFO_RETURNFLAG, MSG_INFO);
sound(player, CH_TRIGGER, flag.snd_flag_returned, VOL_BASE, ATTN_NONE);
ctf_EventLog("return", flag.team, player);
{
if(tmp_player == player)
{
- Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PICKUP_RED, CENTER_CTF_PICKUP_BLUE), NO_STR_ARG, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
+ Send_Notification(tmp_player, MSG_CENTER, RED_OR_BLUE(flag, CENTER_CTF_PICKUP_), NO_STR_ARG, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
if(ctf_stalemate) { Send_Notification(player, MSG_CENTER, CENTER_CTF_STALEMATE_CARRIER, NO_STR_ARG, NO_STR_ARG, NO_FL_ARG, NO_FL_ARG, NO_FL_ARG); }
}
else if(!IsDifferentTeam(tmp_player, player) && tmp_player != player)
MUTATOR_HOOKFUNCTION(ctf_GetCvars)
{
- GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_TEAM_VERBOSE, "notification_CENTER_CTF_PICKUP_TEAM_VERBOSE");
- GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_ENEMY_VERBOSE, "notification_CENTER_CTF_PICKUP_ENEMY_VERBOSE");
+ GetCvars_handleFloat(get_cvars_s, get_cvars_f, CAPTURE_VERBOSE, "notification_ctf_capture_verbose");
+ GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_TEAM_VERBOSE, "notification_ctf_pickup_team_verbose");
+ GetCvars_handleFloat(get_cvars_s, get_cvars_f, PICKUP_ENEMY_VERBOSE, "notification_ctf_pickup_enemy_verbose");
return TRUE;
}