Raised This Month: $12 Target: $400
 3% 

[CSGO] Getting info from advanced votes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-04-2016 , 23:26   [CSGO] Getting info from advanced votes
Reply With Quote #1

I'm trying to get a clients name and what they voted for so I can log it from the VoteHandler. Here is what I have so far:

PHP Code:
public void H_VoteForceRTVCallback(Menu menuint num_votesint num_clients, const int[][] client_infoint num_items, const int[][] item_info)
{
    for (
int i 0num_clientsi++)
    {
        
char name[64];
        
int client GetClientOfUserId(i);
        
GetClientName(clientname64);
        
LogToFileEx(g_sLogPath"%s voted for %i"nameclient_info[i][VOTEINFO_CLIENT_ITEM]);
    }

Although this returned the name of the server instead.
__________________
Accepting PM's for private requests!
Jackol1234 is offline
Blowst
Senior Member
Join Date: Feb 2011
Location: Korea, Republic of
Old 06-05-2016 , 00:54   Re: [CSGO] Getting info from advanced votes
Reply With Quote #2

get info from client_info array.

PHP Code:
public void H_VoteForceRTVCallback(Menu menuint num_votesint num_clients, const int[][] client_infoint num_items, const int[][] item_info)
{
    for (
int i 0num_clientsi++)
    {
        
int client client_info[i][CLIENTINFO_CLIENT_INDEX/*or something, idk about this plugin.*/]
        
char name[64];
        
GetClientName(clientname64);
        
LogToFileEx(g_sLogPath"%s voted for %i"nameclient_info[i][VOTEINFO_CLIENT_ITEM]);
    }

__________________
Sorry about my poor English

Blowst is offline
Jackol1234
Senior Member
Join Date: Apr 2015
Old 06-05-2016 , 01:08   Re: [CSGO] Getting info from advanced votes
Reply With Quote #3

That makes a lot of sense. I didn't notice CLIENTINFO_CLIENT_INDEX in the include I was trying to write this from. Hopefully this works.

Edit: It worked now to translate the integer into a yes or no. I'm trying to understand this portion of the handler. I got this code from ckSurf and I'm confused how it gets this:

PHP Code:
if (item_info[0][VOTEINFO_ITEM_INDEX] == 0) {    // If the winner is Yes
        
votesYes item_info[0][VOTEINFO_ITEM_VOTES];
        if (
num_items 1) {
            
votesNo item_info[1][VOTEINFO_ITEM_VOTES];
        }
    }
    else {    
// If the winner is No
        
votesNo item_info[0][VOTEINFO_ITEM_VOTES];
        if (
num_items 1) {
            
votesYes item_info[1][VOTEINFO_ITEM_VOTES];
        }
    } 
What is this checking "item_info[0][VOTEINFO_ITEM_INDEX] == 0" in the if statement and why do the votesNo and votesYes change places depending on the outcome of the if statement?
__________________
Accepting PM's for private requests!

Last edited by Jackol1234; 06-05-2016 at 01:16.
Jackol1234 is offline
Blowst
Senior Member
Join Date: Feb 2011
Location: Korea, Republic of
Old 06-05-2016 , 02:51   Re: [CSGO] Getting info from advanced votes
Reply With Quote #4

Quote:
Originally Posted by Jackol1234 View Post
That makes a lot of sense. I didn't notice CLIENTINFO_CLIENT_INDEX in the include I was trying to write this from. Hopefully this works.

Edit: It worked now to translate the integer into a yes or no. I'm trying to understand this portion of the handler. I got this code from ckSurf and I'm confused how it gets this:

PHP Code:
if (item_info[0][VOTEINFO_ITEM_INDEX] == 0) {    // If the winner is Yes
        
votesYes item_info[0][VOTEINFO_ITEM_VOTES];
        if (
num_items 1) {
            
votesNo item_info[1][VOTEINFO_ITEM_VOTES];
        }

    }
    else {    
// If the winner is No
        
votesNo item_info[0][VOTEINFO_ITEM_VOTES];
        if (
num_items 1) {
            
votesYes item_info[1][VOTEINFO_ITEM_VOTES];
        }
    } 
What is this checking "item_info[0][VOTEINFO_ITEM_INDEX] == 0" in the if statement and why do the votesNo and votesYes change places depending on the outcome of the if statement?
item_info array is sorted in descending order(number of votes)

So, item_info[0] is the winner item.
then item_info[1] is the 2nd voted item.

next, item_info[0][VOTEINFO_ITEM_INDEX] means winner item's item index

so what's item indices mean here?

you could find this code.
PHP Code:
public void StartVoteExtend(int client)
{
    
char szPlayerName[MAX_NAME_LENGTH];    
    
GetClientName(clientszPlayerNameMAX_NAME_LENGTH);
    
CPrintToChatAll("[{olive}CK{default}] Vote to Extend started by {green}%s{default}"szPlayerName);

    
g_szUsedVoteExtend[g_VoteExtends] = g_szSteamID[client];    // Add the user's steam ID to the list
    
g_VoteExtends++;    // Increment the total number of vote extends so far

    
Menu voteExtend CreateMenu(H_VoteExtend);
    
SetVoteResultCallback(voteExtendH_VoteExtendCallback);
    
char szMenuTitle[128];

    
char buffer[8];
    
IntToString(RoundToFloor(GetConVarFloat(g_hVoteExtendTime)), buffersizeof(buffer));

    
Format(szMenuTitlesizeof(szMenuTitle), "Extend map for %s minutes?"buffer);
    
SetMenuTitle(voteExtendszMenuTitle);
    
    
AddMenuItem(voteExtend"""Yes"); // << this is the first added item! So index = 0
    
AddMenuItem(voteExtend"""No"); // << this is the second added item! So index = 1
    
SetMenuExitButton(voteExtendfalse);
    
VoteMenuToAll(voteExtend20);

"item_info[0][VOTEINFO_ITEM_INDEX] == 0" means the winner item's index is 0("Yes")

VOTEINFO_ITEM_VOTES means "how many clients voted this item."

at former statement(if (item_info[0][VOTEINFO_ITEM_INDEX] == 0)) winner is "Yes"

so, put winner("Yes" item)'s vote count(item_info[0][VOTEINFO_ITEM_VOTES]) into votesYes
and put loser("No" item)'s vote count(item_info[1][VOTEINFO_ITEM_VOTES]) into votesNo

at latter statement(else) winner is "No" or something else

so, put winner("No" item)'s vote count(item_info[0][VOTEINFO_ITEM_VOTES]) into votesNo
and put loser("Yes" item)'s vote count(item_info[1][VOTEINFO_ITEM_VOTES]) into votesYes

Sorry for my poor explanation.

you can check out here for more info:
https://sm.alliedmods.net/new-api/menus
__________________
Sorry about my poor English


Last edited by Blowst; 06-05-2016 at 02:55.
Blowst is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:52.


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