core/smn_menus.cpp
changeset 2056 f1fcde46ac7c
parent 2042 4a2faafca477
child 2289 44045ead61cd
     1.1 --- a/core/smn_menus.cpp	Sat May 17 05:10:36 2008 +0000
     1.2 +++ b/core/smn_menus.cpp	Sat May 17 05:12:52 2008 +0000
     1.3 @@ -1405,6 +1405,49 @@
     1.4  	return *s_CurSelectPosition;
     1.5  }
     1.6  
     1.7 +static cell_t IsClientInVotePool(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	int client;
    1.10 +	IGamePlayer *pPlayer;
    1.11 +
    1.12 +	client = params[1];
    1.13 +	if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL)
    1.14 +	{
    1.15 +		return pContext->ThrowNativeError("Invalid client index %d", client);
    1.16 +	}
    1.17 +
    1.18 +	if (!g_Menus.IsVoteInProgress())
    1.19 +	{
    1.20 +		return pContext->ThrowNativeError("No vote is in progress");
    1.21 +	}
    1.22 +
    1.23 +	return g_Menus.IsClientInVotePool(client) ? 1 : 0;
    1.24 +}
    1.25 +
    1.26 +static cell_t RedrawClientVoteMenu(IPluginContext *pContext, const cell_t *params)
    1.27 +{
    1.28 +	int client;
    1.29 +	IGamePlayer *pPlayer;
    1.30 +
    1.31 +	client = params[1];
    1.32 +	if ((pPlayer = g_Players.GetPlayerByIndex(client)) == NULL)
    1.33 +	{
    1.34 +		return pContext->ThrowNativeError("Invalid client index %d", client);
    1.35 +	}
    1.36 +
    1.37 +	if (!g_Menus.IsVoteInProgress())
    1.38 +	{
    1.39 +		return pContext->ThrowNativeError("No vote is in progress");
    1.40 +	}
    1.41 +
    1.42 +	if (!g_Menus.IsClientInVotePool(client))
    1.43 +	{
    1.44 +		return pContext->ThrowNativeError("Client is not in the voting pool");
    1.45 +	}
    1.46 +
    1.47 +	return g_Menus.RedrawClientVoteMenu(client) ? 1 : 0;
    1.48 +}
    1.49 +
    1.50  class EmptyMenuHandler : public IMenuHandler
    1.51  {
    1.52  public:
    1.53 @@ -1505,7 +1548,9 @@
    1.54  	{"GetPanelStyle",			GetPanelStyle},
    1.55  	{"InsertMenuItem",			InsertMenuItem},
    1.56  	{"InternalShowMenu",		InternalShowMenu},
    1.57 +	{"IsClientInVotePool",		IsClientInVotePool},
    1.58  	{"IsVoteInProgress",		IsVoteInProgress},
    1.59 +	{"RedrawClientVoteMenu",	RedrawClientVoteMenu},
    1.60  	{"RedrawMenuItem",			RedrawMenuItem},
    1.61  	{"RemoveAllMenuItems",		RemoveAllMenuItems},
    1.62  	{"RemoveMenuItem",			RemoveMenuItem},