Raised This Month: $ Target: $400
 0% 

[ Solved ] How to get num of terrorists ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-23-2008 , 11:32   [ Solved ] How to get num of terrorists ?
Reply With Quote #1

__________________

Last edited by xPaw; 08-24-2008 at 11:18.
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-23-2008 , 11:40   Re: How to get num of terrorists ?
Reply With Quote #2

It should work. How did you test to get this conslusion ?
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-23-2008 , 11:56   Re: How to get num of terrorists ?
Reply With Quote #3

with looping task in init, every 30 secs
__________________
xPaw is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 08-23-2008 , 19:51   Re: How to get num of terrorists ?
Reply With Quote #4

Don't use that method anyway, though it seems the most common sense way to do it.

Before I give you updated code, I have to question why the hell you'd be looping this. That's a bad idea and needless to boot. Do you want to know the current T count at any given moment?

This code will give you the T count:
Code:
new players[32], playerCnt, playerIdx, terroristCnt;
get_players(players, playerCnt);

for (playerIdx = 0; playerIdx < playerCnt; playerIdx++)
{
   if (get_user_team(players[playerIdx]) == 2)
   {
      terroristCnt++;
   }
}
You'll need to confirm if terrorists are team 1 or 2 as I can't recall at the moment.
__________________
Brad is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-23-2008 , 19:56   Re: How to get num of terrorists ?
Reply With Quote #5

Quote:
== 2)
1 = terro / 2 = ct ^^
__________________
Arkshine is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-23-2008 , 20:28   Re: How to get num of terrorists ?
Reply With Quote #6

Quote:
Originally Posted by Brad View Post
Don't use that method anyway, though it seems the most common sense way to do it.

Before I give you updated code, I have to question why the hell you'd be looping this. That's a bad idea and needless to boot. Do you want to know the current T count at any given moment?

This code will give you the T count:
Code:
new players[32], playerCnt, playerIdx, terroristCnt;
get_players(players, playerCnt);

for (playerIdx = 0; playerIdx < playerCnt; playerIdx++)
{
   if (get_user_team(players[playerIdx]) == 2)
   {
      terroristCnt++;
   }
}
You'll need to confirm if terrorists are team 1 or 2 as I can't recall at the moment.
You don't need to use both,get_players and a loop. Just use one of them.
PHP Code:
new iTRCount 0
new iMaxPlayers get_maxplayers()
for(new 
i=1;<= iMaxPlayers;i++)
{
    if(
is_user_connected(i) && get_user_team(i) == 1)
        
iTRCount++

danielkza is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 08-23-2008 , 21:23   Re: How to get num of terrorists ?
Reply With Quote #7

Have you done any tests to see which is better? I haven't, so was just wondering.
__________________
Brad is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-23-2008 , 22:00   Re: How to get num of terrorists ?
Reply With Quote #8

Quote:
Originally Posted by Brad View Post
Have you done any tests to see which is better? I haven't, so was just wondering.
This has been discussed a lot, and in the end the common sense is just use what seems better to you,or which needs less code. Obviously, get_players + a loop is not in any way better. It has the disadvantages of both methods. Also, the funcwiki says:
Quote:
Originally Posted by FuncWiki
Note: "e" flag can return incorrect results (for cstrike/czero at least).


"We don't really support get_players() with flags anymore. It was a bad idea and if it was our choice, it would have never been added to the original AMX Mod." - BAILOPAN
So, I would stick with the MaxPlayers' loop method.
danielkza is offline
Iwon
BANNED
Join Date: Jul 2008
Old 08-24-2008 , 06:29   Re: How to get num of terrorists ?
Reply With Quote #9

PHP Code:
new players[32], playerCntplayerIdxterroristCnt;
get_players(playersplayerCnt);

for (
playerIdx 0playerIdx playerCntplayerIdx++)
{
   if (
get_user_team(players[playerIdx]) == 2)
   {
      
terroristCnt++;
   }

That is better.
Iwon is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-24-2008 , 07:07   Re: How to get num of terrorists ?
Reply With Quote #10

No, I don't think. The less you use natives, the better it is.

I don't see the point to use get_players() without flags, if the purpose is just to loop through all players. So, the danielkza's way is more appropriate. ( considering that "e" flag can return incorrect results )
__________________

Last edited by Arkshine; 08-24-2008 at 07:11.
Arkshine 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 03:10.


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