/****************************************************************** ** Biohazards Last Scout Plugin v 2.0 ******** *** (plugin_logd_lastscout.sma) ******* **** INFO: Wishs good luck to the last man of a team in ****** ***** the current round. It acts on Kills, Teamkills, Dis- ***** ****** connection and Suicide. Also works with PodBot 2.5 **** ******* *** ******** Thanks to f[SAM]t for this fine idea ** ******************************************************************/ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define ACCESS_CONSOLE 131072 #define ACCESS_LS 1024 #define SHOW_TIME 5 new STRING_VERSION[MAX_DATA_LENGTH] = "2.0"; new bLastScout = 1; // 1 - LastScout on, 2 - LastScout off new bAudio = 1; // 1 - Sound on, 0 - Sound off new Style = 1; // 1 - Centersay, 2 - Typesay, 0 - disabled new bMode = 0; // Holds information if last man was allready detected new bWar = 0; // 1 - Plugin zwecks Clanwar abschalten public admin_war(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new User[MAX_NAME_LENGTH]; new Value; convert_string(HLCommand,Command,MAX_COMMAND_LENGTH); convert_string(HLData,Data,MAX_DATA_LENGTH); convert_string(HLUserName,User,MAX_NAME_LENGTH); Value = strtonum(Data); if (Value == 1) { if (bWar != 1) { bWar = 1; selfmessage("Last Scout Plugin deactivated. Reactivate with 'admin_war 0'"); } else selfmessage("Last Scout Plugin already deactivated"); } if (Value == 0) { if (bWar != 0) { bWar = 0; selfmessage("Last Scout Plugin reactivated"); } else selfmessage("Last Scout Plugin already reactivated"); } if ((Value != 0) && (Value != 1)) selfmessage("Value has to be 0 or 1 !"); return PLUGIN_HANDLED; } public admin_ls_off(HLCommand, HLData, HLUserName, UserIndex) { new User[MAX_NAME_LENGTH]; new Text[MAX_TEXT_LENGTH]; convert_string(HLUserName, User, MAX_NAME_LENGTH); if (bLastScout != 0) { bLastScout = 0; // Last Scout off say(">>> Last Scout Plugin has been disabled <<<"); snprintf(Text, MAX_TEXT_LENGTH, "Last Scout Plugin has been disabled by %s", User); log(Text); } else selfmessage("Last Scout Plugin already disabled"); return PLUGIN_HANDLED; } public admin_ls_on(HLCommand, HLData, HLUserName, UserIndex) { new User[MAX_NAME_LENGTH]; new Text[MAX_TEXT_LENGTH]; convert_string(HLUserName, User, MAX_NAME_LENGTH); if (bLastScout != 1) { bLastScout = 1; // Last Scout on say(">>> Last Scout Plugin has been enabled <<<"); snprintf(Text, MAX_TEXT_LENGTH, "Last Scout Plugin has been enabled by %s", User); log(Text); } else selfmessage("Last Scout Plugin already enabled"); return PLUGIN_HANDLED; } public admin_lsaudio_off(HLCommand, HLData, HLUserName, UserIndex) { new User[MAX_NAME_LENGTH]; convert_string(HLUserName, User, MAX_NAME_LENGTH); if (bAudio != 0) { bAudio = 0; // HL-Speech off selfmessage(">>> Sound has been disabled"); } else selfmessage("Sound is already disabled"); return PLUGIN_HANDLED; } public admin_lsaudio_on(HLCommand, HLData, HLUserName, UserIndex) { new User[MAX_NAME_LENGTH]; convert_string(HLUserName, User, MAX_NAME_LENGTH); if (bAudio != 1) { bAudio = 1; // HL-Speech on selfmessage(">>> Sound has been enabled"); } else selfmessage("Sound is already enabled"); return PLUGIN_HANDLED; } public admin_ls_style(HLCommand,HLData,HLUserName,UserIndex) { new Command[MAX_COMMAND_LENGTH]; new Data[MAX_DATA_LENGTH]; new User[MAX_NAME_LENGTH]; new Value; convert_string(HLCommand,Command,MAX_COMMAND_LENGTH); convert_string(HLData,Data,MAX_DATA_LENGTH); convert_string(HLUserName,User,MAX_NAME_LENGTH); Value = strtonum(Data); if (Value == 1) { Style = 1; // Centersay selfmessage(">> Style changed to 'Centersay'"); } if (Value == 2) { Style = 2; // Typesay selfmessage(">> Style changed to 'Typesay'"); } if (Value == 0) { Style = 0; // disabled selfmessage(">> Style changed to 'disabled'"); } if ((Value != 1) && (Value != 2) && (Value != 0)) selfmessage("Value has to be a number between 0 and 2 !"); return PLUGIN_HANDLED; } public ls_onStartOrEnd(HLCommand,HLData,HLUserName,UserIndex) { if (!bLastScout) return PLUGIN_CONTINUE; if (bWar == 1) return PLUGIN_CONTINUE; new Params[MAX_DATA_LENGTH]; convert_string(HLData,Params,MAX_DATA_LENGTH); switch( Params[6] ) { case 'S': { bMode = 0; return PLUGIN_CONTINUE; } } return PLUGIN_CONTINUE; } public logd_lastscout (HLCommand,HLData,HLUserName,UserIndex) { if (!bLastScout) return PLUGIN_CONTINUE; if (bWar == 1) return PLUGIN_CONTINUE; new Target[MAX_NAME_LENGTH]; new LastMan_T[MAX_NAME_LENGTH]; new LastMan_CT[MAX_NAME_LENGTH]; new SessionID; new WONID; new Team; new Dead; new Anzahl_T = 0; new Anzahl_CT = 0; new i; new maxplayers = maxplayercount(); for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead)) { if ((Dead == 0) && (Team == 1)) { Anzahl_T ++; LastMan_T = Target; } if ((Dead == 0) && (Team == 2)) { Anzahl_CT ++; LastMan_CT = Target; } } } if (bMode == 0) { if ((Anzahl_T == 1) && (Anzahl_CT > 1)) { ls_ShowHim(1, LastMan_T, ""); bMode = 1; } if ((Anzahl_CT == 1) && (Anzahl_T > 1)) { ls_ShowHim(2, LastMan_CT, ""); bMode = 1; } } if ((Anzahl_CT == 1) && (Anzahl_T == 1)) { ls_ShowHim(0, LastMan_T, LastMan_CT); } if ((Anzahl_CT == 1) && (Anzahl_T == 0)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_CT) == 0) && (WONID != 0)) { playsound(LastMan_CT, "misc/theone.wav"); } } } } } if ((Anzahl_CT == 0) && (Anzahl_T == 1)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_T) == 0) && (WONID != 0)) { playsound(LastMan_T, "misc/theone.wav"); } } } } } return PLUGIN_CONTINUE; } public ls_onDisconnect (dName, dUID, dWonid, sTeam) { if (!bLastScout) return PLUGIN_CONTINUE; if (bWar == 1) return PLUGIN_CONTINUE; new Target[MAX_NAME_LENGTH]; new LastMan_T[MAX_NAME_LENGTH]; new LastMan_CT[MAX_NAME_LENGTH]; new SessionID; new WONID; new Team; new Dead; new Anzahl_T = 0; new Anzahl_CT = 0; new i; new maxplayers = maxplayercount(); for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead)) { if ((Dead == 0) && (Team == 1)) { Anzahl_T ++; LastMan_T = Target; } if ((Dead == 0) && (Team == 2)) { Anzahl_CT ++; LastMan_CT = Target; } } } if (bMode == 0) { if ((Anzahl_T == 1) && (Anzahl_CT > 1)) { ls_ShowHim(1, LastMan_T, ""); bMode = 1; } if ((Anzahl_CT == 1) && (Anzahl_T > 1)) { ls_ShowHim(2, LastMan_CT, ""); bMode = 1; } } if ((Anzahl_CT == 1) && (Anzahl_T == 1)) { ls_ShowHim(0, LastMan_T, LastMan_CT); } if ((Anzahl_CT == 1) && (Anzahl_T == 0)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_CT) == 0) && (WONID != 0)) { playsound(LastMan_CT, "misc/theone.wav"); } } } } } if ((Anzahl_CT == 0) && (Anzahl_T == 1)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_T) == 0) && (WONID != 0)) { playsound(LastMan_T, "misc/theone.wav"); } } } } } return PLUGIN_CONTINUE; } public ls_onSuicide (sName, sUID, sWonid, sTeam, sWeapon) { if (!bLastScout) return PLUGIN_CONTINUE; if (bWar == 1) return PLUGIN_CONTINUE; new Target[MAX_NAME_LENGTH]; new LastMan_T[MAX_NAME_LENGTH]; new LastMan_CT[MAX_NAME_LENGTH]; new SessionID; new WONID; new Team; new Dead; new Anzahl_T = 0; new Anzahl_CT = 0; new i; new maxplayers = maxplayercount(); for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i,Target,MAX_NAME_LENGTH,SessionID,WONID,Team,Dead)) { if ((Dead == 0) && (Team == 1)) { Anzahl_T ++; LastMan_T = Target; } if ((Dead == 0) && (Team == 2)) { Anzahl_CT ++; LastMan_CT = Target; } } } if (bMode == 0) { if ((Anzahl_T == 1) && (Anzahl_CT > 1)) { ls_ShowHim(1, LastMan_T, ""); bMode = 1; } if ((Anzahl_CT == 1) && (Anzahl_T > 1)) { ls_ShowHim(2, LastMan_CT, ""); bMode = 1; } } if ((Anzahl_CT == 1) && (Anzahl_T == 1)) { ls_ShowHim(0, LastMan_T, LastMan_CT); } if ((Anzahl_CT == 1) && (Anzahl_T == 0)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_CT) == 0) && (WONID != 0)) { playsound(LastMan_CT, "misc/theone.wav"); } } } } } if ((Anzahl_CT == 0) && (Anzahl_T == 1)) { if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Target); if (playerinfo(i, Target, MAX_NAME_LENGTH, SessionID, WONID)) { if ((strcmp(Target, LastMan_T) == 0) && (WONID != 0)) { playsound(LastMan_T, "misc/theone.wav"); } } } } } return PLUGIN_CONTINUE; } public ls_ShowHim (Team, LastMan[MAX_NAME_LENGTH], LastMan2[MAX_NAME_LENGTH]) { new TextMessage[MAX_TEXT_LENGTH]; new Digit = random(2); new Name[MAX_NAME_LENGTH]; new iUserID; new iWONID; new maxplayers = maxplayercount(); new i; if (Team != 0) { if (Digit == 0) snprintf(TextMessage, MAX_TEXT_LENGTH, "%s: I hope you still have a healthpack", LastMan); if (Digit == 1) snprintf(TextMessage, MAX_TEXT_LENGTH, "%s: All your teammates were killed. Good luck !", LastMan); if (Digit == 2) snprintf(TextMessage, MAX_TEXT_LENGTH, "%s: Now you are alone. Have fun !", LastMan); } if (Team == 0) { snprintf(TextMessage, MAX_TEXT_LENGTH, "%s vs %s", LastMan, LastMan2); if (Style == 1) centersay(TextMessage, SHOW_TIME, 0, 255, 0); if (Style == 2) typesay(TextMessage, SHOW_TIME, 0, 255, 0); } if (Team == 1) { if (Style == 1) centersay(TextMessage, SHOW_TIME, 255, 0, 0); if (Style == 2) typesay(TextMessage, SHOW_TIME, 255, 0, 0); } if (Team == 2) { if (Style == 1) centersay(TextMessage, SHOW_TIME, 0, 0, 255); if (Style == 2) typesay(TextMessage, SHOW_TIME, 0, 0, 255); } if (bAudio == 1) { for(i=1; i<=maxplayers; i++) { strinit(Name); if (playerinfo(i, Name, MAX_NAME_LENGTH, iUserID, iWONID)) { if ((strcmp(Name, LastMan) == 0) && (iWONID != 0)) { playsound(Name, "misc/force.wav"); } if ((strcmp(Name, LastMan2) == 0) && (iWONID != 0)) { playsound(Name, "misc/force.wav"); } } } } } public plugin_init() { plugin_registerinfo("Biohazards Last Scout Plugin ","Wishs good luck to the last man standing.",STRING_VERSION); plugin_registercmd("logd_lastscout", "logd_lastscout", ACCESS_CONSOLE); plugin_registercmd("ls_onStartOrEnd", "ls_onStartOrEnd", ACCESS_CONSOLE); plugin_registercmd("ls_onDisconnect", "ls_onDisconnect", ACCESS_CONSOLE); plugin_registercmd("ls_onSuicide", "ls_onSuicide", ACCESS_CONSOLE); plugin_registercmd("admin_ls_off", "admin_ls_off", ACCESS_LS, "admin_ls_off: Turns off enemy counting."); plugin_registercmd("admin_ls_on", "admin_ls_on", ACCESS_LS, "admin_ls_on: Turns on enemy counting."); plugin_registercmd("admin_lsaudio_off", "admin_lsaudio_off", ACCESS_LS, "admin_lsaudio_off: Turns off HL-Speech."); plugin_registercmd("admin_lsaudio_on", "admin_lsaudio_on", ACCESS_LS, "admin_lsaudio_on: Turns on HL-Speech."); plugin_registercmd("admin_ls_style", "admin_ls_style", ACCESS_LS, "admin_ls_style: Sets the style of messages."); plugin_registercmd("admin_war", "admin_war", ACCESS_LS, "admin_war: Deactivates Last Scout for Clanmatch."); exec( "logd_reg 57 admin_command logd_lastscout" ); exec( "logd_reg 62 admin_command ls_onStartOrEnd" ); exec( "logd_reg 52 admin_command ls_onDisconnect" ); exec( "logd_reg 53 admin_command ls_onSuicide" ); return PLUGIN_CONTINUE; }