/* This plugin will show a message to everyone who connects */ /* $Id: plugin_consgreet.sma,v 1.1 12/13/01 SR71Goku Exp $ */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> new STRING_VERSION[MAX_DATA_LENGTH] = "1.0.1.0"; /* from the old adminmod */ addstr(strBegin[],strEnd[]) { new i=0; new Length = strlen(strEnd); new j; while(strBegin[i]!=0) i++; for(j=0;j<Length;j++) strBegin[i+j]=strEnd[j]; /* Null-terminate the string. */ strBegin[i+j] = NULL_CHAR; } /* from the old adminmod */ public NumToStr(num,str[]) { new Base = 1; new Digits = 1; new i = 0; /* Special case: 0 */ if (num == 0) { str[i++] = '0'; str[i++] = NULL_CHAR; } else { /* If we've got a negative number, add a negative sign to the string, and multiply the number by -1 */ if (num < 0) { str[i++] = '-'; num *= -1; } /* Ok. We've got at least one digit. Keep multiplying by 10 till we get a higher number than what we've got. Note that this will leave Digits 1 higher than what we want (eg, if Num was 7, Digits will be 2 */ while (Base <= num) { Base *= 10; Digits++; } /* Because Digits is higher, use --Digits rather than Digits--. Also, divide Base before using it. */ while (--Digits > 0) { Base /= 10; str[i++] = '0' + (num - (num % Base)) / Base; num = num % Base; } str[i++] = NULL_CHAR; } } /* from Jag's script */ public GetTeamCount(iTeam) { new i; new maxplayers = maxplayercount(); new SessionID; new Team; new TeamCount = 0; new WONID; new Name[MAX_NAME_LENGTH]; for(i = 1; i <= maxplayers; i++) { if(playerinfo(i,Name,MAX_NAME_LENGTH,SessionID,WONID,Team)==1) { if(Team==iTeam) { TeamCount++; } } } return TeamCount; } public plugin_connect(HLUserName,HLIP,UserIndex) { new strName[MAX_NAME_LENGTH],strIP[MAX_DATA_LENGTH]; new strSeconds[MAX_NUMBER_LENGTH]; new strNumber[MAX_NUMBER_LENGTH]; new NextMap[MAX_NAME_LENGTH]; nextmap(NextMap,MAX_NAME_LENGTH); new conmsg[MAX_TEXT_LENGTH]; new host[MAX_TEXT_LENGTH]; new CurrentMap[MAX_NAME_LENGTH]; new varTeamCount; new Seconds = timeleft(0); new numPlayers = playercount(); new numMaxPlayers = maxplayercount(); /* LOOK HERE LOOK HERE */ new FriendlyFire = getvar("mp_friendlyfire"); Seconds /= 60; NumToStr(Seconds, strSeconds); currentmap(CurrentMap,MAX_NAME_LENGTH); getstrvar("hostname",host,MAX_TEXT_LENGTH); convert_string(HLUserName, strName,MAX_NAME_LENGTH); convert_string(HLIP,strIP,MAX_DATA_LENGTH); /* the start of the greeting */ consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); consgreet(""); addstr(conmsg,"Hello, "); addstr(conmsg,strName); addstr(conmsg,", Welcome to "); addstr(conmsg,host); consgreet(""); consgreet(conmsg); conmsg = ""; addstr(conmsg,"Your ip address is: "); addstr(conmsg,strIP); consgreet(conmsg); conmsg = ""; consgreet("================================================================"); consgreet("-------------------------------Current info-------------------------------"); conmsg = ""; addstr(conmsg,"The current map is: "); addstr(conmsg,CurrentMap); consgreet(conmsg); conmsg = ""; addstr(conmsg,"The next map in the mapcycle is: "); addstr(conmsg,NextMap); consgreet(conmsg); conmsg = ""; addstr(conmsg,"Time remaining on map is: "); addstr(conmsg,strSeconds); addstr(conmsg," Minutes"); consgreet(conmsg); conmsg = ""; addstr(conmsg, "The current playercount is: "); NumToStr(numPlayers, strNumber); addstr(conmsg, strNumber); addstr(conmsg, " / "); NumToStr(numMaxPlayers, strNumber); addstr(conmsg, strNumber); consgreet(conmsg); conmsg = ""; addstr(conmsg, "Friendly Fire is: "); if( FriendlyFire != 1) { addstr(conmsg, "off"); } else { addstr(conmsg, "on"); } consgreet(conmsg); conmsg = ""; conmsg = "There are currently: "; varTeamCount = GetTeamCount(1); NumToStr(varTeamCount, strNumber); addstr(conmsg, strNumber); addstr(conmsg, " Terrorists"); consgreet(conmsg); conmsg = ""; conmsg = "and "; varTeamCount = GetTeamCount(2); NumToStr(varTeamCount, strNumber); addstr(conmsg, strNumber); addstr(conmsg, " Counter-Terrorists"); consgreet(conmsg); conmsg = ""; if(fileexists("consgreet.txt")==1) { consgreet("================================================================"); consgreet("------------------------------Server Stuff--------------------------------"); consgreet("consgreet.txt"); consgreet(""); } consgreet("================================================================"); consgreet(""); consgreet(""); consgreet("--------------------Now just wait to get connected--------------------"); consgreet(""); consgreet(""); return PLUGIN_CONTINUE; } public plugin_init() { plugin_registerinfo("SR71Goku's Consgreet","Shows CS message on connect.",STRING_VERSION); return PLUGIN_CONTINUE; }