#include <core> #include <console> #include <string> #include <admin> #include <adminlib> #define ACCESS_MAPMEM 2048 new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.0"; new pv_maps[21][50]; /* -=Plugin_KrezerJ_MapTracker v1.0=- http://www.KrezerJ.com - KrezerJ@KrezerJ.com * Prevents maps from being played over and over again by tracking what maps have been * most recently been loaded and does not allow any votes for those maps * Notes: admin_maptracker : displays maps that can not be voted on at this time. * admin_maptracker <number> : number of new maps before one may be repeated. * * ATTN: This plugin MUST be listed before "plugin_hldsld_mapvote.amx" in plugin.ini!! */ /* Set this to the number of new maps before one may be repeated */ new mapMem = 5; // (anything from 2 to 20) public admin_maptracker(HLCommand,HLData,HLUserName,UserIndex) { new i; new iData; new Data[MAX_DATA_LENGTH]; new stri[MAX_TEXT_LENGTH]; new Text[MAX_TEXT_LENGTH]; convert_string(HLData,Data,MAX_DATA_LENGTH); numtostr(mapMem,stri); iData=strtonum(Data); // Quick and dirty way to allow modification of mapMem if(strlen(Data)>0) { if(!check_auth(ACCESS_MAPMEM)){ selfmessage("You are not authorized to change the number of maps tracked"); return PLUGIN_HANDLED; } if(1<iData<21){ mapMem = iData; set_vaultdata("pv_map",Data); snprintf(Text, MAX_TEXT_LENGTH, "Map Memory is now set to %s Maps.", Data); selfmessage(Text); } else { selfmessage("Enter a number between 2 and 20 to change the number of maps tracked"); } return PLUGIN_HANDLED; } // Print Disabled Maps snprintf(Text, MAX_TEXT_LENGTH, "Disabled Maps - Last %s played", stri); selfmessage(Text); selfmessage("==========================="); for(i=1; i<=mapMem; i++){ numtostr(i,stri); snprintf(Text, MAX_TEXT_LENGTH, "%s: %s", stri, pv_maps[i]); selfmessage(Text); // Print the array } return PLUGIN_HANDLED; } public HandleSay(HLCommand,HLData,HLUserName,UserIndex) { new Data[MAX_DATA_LENGTH]; new i; new Text[MAX_TEXT_LENGTH]; new User[MAX_NAME_LENGTH]; convert_string(HLData,Data,MAX_DATA_LENGTH); convert_string(HLUserName,User,MAX_DATA_LENGTH); strstripquotes(Data); if(strmatch(Data,"vote ",strlen("vote "))==1) { new moreMaps; new Length; new mrMaps[MAX_DATA_LENGTH]; new strMap[MAX_DATA_LENGTH]; Length = strlen(Data); /* we need to strip out 'vote ' (5 characters */ for(i=5;i<Length+1;i++) strMap[i-5] = Data[i]; strMap[i-5] = NULL_CHAR; for(i=1; i<=mapMem; i++){ if (strcasecmp(strMap, pv_maps[i])==0){ moreMaps = (mapMem-i+1); numtostr(moreMaps,mrMaps); snprintf(Text, MAX_TEXT_LENGTH, "%s : %s", User, Data); // echo their Say say(Text); snprintf(Text, MAX_TEXT_LENGTH, "Sorry, %s, you cant vote that map till you play %s more maps.", User, mrMaps); say(Text); say("Votes for Recently Played Maps are Disabled, Type MapTracker for a List of those Maps."); return PLUGIN_HANDLED; // Delete the say to Cancel the vote } } } if (strcasestr(Data, "maptracker")!=-1) { centersay ("This Server is using Plugin_KrezerJ_MapTracker v1.0^nWritten by KrezerJ",9,0,255,0); new stri[MAX_TEXT_LENGTH]; new Msg[MAX_TEXT_LENGTH]; numtostr(mapMem,stri); snprintf(Text, MAX_TEXT_LENGTH, "Disabled Maps - Last %s played", stri); say(Text); for(i=1; i<=mapMem; i++){ numtostr(i,stri); snprintf(Text, MAX_TEXT_LENGTH, "%s: %s ", stri, pv_maps[i]); // If longer than max message length say Msg and // start a new line with this text (could have used ^n) if (strlen(Text)+strlen(Msg)>=100) { say(Msg); Msg=""; } strcpy(Msg[strlen(Msg)],Text,MAX_TEXT_LENGTH); // append text } say(Msg); } return PLUGIN_CONTINUE; } public plugin_init() { plugin_registerinfo("KrezerJs Map Tracker", "Stop People from loading the same maps every vote", STRING_VERSION); plugin_registercmd("admin_maptracker","admin_maptracker",ACCESS_ALL,"admin_maptracker : maps that can not be voted on at this time."); plugin_registerhelp("admin_maptracker",ACCESS_MAPMEM,"admin_maptracker <number>: number of new maps before one may be repeated."); plugin_registerhelp("say",ACCESS_ALL,"say maptracker : maps that can not be voted on at this time."); plugin_registercmd("say", "HandleSay", ACCESS_ALL); new i; new VaultData[MAX_TEXT_LENGTH]; new strVAR[MAX_TEXT_LENGTH]; new stri[MAX_TEXT_LENGTH]; currentmap(pv_maps[1],MAX_TEXT_LENGTH); // Read Vault Data if(get_vaultdata("pv_map",VaultData,MAX_TEXT_LENGTH) != 0){ i=strtonum(VaultData); if(1<i<21){ mapMem = i; } } for(i=1; i<mapMem; i++){ numtostr(i,stri); snprintf(strVAR, MAX_TEXT_LENGTH, "pv_map%s", stri); if(get_vaultdata(strVAR,VaultData,MAX_TEXT_LENGTH) != 0){ strcpy(pv_maps[i+1],VaultData,MAX_TEXT_LENGTH); } } // Update Vault Data for(i=1; i<mapMem; i++){ numtostr(i,stri); snprintf(strVAR, MAX_TEXT_LENGTH, "pv_map%s", stri); set_vaultdata(strVAR,pv_maps[i]); } return PLUGIN_CONTINUE; }