plugins/include/mapchooser.inc
author Asher Baker <asherkin@gmail.com>
Thu Apr 26 16:58:18 2012 +0100 (2012-04-26)
changeset 3488 bee90c8ef6c3
parent 3150 a7a63f60830b
permissions -rw-r--r--
Fixed client serials not being unique on Windows (bug 5285, r=psychonic).
     1 #if defined _mapchooser_included_
     2   #endinput
     3 #endif
     4 #define _mapchooser_included_
     5 
     6 enum NominateResult
     7 {
     8 	Nominate_Added,			/** The map was added to the nominate list */
     9 	Nominate_Replaced,		/** A clients existing nomination was replaced */
    10 	Nominate_AlreadyInVote,	/** Specified map was already in the vote */
    11 	Nominate_InvalidMap,	/** Mapname specifed wasn't a valid map */
    12 	Nominate_VoteFull,		/** This will only occur if force was set to false */
    13 };
    14 
    15 enum MapChange
    16 {
    17 	MapChange_Instant,		/** Change map as soon as the voting results have come in */
    18 	MapChange_RoundEnd,		/** Change map at the end of the round */
    19 	MapChange_MapEnd,		/** Change the sm_nextmap cvar */
    20 };
    21 
    22 /**
    23  * Attempt to add a map to the mapchooser map list.
    24  *
    25  * @param map		Map to add.
    26  * @param force		Should we force the map in even if it requires overwriting an existing nomination?
    27  * @param owner		Client index of the nominater. If the client disconnects the nomination will be removed. Use 0 for constant nominations
    28  * @return			Nominate Result of the outcome
    29  */
    30 native NominateResult:NominateMap(const String:map[], bool:force, owner);
    31 
    32 /**
    33  * Attempt to remove a map from the mapchooser map list.
    34  *
    35  * @param map		Map to remove.
    36  * @return			True if the nomination was found and removed, or false if the nomination was not found.
    37  */
    38 native bool:RemoveNominationByMap(const String:map[]);
    39 
    40 /**
    41  * Attempt to remove a map from the mapchooser map list.
    42  *
    43  * @param owner		Client index of the nominater.
    44  * @return			True if the nomination was found and removed, or false if the nomination was not found.
    45  */
    46 native bool:RemoveNominationByOwner(owner);
    47 
    48 /**
    49  * Gets the current list of excluded maps.
    50  *
    51  * @param array		An ADT array handle to add the map strings to.
    52  * @noreturn
    53  */
    54 native GetExcludeMapList(Handle:array);
    55 
    56 /**
    57  * Gets the current list of nominated maps.
    58  *
    59  * @param maparray		An ADT array handle to add the map strings to.
    60  * @param ownerarray	An optional ADT array handle to add the nominator client indexes to.
    61  * @noreturn
    62  */
    63 native GetNominatedMapList(Handle:maparray, Handle:ownerarray = INVALID_HANDLE);
    64 
    65 /**
    66  * Checks if MapChooser will allow a vote
    67  *
    68  * @return			True if a vote can be held, or false if mapchooser is already holding a vote.
    69  */
    70 native bool:CanMapChooserStartVote();
    71 
    72 /**
    73  * Initiates a MapChooser map vote
    74  *
    75  * Note: If no input array is specified mapchooser will use its internal list. This includes
    76  * any nominations and excluded maps (as per mapchoosers convars).
    77  *
    78  * @param when			MapChange consant of when the resulting mapchange should occur.
    79  * @param inputarray	ADT array list of maps to add to the vote.
    80  */
    81 native InitiateMapChooserVote(MapChange:when, Handle:inputarray=INVALID_HANDLE);
    82 
    83 /**
    84  * Checks if MapChooser's end of map vote has completed.
    85  *
    86  * @return			True if complete, false otherwise.
    87  */
    88 native bool:HasEndOfMapVoteFinished();
    89 
    90 /**
    91  * Checks if MapChooser is set to run an end of map vote.
    92  *
    93  * @return			True if enabled, false otherwise.
    94  */
    95 native bool:EndOfMapVoteEnabled();
    96 
    97 /**
    98  * Called when mapchooser removes a nomination from its list.
    99  * Nominations cleared on map start will not trigger this forward
   100  */
   101 forward OnNominationRemoved(const String:map[], owner);
   102 
   103 /**
   104  * Called when mapchooser starts a Map Vote.
   105  */
   106 forward OnMapVoteStarted();
   107 
   108 
   109 public SharedPlugin:__pl_mapchooser = 
   110 {
   111 	name = "mapchooser",
   112 	file = "mapchooser.smx",
   113 #if defined REQUIRE_PLUGIN
   114 	required = 1,
   115 #else
   116 	required = 0,
   117 #endif
   118 };
   119 
   120 public __pl_mapchooser_SetNTVOptional()
   121 {
   122 	MarkNativeAsOptional("NominateMap");
   123 	MarkNativeAsOptional("RemoveNominationByMap");
   124 	MarkNativeAsOptional("RemoveNominationByOwner");
   125 	MarkNativeAsOptional("GetExcludeMapList");
   126 	MarkNativeAsOptional("GetNominatedMapList");
   127 	MarkNativeAsOptional("CanMapChooserStartVote");
   128 	MarkNativeAsOptional("InitiateMapChooserVote");
   129 	MarkNativeAsOptional("HasEndOfMapVoteFinished");
   130 	MarkNativeAsOptional("EndOfMapVoteEnabled");
   131 }
   132