AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   show the result got most votes (https://forums.alliedmods.net/showthread.php?t=19802)

[ --<-@ ] Black Rose 10-25-2005 21:07

show the result got most votes
 
how to make it show the result got most votes like in adminvote.sma i tryed to read that but that was hard... :P
i've got this4 now
Code:
#include <amxmodx> #include <amxmisc> new votes[4] new arg1[32] new arg2[32] new arg3[32] new arg4[32] new arg5[32] public plugin_init() {     register_plugin("--<-@ Vote", "1.0.0", "[ --<-@ ]")     register_menucmd(register_menuid("voting"),1023,"voting_handler")     register_concmd("rose_vote", "vote", ADMIN_VOTE, "<vote> <answer1> <answer2> <answer3> <answer4>") } public vote(id, level, cid)     {     if(!cmd_access(0, 0, 0, 1)) {         return PLUGIN_HANDLED     }     new Float:voting = get_cvar_float("amx_last_voting")     if (voting > get_gametime()) {         console_print(id, "A vote is already started", id)         return PLUGIN_HANDLED     }     read_argv(1, arg1, 31)     read_argv(2, arg2, 31)     read_argv(3, arg3, 31)     read_argv(4, arg4, 31)     read_argv(5, arg5, 31)         if (equal(arg1, "")) {         client_print(id, print_console, "[ --<-@ ] You need a question to start a vote.")         client_print(id, print_console, "[ --<-@ ] Usage: rose_vote <question> <answer1> <answer2> <answer3> <answer4>")         return PLUGIN_HANDLED     }     if (equal(arg2, "")) {         client_print(id, print_console, "[ --<-@ ] You need at least Two answers (You typed in 0).")         return PLUGIN_HANDLED     }     if (equal(arg3, "")) {         client_print(id, print_console, "[ --<-@ ] You need at least Two answers (You typed in 1).")         return PLUGIN_HANDLED     }     if (!equal(arg3, "")) {         new menubody[128], keys         if (!equal(arg3, "")) {             if (equal(arg4, "")) {                 format(menubody, 127, "%s^n^n1. %s^n2. %s", arg1, arg2, arg3)                 keys = MENU_KEY_1|MENU_KEY_2             }         }         if (!equal(arg4, "")) {             if (equal(arg5, "")) {                 format(menubody, 127, "%s^n^n1. %s^n2. %s^n3. %s", arg1, arg2, arg3, arg4)                 keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3             }         }         if (!equal(arg5, "")) {             format(menubody, 127, "%s^n^n1. %s^n2. %s^n3. %s^n4. %s", arg1, arg2, arg3, arg4, arg5)             keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4         }         for(new i = 0; i <= get_playersnum(); i++)             show_menu(i,keys,menubody,6,"voting")                 set_task(get_cvar_float("amx_vote_time"),"display_results")         new Float:vote_time = get_cvar_float("amx_vote_time") + 2.0         set_cvar_float("amx_last_voting", get_gametime() + vote_time)     }     return PLUGIN_HANDLED } public voting_handler(id, key) {     if(key == 0)         {         votes[0]++     }     if(key == 1)         {         votes[1]++     }     if(key == 2)         {         votes[2]++     }     if(key == 3)         {         votes[3]++     }     if(get_cvar_num("amx_vote_answers"))         {         new username[32]         get_user_name(id, username,31)         client_print(0, print_chat, "%s Voted For Option %i", username, key+1)     } } public display_results()     {     if (votes[0]+votes[1]+votes[2]+votes[3] > 0) {         if (!equal(arg3, "")) {             if (equal(arg4, "")) {                 client_print(0, print_chat, "[ --<-@ ] %s: (%s got %i votes) (%s got %i votes)", arg1, arg2, votes[0], arg3, votes[1])             }         }         if (!equal(arg4, "")) {             if (equal(arg5, "")) {                 client_print(0, print_chat, "[ --<-@ ] %s: (%s got %i votes) (%s got %i votes) (%s got %i votes)", arg1, arg2, votes[0], arg3, votes[1], arg4, votes[2])             }         }         if (!equal(arg5, "")) {             client_print(0, print_chat, "[ --<-@ ] %s: (%s got %i votes) (%s got %i votes) (%s got %i votes) (%s got %i votes)", arg1, arg2, votes[0], arg3, votes[1], arg4, votes[2] , arg5, votes[3])         }     }     else {         client_print(0, print_chat, "[ --<-@ ] Voting Failed, Try Voting Next Time")     }     votes[0] = 0     votes[1] = 0     votes[2] = 0     votes[3] = 0     set_cvar_float("amx_last_voting", get_gametime())     return PLUGIN_CONTINUE }


All times are GMT -4. The time now is 23:48.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.