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

get_players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-17-2022 , 23:06   get_players
Reply With Quote #1

hello!, I wanted to know how to use this function to obtain the alive players and that they are from the opposing team

PHP Code:
native get_players(players[MAX_PLAYERS], &num, const flags[] = "", const team[] = ""); 
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-17-2022 , 23:35   Re: get_players
Reply With Quote #2

Found a few threads in the Scripting Help forum (this one) with a quick search for "get_players team". Here is one that should help. This one talks about the difference between the new and old versions of the function.

Interestingly, I found that the official documentation actually shows an example for getting all players on a team that are also alive (for both versions here and here).
__________________

Last edited by fysiks; 10-17-2022 at 23:37.
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-18-2022 , 00:15   Re: get_players
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Found a few threads in the Scripting Help forum (this one) with a quick search for "get_players team". Here is one that should help. This one talks about the difference between the new and old versions of the function.

Interestingly, I found that the official documentation actually shows an example for getting all players on a team that are also alive (for both versions here and here).

mm i know this already, but I was hoping to know, how to find the players of the team opposite yours, which team to put in the native, thinking about what will change


Like:

PHP Code:
static Team[16];
get_opposite_teamidTeam15 );

new 
players[g_maxplayers];
static 
num;

get_players(players,num,"be"Team); 
but the question is to make the "get_opposite_team" function

edit: here is the function...

PHP Code:
stock get_opposite_teamClientOpposite[] )
{
       static 
Name[1]; 

       
get_user_teamClientTeam);

       switch(
Team[0])
       {
           case 
'C'// CT
           

                  
Opposite Terrorist
           
}
           case 
'T'// Terrorist
           
{
                  
Opposite CT
           
}
           case 
'A'// i dont know in this one, if the game is in all vs all?
           
{
                  
Opposite All
           
}
       }      


Last edited by MrPickles; 10-18-2022 at 01:04.
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-18-2022 , 01:04   Re: get_players
Reply With Quote #4

Use get_user_team() to determine which team the player is on and then you'll know the other team (there are mod-specific versions of get_user_team for Counter-Strike and Day of Defeat IIRC that might be better for clarity if you're playing one of those). Then, you'll know the opposite team.

Psuedocode:
Code:
if team == TeamA then
    TeamB
else
    TeamA
or, just replace "Team" in the get_players() function with the ternary operation:

Code:
get_user_team(id) == TeamA ? "TeamB" : "TeamA"
no need for an extra function unless you're trying to do something fancy with it.
__________________
fysiks is offline
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-18-2022 , 01:14   Re: get_players
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Use get_user_team() to determine which team the player is on and then you'll know the other team (there are mod-specific versions of get_user_team for Counter-Strike and Day of Defeat IIRC that might be better for clarity if you're playing one of those). Then, you'll know the opposite team.

Psuedocode:
Code:
if team == TeamA then
    TeamB
else
    TeamA
or, just replace "Team" in the get_players() function with the ternary operation:

Code:
get_user_team(id) == TeamA ? "TeamB" : "TeamA"
no need for an extra function unless you're trying to do something fancy with it.
Code:
get_user_team(id) == TeamA ? "TeamB" : "TeamA"
in the code ( in get_players ) how goes? is for counter strike
MrPickles is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-18-2022 , 01:24   Re: get_players
Reply With Quote #6

Based on one of the threads that I found, the strings you use are "TERRORIST" or "CT". I don't normally play Counter-Strike but I believe that the values returned from get_user_team() are either 1 or 2 for the aforementioned team names, respectively.

However, if it's specifically for Counter-Strike, you should probably use cs_get_user_team() and then you can use the CsTeams enum value to check with. It would end up like this:

Code:
cs_get_user_team(id) == CS_TEAM_T ? "CT" : "TERRORIST"
As I said before, this would just replace the "Team" variable in get_players().
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-22-2022 , 00:34   Re: get_players
Reply With Quote #7

Don't look to much at this one, i don't think it's recommended doing it this way, but if it works, it works in my opinion (if it doesn't have significant negative effects on the server).

Two things that might be helpful for you.

Get enemy players.

Spoiler



Get Alive Team Players.


Spoiler


All these things are untested, but should do their job, except for the first one, that might just be a no-go by the amxmodx communicty.

If you need more info on what i did, feel free to ask, but i feel like it's pretty common sense.
__________________

Last edited by Napoleon_be; 10-22-2022 at 01:22.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-22-2022 , 01:49   Re: get_players
Reply With Quote #8

Quote:
Originally Posted by Napoleon_be View Post
Don't look to much at this one, i don't think it's recommended doing it this way, but if it works, it works in my opinion (if it doesn't have significant negative effects on the server).

Two things that might be helpful for you.

Get enemy players.

Spoiler



Get Alive Team Players.


Spoiler


All these things are untested, but should do their job, except for the first one, that might just be a no-go by the amxmodx communicty.

If you need more info on what i did, feel free to ask, but i feel like it's pretty common sense.
Neither of these make any sense. Simply use get_players() with team argument determined by the check that I posted. It's actually quite simple, no loops necessary.
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-23-2022 , 06:56   Re: get_players
Reply With Quote #9

Really depends on what the player wants,. Could be done in different ways .Your vision might be wrong about it might. Although i know what you're referring to.
__________________

Last edited by Napoleon_be; 10-23-2022 at 06:58.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 10-23-2022 , 16:48   Re: get_players
Reply With Quote #10

Quote:
Originally Posted by Napoleon_be View Post
Don't look to much at this one, i don't think it's recommended doing it this way, but if it works, it works in my opinion (if it doesn't have significant negative effects on the server).

Two things that might be helpful for you.

Get enemy players.

Spoiler



Get Alive Team Players.


Spoiler


All these things are untested, but should do their job, except for the first one, that might just be a no-go by the amxmodx communicty.

If you need more info on what i did, feel free to ask, but i feel like it's pretty common sense.

Spoiler



Get Alive Team Players.


getting my team in a loop 0_0, its really unnecesary..


===>

PHP Code:
get_enemy_players(id)
{
    new 
iPlayers[33], iNumiEnemiesMyTeam;
    
get_players(iPlayersiNum"a" );

       
MyTeam get_user_team(id);

    for(new 
iiNumiNum)
    {
        if(
MyTeam != get_user_team(iPlayers[i])
            
iEnemies++
    }
    return 
iEnemies;


Last edited by MrPickles; 10-23-2022 at 16:48.
MrPickles 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 20:38.


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