Ein neues Thema erstellen  Auf das Thema antworten  [ 1 Beitrag ] 
Autor Nachricht
BeitragVerfasst: 28.01.2005, 00:08 

Registriert: 17.10.2004, 12:11
Beiträge: 171
Wohnort: nähe Bielefeld
Hallo

Ich habe mal wieder nen wunsch wo ich nicht weiter komme.....ich habe das plugin_map_random.sma plugin installiert und muss sagen dass ist echt super klasse...ABER...

1. Ich hätte gerne das nur 3 maps zur wahl stehen und nicht 5.....

2. Ich hätte gerne dass wenn ein map das vote gewinnt das laufende map erst zuende läuft und dann zum gewonnenen map wächselt und nicht sofort..

3. Das der vote mindestens 60 oder 120 sec läuft

Kann mir da jemand helfen oder mir das plugin umschreiben ?????

ich bin da zu blöd zu :roll:

Danke euch schonmal


Gruß Ghost
Code:
/* This plugin will bring up a vote for 5 random maps at the end of the round 
   This is a direct replacement for plugin_hldsld_mapvote.sma.  It will use all
   of the cvar settings for that plugin.  It is *highly* recommended you remove
   that plugin if you are running this one. 
   
   Idea for this plugin, all features, and testing done by Platinum of gamesniffer.com:27015 
   Go there to see it in action! */

/* $Id: plugin_map_random.sma,v 1.3 2002/02/21 yensid $ */

#include <core>
#include <console>
#include <string>
#include <admin>
#include <adminlib>

#define ACCESS_VOTE_MAPS 1
#define ACCESS_CONTROL_VOTE 2

/* The number of maps to store in memory so they can't be voted for again. 
   Feel free to change this.  Note that this number must be half or less
   than the maximum number of maps you have in your maps.ini. */
#define MAX_DENY_MAP 5

/* The number of maps to vote for.
   Do not change this without changing the vote() function lines! */
#define MAX_MAPS 5


enum VoteStatus {
	VoteInProgress,		/* Voting is allowed */
	VoteNotBegun,		/* Voting not allowed - no vote in progress, but a vote may be called */
	MapStart,		/* Voting not allowed - map just began */
	VoteFinished		/* Voting not allowed - vote just finished */
}

new STRING_VERSION[MAX_DATA_LENGTH] = "2.50.26";

new VoteStatus:MapVoteStatus = MapStart;

new ExtendCount = 0;
new ExtendMapTime = 0;
new DenyMaps[MAX_DENY_MAP][MAX_NAME_LENGTH];
new VoteMaps[MAX_MAPS][MAX_NAME_LENGTH];
new Deny_Map_Count;

public admin_startvote(HLCommand,HLData,HLUserName,UserIndex) {
	new Maps[MAX_DATA_LENGTH];
	new Data[MAX_DATA_LENGTH];
	convert_string(HLData,Data,MAX_DATA_LENGTH);
	strbreak(Data, Data, Maps, MAX_DATA_LENGTH);
	StartVoteHelper(0, Data);
	return PLUGIN_HANDLED;
}

public AllowMapVote(Timer,Repeat,HLUser,HLParam) {
	MapVoteStatus = VoteNotBegun;
}

public ExtendMap(Timer,Repeat,HLUser,HLParam) {
	new iFreq = getvar("admin_vote_freq");
	new ExecCommand[MAX_DATA_LENGTH];
	new Timelimit = 0;
	
	ExtendCount++;
	Timelimit = getvar("mp_timelimit");
	Timelimit += GetExtendTime();
	snprintf(ExecCommand, MAX_DATA_LENGTH, "mp_timelimit %i", Timelimit);
	exec(ExecCommand);
	if (iFreq > 0) {
		set_timer("AllowMapVote",iFreq,1); 
	}
	if(getvar("admin_vote_autostart") != 0) {
		/* Call for a vote five minutes before map ends */
		set_timer("StartMapVote", (ExtendMapTime - 5) * 60, 1, "");
	}
}

public FixVoteFreq(Timer,Repeat,HLUser,HLParam) {
	new strVoteAllow[MAX_NUMBER_LENGTH];
	new Cmd[MAX_DATA_LENGTH];
	
	convert_string(HLParam,strVoteAllow,MAX_NUMBER_LENGTH);
	snprintf(Cmd, MAX_TEXT_LENGTH, "vote_freq &s", strVoteAllow);
	exec(Cmd);
}

/* Return the amount of time (in minutes) to extend a map for if an extend vote wins. */
GetExtendTime() {
	/* If this is the first time we're extending the map, we want to extend it
	by the length of mp_timelimit.  Second and subsequent times through, we want
	to keep extending it by the original timelimit...not the new one (eg, if we
	start at 30 mins...on the second time through, mp_timelimit will say 60.  We
	want to jump to 90, not 120. */
	if (ExtendMapTime == 0) {
		ExtendMapTime = getvar("mp_timelimit");
	}
	return ExtendMapTime;
}

/* Handle a map vote's results. */
public HandleMapVote(WinningOption,HLMap,VoteCount,UserCount) {
	new strNumber[MAX_NUMBER_LENGTH];
	new Text[MAX_TEXT_LENGTH];
	new iMap = WinningOption - 1;
	new ChatTime = getvar("mp_chattime");
	
	new Ratio = getvar("admin_vote_ratio");
	if (VoteCount >= Ratio*UserCount/100) {
		if (WinningOption == 6) {
			new iExtend = GetExtendTime();
			snprintf(Text, MAX_TEXT_LENGTH, "Voting is now over. The map will be extended for %i more minutes.", iExtend);
			say(Text);
			set_timer("ExtendMap",2,1);
		} else {
			new strDeny_Map_Count[MAX_NUMBER_LENGTH];
			new Key[MAX_COMMAND_LENGTH];
			get_serverinfo("Deny_Map_Count", strDeny_Map_Count, MAX_NUMBER_LENGTH);
			Deny_Map_Count = strtonum(strDeny_Map_Count);
			if (Deny_Map_Count >= MAX_DENY_MAP) {
				Deny_Map_Count = 0;
			}
			snprintf(Key, MAX_NAME_LENGTH, "deny_map_%i", Deny_Map_Count);
			set_serverinfo(Key, VoteMaps[iMap]);
			Deny_Map_Count++;
			numtostr(Deny_Map_Count, strDeny_Map_Count);
			set_serverinfo("Deny_Map_Count", strDeny_Map_Count);
			snprintf(Text, MAX_TEXT_LENGTH, "Changing map to %s due to vote.", VoteMaps[iMap]);
			say(Text);
			if (ChatTime < 5) {
				exec("mp_chattime 5");
			}
			// added in 1.3:
			changelevel( VoteMaps[iMap], 5 );
/* removed in 1.3 to use new changelevel function
			setstrvar("mp_timelimit","1");
			set_timer("ChangeMap",2,1,VoteMaps[iMap]);
*/
		}
	} else {
		numtostr(Ratio*UserCount/100,strNumber);
		snprintf(Text, MAX_TEXT_LENGTH, "Map vote succeeded, but not enough votes for change (needed %s)", strNumber);
		say(Text);
	}
	MapVoteStatus = VoteFinished;
}

public HandleSay(HLCommand,HLData,HLUserName,UserIndex) {
	new Data[MAX_DATA_LENGTH];
	
	convert_string(HLData,Data,MAX_DATA_LENGTH);

	strstripquotes(Data);
	if (strmatch(Data, "rockthevote", 11)==1 || strmatch(Data, "mapvote", 7)==1) {
		new Maps[MAX_DATA_LENGTH];
		strbreak(Data, Data, Maps, MAX_DATA_LENGTH);
		StartVoteHelper(1, Maps);
	}
	return PLUGIN_CONTINUE;
}

public StartMapVote(Timer,Repeat,HLUser,HLParam) {
	new Extend = 0;
	new iMaxExtend = getvar("admin_vote_maxextend");
	new LoadFile[MAX_NAME_LENGTH];
	new MapFileSize;
	new MapLine;
	new Key[MAX_NAME_LENGTH];
	new iExtend = GetExtendTime();
	new Target[MAX_NAME_LENGTH];
	new MaxPlayers = maxplayercount();
	new VoteAllow = getvar("vote_freq");
	new strVoteAllow[MAX_NUMBER_LENGTH];
	new Match;
	new Data[MAX_DATA_LENGTH];
	new Map[MAX_MAPS][MAX_NAME_LENGTH];
	
	convert_string(HLParam,Data,MAX_DATA_LENGTH);
	
	if(MapVoteStatus==VoteInProgress) {
		return PLUGIN_HANDLED;
	}
	MapVoteStatus = VoteInProgress;
	if (strlen(Data)!=0) {
		strcpy(Map[0], Data, MAX_DATA_LENGTH);
		for (new i = 0; i < MAX_MAPS; ++i) {
			if (strlen(Map[i])!=0) {
				strbreak(Map[i], Map[i], Map[i+1], MAX_DATA_LENGTH);
			}
		}
	}
			
	getstrvar("maps_file", LoadFile, MAX_NAME_LENGTH);
	if ((strlen(LoadFile)==0) || (streq(LoadFile, "0")==1)) {
		strcpy(LoadFile, "mapcycle.txt", 13);
	}
	if(ExtendCount < iMaxExtend || iMaxExtend == 0) {
		Extend = 1;
	}
	MapFileSize = filesize(LoadFile);
	if (MapFileSize >= MAX_DENY_MAP * 2) {
		for (new i = 0; i < MAX_DENY_MAP; ++i) {
			snprintf(Key, MAX_NAME_LENGTH, "deny_map_%i", i);
			get_serverinfo(Key, DenyMaps[i], MAX_NAME_LENGTH);
		}
	} else {
		log ("Cannot restrict maps in map vote because MAX_DENY_MAP is greater than or equal to half the number of maps.");
		return PLUGIN_HANDLED;
	}
	if (vote_allowed()!=1) {
		exec("vote_freq 1");
		numtostr(VoteAllow, strVoteAllow);
		set_timer("FixVoteFreq", 10, 1, "strVoteAllow");
	}
	for (new i = 0; i < MAX_MAPS; ++i) {
		Match = 1;
		while(Match == 1) {
			Match = 0;
			if (valid_map(Map[i])!=1) {
				MapLine = random(MapFileSize);
				readfile(LoadFile, VoteMaps[i], MapLine, MAX_TEXT_LENGTH);
			} else {
				strcpy(VoteMaps[i], Map[i], MAX_NAME_LENGTH);
				strinit(Map[i]);
			}
			for (new j = 0; j < MAX_DENY_MAP; ++j) {
				if ((streq(VoteMaps[i], DenyMaps[j])==1)||(streq(VoteMaps[i], "")==1)) {
					Match = 1;
				} else {
					if (i > 0) {
						for (new k = 0; k < i; ++k) {
							if (streq(VoteMaps[i], VoteMaps[k])==1) {
								Match = 1;
							}
						}
					}
				}
			}
		}
	}
	for (new i=1; i<=MaxPlayers; i++) {
		strinit(Target);
		if(playerinfo(i,Target,MAX_NAME_LENGTH)==1) {
			execclient(Target,"speak gman/gman_choose1");
		}
	}
	if (Extend == 1) {
		new strExtend[MAX_NUMBER_LENGTH];
		snprintf(strExtend, MAX_NUMBER_LENGTH, "Extend by %i", iExtend);
		vote("Change map to:", VoteMaps[0], VoteMaps[1], VoteMaps[2], VoteMaps[3], VoteMaps[4], strExtend, "HandleMapVote", LoadFile);
	} else {
		vote("Change map to:", VoteMaps[0], VoteMaps[1], VoteMaps[2], VoteMaps[3], VoteMaps[4], "HandleMapVote", LoadFile);
	}
	return PLUGIN_HANDLED;
}

StartVoteHelper(Public = 0, Maps[]) {
	new Text[MAX_TEXT_LENGTH];
	
	if (check_auth(ACCESS_VOTE_MAPS) == 0) {
		reject_message(Public);
		return PLUGIN_HANDLED;
	}
	
	if (getvar("admin_vote_freq") <= 0) {
		if (check_auth(ACCESS_CONTROL_VOTE) == 0) {
			reject_message(Public);
			return PLUGIN_HANDLED;
		}
	}

	if (MapVoteStatus==VoteInProgress) {
		strcpy(Text,"A map vote is already in progress.",MAX_TEXT_LENGTH);
	} else if (MapVoteStatus==VoteNotBegun) {
		set_timer("StartMapVote", 1, 1, Maps);
		return PLUGIN_HANDLED;
	} else if (MapVoteStatus==MapStart) {
		new iFreq = getvar("admin_vote_freq") / 60;
		snprintf(Text,MAX_TEXT_LENGTH,"A map vote is not allowed within %i minutes of the map start.",iFreq);
	} else if (MapVoteStatus==VoteFinished) {
		new iFreq = getvar("admin_vote_freq") / 60;
		snprintf(Text,MAX_TEXT_LENGTH,"A map vote is not allowed within %i minutes of a previous vote.",iFreq);
	} else {
		strcpy(Text,"Oops.  Apparently, there's an unhandled map vote status here.",MAX_TEXT_LENGTH);
	}
	if (Public == 0) {
		selfmessage(Text);
	} else {
		say(Text);
	}
	return PLUGIN_HANDLED;
}

public plugin_init() {
	plugin_registerinfo("Admin Random Map Vote Plugin","Runs a vote for random maps at the end of the round.",STRING_VERSION);
	
	plugin_registercmd("admin_startvote","admin_startvote",ACCESS_VOTE_MAPS,"admin_startvote [<mapnames>]: Starts a random map vote.  Optionally, include mapnames.");
	plugin_registercmd("say","HandleSay",ACCESS_ALL);
	plugin_registerhelp("say",ACCESS_VOTE_MAPS,"say mapvote [<mapnames>]: Starts a random map vote.  Optionally, include mapnames.");
	plugin_registerhelp("say",ACCESS_VOTE_MAPS,"say rockthevote [<mapnames>]: Starts a random map vote.  Optionally, include mapnames.");
	
	new iFreq = getvar("admin_vote_freq");
	new intTimeLimit = getvar("mp_timelimit") * 60;
	new intTime = timeleft(0);
	
	/* If the map is not yet iFreq seconds in, disable voting until it is */
	MapVoteStatus = MapStart;
	if (iFreq > 0 && intTime > (intTimeLimit - iFreq)) {
		set_timer("AllowMapVote",intTime - (intTimeLimit - iFreq), 1);
	}
	if(getvar("admin_vote_autostart") != 0) {
		if (intTime > 300) {
			/* Call for a vote five minutes before map ends */
			set_timer("StartMapVote", intTime - 300, 1, ""); 
		}
	}
	return PLUGIN_CONTINUE;
}


Dateianhänge:
Dateikommentar: ich habs auch nochmal drangehängt
plugin_map_random.sma [10.3 KiB]
136-mal heruntergeladen
Nach oben
   
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen  Auf das Thema antworten  [ 1 Beitrag ] 


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Powered by phpBB® Forum Software © phpBB Limited
Deutsche Übersetzung durch phpBB.de
Original Design von "[ Half-Life Admin Mod © Alfred Reynolds 2000-2003 ] - [ site design by Jägermeister ]"