1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/basefunvotes/votegravity.sp Sat Oct 13 04:43:42 2007 +0000
1.3 @@ -0,0 +1,106 @@
1.4 +
1.5 +DisplayVoteGravityMenu(client,count,String:items[5][])
1.6 +{
1.7 + LogAction(client, -1, "\"%L\" initiated a gravity vote.", client);
1.8 + ShowActivity(client, "%t", "Initiated Vote Gravity");
1.9 +
1.10 + g_voteType = voteType:gravity;
1.11 +
1.12 + g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL);
1.13 +
1.14 + if (count == 1)
1.15 + {
1.16 + strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), items[0]);
1.17 +
1.18 + SetMenuTitle(g_hVoteMenu, "Change Gravity To");
1.19 + AddMenuItem(g_hVoteMenu, items[0], "Yes");
1.20 + AddMenuItem(g_hVoteMenu, VOTE_NO, "No");
1.21 + }
1.22 + else
1.23 + {
1.24 + g_voteInfo[VOTE_NAME][0] = '\0';
1.25 +
1.26 + SetMenuTitle(g_hVoteMenu, "Gravity Vote");
1.27 + for (new i = 0; i < count; i++)
1.28 + {
1.29 + AddMenuItem(g_hVoteMenu, items[i], items[i]);
1.30 + }
1.31 + }
1.32 +
1.33 + SetMenuExitButton(g_hVoteMenu, false);
1.34 + VoteMenuToAll(g_hVoteMenu, 20);
1.35 +}
1.36 +
1.37 +public AdminMenu_VoteGravity(Handle:topmenu,
1.38 + TopMenuAction:action,
1.39 + TopMenuObject:object_id,
1.40 + param,
1.41 + String:buffer[],
1.42 + maxlength)
1.43 +{
1.44 + if (action == TopMenuAction_DisplayOption)
1.45 + {
1.46 + Format(buffer, maxlength, "%T", "Vote Gravity", param);
1.47 + }
1.48 + else if (action == TopMenuAction_SelectOption)
1.49 + {
1.50 + /* Might need a better way of selecting the list of pre-defined gravity choices */
1.51 + new String:items[5][5] ={"200","400","800","1600","3200"};
1.52 + DisplayVoteGravityMenu(param,5, items);
1.53 + }
1.54 + else if (action == TopMenuAction_DrawOption)
1.55 + {
1.56 + /* disable this option if a vote is already running */
1.57 + buffer[0] = IsVoteInProgress() ? ITEMDRAW_IGNORE : ITEMDRAW_DEFAULT;
1.58 + }
1.59 +}
1.60 +
1.61 +public Action:Command_VoteGravity(client, args)
1.62 +{
1.63 + if (args < 1)
1.64 + {
1.65 + ReplyToCommand(client, "[SM] Usage: sm_votegravity <amount> [amount2] ... [amount5]");
1.66 + return Plugin_Handled;
1.67 + }
1.68 +
1.69 + if (IsVoteInProgress())
1.70 + {
1.71 + ReplyToCommand(client, "[SM] %t", "Vote in Progress");
1.72 + return Plugin_Handled;
1.73 + }
1.74 +
1.75 + if (!TestVoteDelay(client))
1.76 + {
1.77 + return Plugin_Handled;
1.78 + }
1.79 +
1.80 + decl String:text[256];
1.81 + GetCmdArgString(text, sizeof(text));
1.82 +
1.83 + decl String:items[5][64];
1.84 + new count;
1.85 + new len, pos;
1.86 +
1.87 + while (pos != -1 && count < 5)
1.88 + {
1.89 + pos = BreakString(text[len], items[count], sizeof(items[]));
1.90 +
1.91 + decl Float:temp;
1.92 + if (StringToFloatEx(items[count], temp) == 0)
1.93 + {
1.94 + ReplyToCommand(client, "[SM] %t", "Invalid Amount");
1.95 + return Plugin_Handled;
1.96 + }
1.97 +
1.98 + count++;
1.99 +
1.100 + if (pos != -1)
1.101 + {
1.102 + len += pos;
1.103 + }
1.104 + }
1.105 +
1.106 + DisplayVoteGravityMenu(client, count, items);
1.107 +
1.108 + return Plugin_Handled;
1.109 +}
1.110 \ No newline at end of file