/* WaTeR*MaRk's Advanced Consgreet Text file based consgreet with all the fixings Create a text file in your mod dir(ie. C:\Sierra\Halflife\tfc) and name it the file name in WMCONS_FILE and type your greeting. You may use several variables in this text file...ie. Wherever you type %host in this file it will display the host name (zip includes example file) NOTE: plugin changes file_access_read to 1 at plugin startup ALL DOLLAR SIGN VARS NEED TO BE ON A LINE OF THEIR OWN --------------- All variables: --------------- %host : Server name %player : Connecting playerÂ’s name %currentmap : Current map %nextmap : Next map %players : Current number of connected players %maxplayers : Max players allowed on the server %timeleft : Time left on the map %timeused : Time into map %time : Current server time %date : Current server date %ip : Players IP $admins : Currently connected admins $classes : Displays Currently Restricted Classes (TFC only) ----------------------------------------------- WMCONS_ADMIN : What this plugin considers an admin, default 2(any admin that can change map) WMCONS_FILE : The file that the consgreet is read from, default "wmcons.txt" Created by : WaTeR*MaRk Email : WaterMark@HalflifeMapping.com Created on : 7/15/02 Version : 1.4 */ new WMCONS_FILE[] = "wmcons.txt"; #define WMCONS_ADMIN 2 //// Dont Edit Below this Comment //// #include <core> #include <console> #include <string> #include <admin> #include <adminlib> new CLASSNAMES[9][9]; new CLASSVARS[9][12]; new STRING_VERSION[] = "1.4"; public plugin_init() { plugin_registerinfo("WM's Consgreet","Textfile Based Consgreet",STRING_VERSION); // init CLASSVARS strcpy(CLASSVARS[0],"cr_engineer",12); strcpy(CLASSVARS[1],"cr_pyro",12); strcpy(CLASSVARS[2],"cr_sniper",12); strcpy(CLASSVARS[3],"cr_demoman",12); strcpy(CLASSVARS[4],"cr_medic",12); strcpy(CLASSVARS[5],"cr_scout",12); strcpy(CLASSVARS[6],"cr_spy",12); strcpy(CLASSVARS[7],"cr_soldier",12); strcpy(CLASSVARS[8],"cr_hwguy",12); // init CLASSNAMES new strTemp[12]; new i; for(i = 0;i<9;i++) { strcpy(strTemp, CLASSVARS[i], 12); strtrim(strTemp,"cr_",0); strcpy(CLASSNAMES[i], strTemp, 9); } // return PLUGIN_CONTINUE; } public plugin_connect(HLUserName, HLIP, UserIndex) { new strWONid[MAX_NUMBER_LENGTH]; new user[MAX_NAME_LENGTH]; new line[MAX_TEXT_LENGTH]; new host[MAX_NAME_LENGTH]; new current[MAX_NAME_LENGTH]; new strmaxplayers[MAX_NUMBER_LENGTH]; new strcurrentplayers[MAX_NUMBER_LENGTH]; new strtimeleft[MAX_NUMBER_LENGTH]; new strtimespent[MAX_NUMBER_LENGTH]; new strDate[MAX_TEXT_LENGTH]; new next[MAX_NAME_LENGTH]; new strip[MAX_NUMBER_LENGTH]; new time[MAX_TEXT_LENGTH]; new iWONid; new count = 0; // gather current server information convert_string(HLUserName, user, MAX_NAME_LENGTH); convert_string(HLIP, strip, MAX_NUMBER_LENGTH); getstrvar("hostname", host, MAX_NAME_LENGTH); currentmap(current, MAX_NAME_LENGTH); numtostr(maxplayercount(), strmaxplayers); numtostr(playercount(), strcurrentplayers); numtostr((maptime(1,0) / 60), strtimeleft); numtostr((maptime(0,0) / 60),strtimespent); nextmap(next,MAX_NAME_LENGTH); servertime(time, MAX_TEXT_LENGTH, "%H:%M"); servertime(strDate, MAX_TEXT_LENGTH, "%m/%d/%y"); get_userWONID(user, iWONid); numtostr(iWONid, strWONid); // display consgreet text with replaced vars if(fileexists(WMCONS_FILE)) { while (readfile(WMCONS_FILE, line, count, MAX_TEXT_LENGTH)>0) { strsubst(line, "%host", host, MAX_TEXT_LENGTH); strsubst(line, "%currentmap", current, MAX_TEXT_LENGTH); strsubst(line, "%maxplayers", strmaxplayers, MAX_TEXT_LENGTH); strsubst(line, "%players", strcurrentplayers, MAX_TEXT_LENGTH); strsubst(line, "%timeleft", strtimeleft, MAX_TEXT_LENGTH); strsubst(line, "%nextmap", next, MAX_TEXT_LENGTH); strsubst(line, "%player", user, MAX_TEXT_LENGTH); strsubst(line, "%ip", strip, MAX_TEXT_LENGTH); strsubst(line, "%timeused", strtimespent, MAX_TEXT_LENGTH); strsubst(line, "%time", time, MAX_TEXT_LENGTH); strsubst(line, "%won", strWONid, MAX_TEXT_LENGTH); strsubst(line, "%date", strDate, MAX_TEXT_LENGTH); if((streq(line, "$admins")==0)&&(streq(line, "$classes")==0)) { consgreet(line); } else { if(streq(line, "$admins")) listadmins(); else listclasses(); } count++; } } else { consgreet("Error reading consgreet file"); } // return PLUGIN_HANDLED; } listadmins() { new user[MAX_NAME_LENGTH]; new admin = FALSE; for(new i=1;i<playercount();i++) { if(playerinfo(i, user, MAX_NAME_LENGTH)) { if(access(WMCONS_ADMIN, user)) { admin = TRUE; consgreet(user); } } } if(admin==FALSE) { consgreet(""); consgreet("None Connected"); consgreet(""); } return PLUGIN_CONTINUE; } listclasses() { new CLASSDATA[9][12]; new msg[MAX_TEXT_LENGTH]; new limited = TRUE; new i; // Gather Data for(i = 0;i<9;i++) { getstrvar(CLASSVARS[i], CLASSDATA[i], MAX_NUMBER_LENGTH); if(!streq(CLASSDATA[i], "0")) limited = FALSE; if(streq(CLASSDATA[i], "-1")) strcpy(CLASSDATA[i], "No", MAX_NUMBER_LENGTH); } // Format and display data if(limited == TRUE) { consgreet(""); consgreet("No Class Limitations"); consgreet(""); } else { for(i = 0;i<9;i++) { if(streq(CLASSDATA[i],"0")==0) { snprintf(msg, MAX_TEXT_LENGTH, "%s %s's", CLASSDATA[i], CLASSNAMES[i]); consgreet(msg); } } } // return PLUGIN_CONTINUE; }