diff options
Diffstat (limited to 'src/game/client/components/voting.cpp')
| -rw-r--r-- | src/game/client/components/voting.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index b81cfb97..d90e617f 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -4,12 +4,29 @@ void VOTING::con_callvote(void *result, void *user_data) { + NETMSG_CL_CALLVOTE msg = {0}; + msg.type = console_arg_string(result, 0); + msg.value = console_arg_string(result, 1); + msg.pack(MSGFLAG_VITAL); + client_send_msg(); } void VOTING::con_vote(void *result, void *user_data) { + VOTING *self = (VOTING *)user_data; + if(str_comp_nocase(console_arg_string(result, 0), "yes") == 0) + self->vote(1); + else if(str_comp_nocase(console_arg_string(result, 0), "no") == 0) + self->vote(-1); } - + +void VOTING::vote(int v) +{ + NETMSG_CL_VOTE msg = {v}; + msg.pack(MSGFLAG_VITAL); + client_send_msg(); +} + VOTING::VOTING() { on_reset(); @@ -26,7 +43,7 @@ void VOTING::on_reset() void VOTING::on_console_init() { - MACRO_REGISTER_COMMAND("callvote", "r", con_callvote, this); + MACRO_REGISTER_COMMAND("callvote", "sr", con_callvote, this); MACRO_REGISTER_COMMAND("vote", "r", con_vote, this); } |