Raised This Month: $32 Target: $400
 8% 

[CSGO] how i can create vote menu only for ct or tr ??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-23-2019 , 22:56   [CSGO] how i can create vote menu only for ct or tr ??
Reply With Quote #1

hi guys,
how i can create vote menu and only show for CT or T team??
for example vote menu for pause the game

sorry for bad speak english

Last edited by Dr.Mohammad; 03-23-2019 at 22:56.
Dr.Mohammad is offline
adma
Senior Member
Join Date: Oct 2015
Old 03-23-2019 , 23:22   Re: [CSGO] how i can create vote menu only for ct or tr ??
Reply With Quote #2

1. Build your Menu
2. Create array with only CT/T
3. Use VoteMenu to send vote to only the clients in the array

PHP Code:
#define CS_TEAM_NONE        0    /**< No team yet. */
#define CS_TEAM_SPECTATOR    1    /**< Spectators. */
#define CS_TEAM_T             2    /**< Terrorists. */
#define CS_TEAM_CT            3    /**< Counter-Terrorists. */

// Build your menu
Menu hMenu = new Menu(MenuHandler_Callback);
hMenu.SetTitle("Title");
hMenu.AddItem("item1""Item 1");
hMenu.AddItem("item2""Item 2");

// Build array of CT/T clients
int iNumClients;
int[] iClients = new int[MaxClients];

for (
int i 1<= MaxClients; ++i) {
  if (!
IsClientInGame(i)) continue;
  
  if (
GetClientTeam(i) == CS_TEAM_T) {
    
iClients[iNumClients++] = i;
  }
}

// Send vote menu to the clients in the array we just built
VoteMenu(hMenuiClientsiNumClientsMENU_TIME_FOREVER);

// Callback
public int MenuHandler_Callback(Menu hMenuMenuAction actionint iParam1int iParam2) {
  if (
action == MenuAction_Enddelete hMenu;

  
// Your own logic

  
return 0;

adma is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-25-2019 , 02:20   Re: [CSGO] how i can create vote menu only for ct or tr ??
Reply With Quote #3

Quote:
Originally Posted by adma View Post
1. Build your Menu
2. Create array with only CT/T
3. Use VoteMenu to send vote to only the clients in the array

PHP Code:
#define CS_TEAM_NONE        0    /**< No team yet. */
#define CS_TEAM_SPECTATOR    1    /**< Spectators. */
#define CS_TEAM_T             2    /**< Terrorists. */
#define CS_TEAM_CT            3    /**< Counter-Terrorists. */

// Build your menu
Menu hMenu = new Menu(MenuHandler_Callback);
hMenu.SetTitle("Title");
hMenu.AddItem("item1""Item 1");
hMenu.AddItem("item2""Item 2");

// Build array of CT/T clients
int iNumClients;
int[] iClients = new int[MaxClients];

for (
int i 1<= MaxClients; ++i) {
  if (!
IsClientInGame(i)) continue;
  
  if (
GetClientTeam(i) == CS_TEAM_T) {
    
iClients[iNumClients++] = i;
  }
}

// Send vote menu to the clients in the array we just built
VoteMenu(hMenuiClientsiNumClientsMENU_TIME_FOREVER);

// Callback
public int MenuHandler_Callback(Menu hMenuMenuAction actionint iParam1int iParam2) {
  if (
action == MenuAction_Enddelete hMenu;

  
// Your own logic

  
return 0;

thank you for help.

this code true??
PHP Code:
void VoteMenuPause(int clinet)
{
    
Menu hMenu = new Menu(VoteMenuPauseHandler_Callback);
    
char Char_BufferText[32], Char_RequesterName[64] = GetClientName(client);
    
int Int_Team GetClientTeam(client);
    
Format(Char_BufferTextsizeof(Char_BufferText), "%s Requested for pause [2 minutes]?"Char_RequesterName);
    
hMenu.SetTitle(Char_BufferText);
    
hMenu.AddItem("y""Yes");
    
hMenu.AddItem("n""No");
    
    
int iNumClients;
    
int[] iClients = new int[MaxClients];
    for(
int i 1<= MaxClients; ++i)
    {
        if (!
IsClientInGame(i)) continue;
        if (
GetClientTeam(i) == Int_Team)
        {
            
iClients[iNumClients++] = i;
        }
    }
    
    
Bool_VotePause true;
    
VoteMenu(hMenuiClientsiNumClientsMENU_TIME_FOREVER);
}

public 
int VoteMenuPauseHandler_Callback(Menu hMenuMenuAction actionint iParam1int iParam2)
{
    if(
action == MenuAction_End)
    {
        
/* This is called after VoteEnd */
        
delete hMenu;
    }
    else if(
action == MenuAction_VoteEnd)
    {
        
Bool_VotePause false;
        
        
/* 0=yes, 1=no */
        
if(param1 == 0)
        {
            
ServerCommand("mp_pause_match");
        }
    }

Dr.Mohammad is offline
adma
Senior Member
Join Date: Oct 2015
Old 03-25-2019 , 03:32   Re: [CSGO] how i can create vote menu only for ct or tr ??
Reply With Quote #4

This line is wrong:
PHP Code:
char Char_BufferText[32], Char_RequesterName[64] = GetClientName(client); 
"Strings" are just arrays of characters with a 0 as the last element. For example, "hello" is the same as {'h', 'e', 'l', 'l', 'o', 0}. Therefore, functions like GetClientName cannot actual return a "string", because you cannot return arrays in Sourcepawn. Instead, Sourcepawn alters arrays that are passed to the function. So instead of your code, you would do:
PHP Code:
char Char_BufferText[32], Char_RequesterName[32];
GetClientName(clientChar_RequesterNamesizeof(Char_RequesterName)); 
You are passing the char array Char_RequesterName into GetClientName() which then gets modified, much like Char_BufferText when you use Format().
adma is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 03-25-2019 , 04:21   Re: [CSGO] how i can create vote menu only for ct or tr ??
Reply With Quote #5

Quote:
Originally Posted by adma View Post
This line is wrong:
PHP Code:
char Char_BufferText[32], Char_RequesterName[64] = GetClientName(client); 
"Strings" are just arrays of characters with a 0 as the last element. For example, "hello" is the same as {'h', 'e', 'l', 'l', 'o', 0}. Therefore, functions like GetClientName cannot actual return a "string", because you cannot return arrays in Sourcepawn. Instead, Sourcepawn alters arrays that are passed to the function. So instead of your code, you would do:
PHP Code:
char Char_BufferText[32], Char_RequesterName[32];
GetClientName(clientChar_RequesterNamesizeof(Char_RequesterName)); 
You are passing the char array Char_RequesterName into GetClientName() which then gets modified, much like Char_BufferText when you use Format().
thank you, nice help :X

other lines is true??
Dr.Mohammad is offline
Reply



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 23:22.


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