/* plugin_produkt_timerem3.sma, v 1.1.0.0 26/3/02 */ /* Extended by Gerald Bonne to display regular adds on centersay */ #include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define MAX_ADDS 50 new STRING_VERSION[MAX_DATA_LENGTH] = "1.0.0.0"; new AdLines[MAX_ADDS][MAX_TEXT_LENGTH]; new TotalAds; new CurrentAd; public execute_all(a[]) { new username[200]; new i=0; new x = 0; x = maxplayercount(); for(i=1; i<=x; i=i+1) { strinit(username); if(playerinfo(i, username, 200)==1) { execclient(username, a); } } return PLUGIN_CONTINUE; } /* Read the ads from ads.txt */ /* Beware in Linux the filename is case sensitive */ public read_my_ads(){ new GotLine; new LineNumber=1; new AdFileStatus = 0; AdFileStatus = fileexists("ads.txt"); TotalAds = 0; if(AdFileStatus > 0){ do { GotLine=readfile("ads.txt", AdLines[TotalAds] , LineNumber, MAX_TEXT_LENGTH); LineNumber++; if(AdLines[TotalAds][0]!=0) TotalAds++; } while(TotalAds<=MAX_ADDS && GotLine); CurrentAd = 0; set_timer("show_ad", 30, 0); } } /* Display the ad and schedule the next one */ public show_ad(){ new Text[MAX_TEXT_LENGTH]; snprintf(Text, MAX_TEXT_LENGTH, "Server advertisement: %s", AdLines[CurrentAd]); centersay(AdLines[CurrentAd], 15, 128, 0, 255); say(Text); CurrentAd++; if(CurrentAd==TotalAds) CurrentAd = 0; set_timer("show_ad", 30, 0); } /* general warning messages fired off by timer (launched in client_start) */ public warn1() { execute_all("speak ^"fvox/bell _period sixty seconds remaining^""); centersay("60 seconds remaining!",10,255,0,0); } public warn5() { execute_all("speak ^"fvox/bell _period five minutes remaining^""); centersay("5 minutes remaining.",10,0,255,0); } public warn10() { execute_all("speak ^"fvox/bell _period ten minutes remaining^""); centersay("10 minutes remaining.",10,0,255,0); } public warn20() { execute_all("speak ^"fvox/bell _period twenty minutes remaining^""); centersay("20 minutes remaining.",10,0,255,0); } public warn30() { execute_all("speak ^"fvox/bell _period thirty minutes remaining^""); centersay("30 minutes remaining.",10,0,255,0); } /* I know that "forty" is spelled wrong below, but if I changed it, the sound wouldn't work. You can thank Valve. */ public warn40() { execute_all("speak ^"fvox/bell _period fourty minutes remaining^""); centersay("40 minutes remaining.",10,0,255,0); } public warn50() { execute_all("speak ^"fvox/bell _period fifty minutes remaining^""); centersay("50 minutes remaining.",10,0,255,0); } public plugin_init() { plugin_registerinfo("Gerald's Time Remaining Plugin with Ads","Announces and writes time remaining and shows ads.",STRING_VERSION); /* Start the timers, to make them set off. */ new time1=timeleft(); set_timer("warn50", time1 - 3000, 0); set_timer("warn40", time1 - 2400, 0); set_timer("warn30", time1 - 1800, 0); set_timer("warn20", time1 - 1200, 0); set_timer("warn10", time1 - 600, 0); set_timer("warn5", time1 - 300, 0); set_timer("warn1", time1 - 60, 0); read_my_ads(); return PLUGIN_CONTINUE; }