plugins/basevotes.sp
changeset 1285 a83f449ab2f8
parent 1284 ac293d8351a3
child 1286 de885ef8d915
     1.1 --- a/plugins/basevotes.sp	Wed Aug 08 23:45:24 2007 +0000
     1.2 +++ b/plugins/basevotes.sp	Thu Aug 09 00:31:45 2007 +0000
     1.3 @@ -66,11 +66,13 @@
     1.4  
     1.5  new String:g_voteArg[256];	/* Used to hold ban/kick reasons or vote questions */
     1.6  
     1.7 +// Temporary global until GetMenuTitle() is added.
     1.8 +new String:g_votetitle[64];
     1.9  
    1.10  public OnPluginStart()
    1.11  {
    1.12  	LoadTranslations("common.phrases");
    1.13 -	LoadTranslations("plugin.basevotes");
    1.14 +	LoadTranslations("basevotes.phrases");
    1.15  	
    1.16  	RegAdminCmd("sm_votemap", Command_Votemap, ADMFLAG_VOTE|ADMFLAG_CHANGEMAP, "sm_votemap <mapname> [mapname2] ... [mapname5] ");
    1.17  	RegAdminCmd("sm_votekick", Command_Votekick, ADMFLAG_VOTE|ADMFLAG_KICK, "sm_votekick <player> [reason]");
    1.18 @@ -134,12 +136,21 @@
    1.19  	if (mapCount == 1)
    1.20  	{
    1.21  		strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]);
    1.22 +		
    1.23 +		// Temp
    1.24 +		strcopy(g_votetitle, sizeof(g_votetitle), "Change Map To");
    1.25 +			
    1.26  		SetMenuTitle(g_hVoteMenu, "Change Map To");
    1.27  		AddMenuItem(g_hVoteMenu, maps[0], "Yes");
    1.28  		AddMenuItem(g_hVoteMenu, "no", "No");
    1.29  	}
    1.30  	else
    1.31  	{
    1.32 +		g_voteInfo[VOTE_NAME][0] = '\0';
    1.33 +		
    1.34 +		// Temp
    1.35 +		strcopy(g_votetitle, sizeof(g_votetitle), "Map Vote");
    1.36 +		
    1.37  		SetMenuTitle(g_hVoteMenu, "Map Vote");
    1.38  		for (new i = 0; i < mapCount; i++)
    1.39  		{
    1.40 @@ -175,7 +186,7 @@
    1.41  	new len = BreakString(text, g_voteArg, sizeof(g_voteArg));
    1.42  	new pos = len;
    1.43  	
    1.44 -	while (pos != -1 && answerCount < 5)
    1.45 +	while (args > 1 && pos != -1 && answerCount < 5)
    1.46  	{	
    1.47  		pos = BreakString(text[len], answers[answerCount], sizeof(answers[]));
    1.48  		answerCount++;
    1.49 @@ -193,7 +204,7 @@
    1.50  	g_hVoteMenu = CreateMenu(Handler_VoteCallback);
    1.51  	SetMenuTitle(g_hVoteMenu, "%s?", g_voteArg);
    1.52  	
    1.53 -	if (answerCount == 1)
    1.54 +	if (answerCount < 2)
    1.55  	{
    1.56  		AddMenuItem(g_hVoteMenu, "Yes", "Yes");
    1.57  		AddMenuItem(g_hVoteMenu, "No", "No");
    1.58 @@ -255,6 +266,9 @@
    1.59  	
    1.60  	g_voteType = voteType:kick;
    1.61  	
    1.62 +	// Temp
    1.63 +	strcopy(g_votetitle, sizeof(g_votetitle), "Votekick Player");	
    1.64 +	
    1.65  	g_hVoteMenu = CreateMenu(Handler_VoteCallback);
    1.66  	SetMenuTitle(g_hVoteMenu, "Votekick Player");
    1.67  	AddMenuItem(g_hVoteMenu, "No", "Yes");
    1.68 @@ -310,6 +324,9 @@
    1.69  
    1.70  	g_voteType = voteType:ban;
    1.71  	
    1.72 +	// Temp
    1.73 +	strcopy(g_votetitle, sizeof(g_votetitle), "Voteban Player");		
    1.74 +	
    1.75  	g_hVoteMenu = CreateMenu(Handler_VoteCallback);
    1.76  	SetMenuTitle(g_hVoteMenu, "Voteban Player");
    1.77  	AddMenuItem(g_hVoteMenu, "No", "Yes");
    1.78 @@ -328,17 +345,18 @@
    1.79  	}
    1.80  	else if (action == MenuAction_Display)
    1.81  	{
    1.82 -		decl String:display[64];
    1.83 -		GetMenuItem(menu, param2, "", 0, _, display, sizeof(display));
    1.84 -	 
    1.85 +		PrintToChatAll("Inside display");
    1.86  	 	if (g_voteType != voteType:question)
    1.87  	 	{
    1.88 +			decl String:title[64];
    1.89 +			//GetMenuTitle(g_hVoteMenu, title, sizeof(title));
    1.90 +			strcopy(title, sizeof(title), g_votetitle);
    1.91 +			
    1.92  	 		decl String:buffer[255];
    1.93 -			Format(buffer, sizeof(buffer), "%T", display, param1);
    1.94 +			Format(buffer, sizeof(buffer), "%T", title, param1, g_voteInfo[VOTE_NAME]);
    1.95  
    1.96 -			return RedrawMenuItem(buffer);
    1.97 +			SetMenuTitle(g_hVoteMenu, buffer);
    1.98  		}
    1.99 -	
   1.100  	}
   1.101  	else if (action == MenuAction_DisplayItem)
   1.102  	{
   1.103 @@ -366,7 +384,7 @@
   1.104  		if (totalVotes < 1)
   1.105  		{
   1.106  			PrintToChatAll("[SM] %t", "No Votes Cast");
   1.107 -			return;
   1.108 +			return 0;
   1.109  		}
   1.110  		
   1.111  		GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display));
   1.112 @@ -404,7 +422,7 @@
   1.113  			{
   1.114  				case (voteType:question):
   1.115  				{
   1.116 -					PrintToChatAll("[SM] %t", "Vote End", g_voteArg, item, RoundToNearest(100.0*percent), totalVotes);
   1.117 +					PrintToChatAll("[SM] %t", "Vote End", g_voteArg, item);
   1.118  				}
   1.119  				
   1.120  				case (voteType:map):
   1.121 @@ -424,7 +442,7 @@
   1.122  					}
   1.123  					
   1.124  					PrintToChatAll("[SM] %t", "Kicked player", g_voteInfo[VOTE_NAME]);					
   1.125 -					LogMessage("Vote kick successful, kicked \"%L\" (reason \"%s\")", g_voteClient[VOTE_USERID], g_voteArg);
   1.126 +					LogMessage("Vote kick successful, kicked \"%L\" (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg);
   1.127  					
   1.128  					ServerCommand("kickid %d \"%s\"", g_voteClient[VOTE_USERID], g_voteArg);					
   1.129  				}
   1.130 @@ -445,7 +463,7 @@
   1.131  					}
   1.132  					
   1.133  					PrintToChatAll("[SM] %t", "Banned player", g_voteInfo[VOTE_NAME], 30);
   1.134 -					LogMessage("Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", g_voteClient[VOTE_USERID], g_voteArg);
   1.135 +					LogMessage("Vote ban successful, banned \"%L\" (minutes \"30\") (reason \"%s\")", g_voteClient[VOTE_CLIENTID], g_voteArg);
   1.136  					
   1.137  					ServerCommand("banid %d %s", 30, g_voteClient[VOTE_AUTHID]);
   1.138  					ServerCommand("kickid %d \"%s\"", g_voteClient[VOTE_USERID], g_voteArg);				
   1.139 @@ -453,6 +471,8 @@
   1.140  			}
   1.141  		}
   1.142  	}
   1.143 +	
   1.144 +	return 0;
   1.145  }
   1.146  
   1.147  /*