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

How can i return the whole team money value ?


Post New Thread Reply   
 
Thread Tools Display Modes
SpannerSpammer
Member
Join Date: Mar 2006
Old 01-18-2017 , 02:24   Re: How can i return the whole team money value ?
Reply With Quote #11

Quote:
Originally Posted by OciXCrom
It's not a correct way to do it.
Quote:
Originally Posted by EFFx
You should use get_players()
LOL, I'm curious as to why you both think his looping function won't work.
__________________
[NeoTF|DEV]SpannerSpammer-[AoE]-
NeoTF Development Team.
http://steamcommunity.com/groups/neotf
SpannerSpammer is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-18-2017 , 05:01   Re: How can i return the whole team money value ?
Reply With Quote #12

It works, but oxicorm says is not the correct way to do it.
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 05:40   Re: How can i return the whole team money value ?
Reply With Quote #13

Quote:
Originally Posted by SpannerSpammer View Post
LOL, I'm curious as to why you both think his looping function won't work.
That's what I'm thinking too.
__________________
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-18-2017 , 08:49   Re: How can i return the whole team money value ?
Reply With Quote #14

Nobody said it won't work. You tell me why would you loop all 32 players when you cal loop the exact number of connected ones.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 09:36   Re: How can i return the whole team money value ?
Reply With Quote #15

So get_players doesn't use a 32 player loop? Compare my method and yours using get_players now.
PHP Code:
static cell AMX_NATIVE_CALL get_players(AMX *amxcell *params/* 4 param */
{
    
int iNum 0;
    
int ilen;
    
charsptemp get_amxstring(amxparams[3], 0ilen);
    
int flags UTIL_ReadFlags(sptemp);

    
cell *aPlayers get_amxaddr(amxparams[1]);
    
cell *iMax get_amxaddr(amxparams[2]);

    
int team 0;

    if (
flags 48)
    {
        
sptemp get_amxstring(amxparams[4], 0ilen);

        if (
flags 16)
        {
            if (
flags 64)
                
team g_teamsIds.findTeamId(sptemp);
            else
                
team g_teamsIds.findTeamIdCase(sptemp);
        }
    }

    for (
int i 1<= gpGlobals->maxClients; ++i)
    {
        
CPlayerpPlayer GET_PLAYER_POINTER_I(i);
        if (
pPlayer->ingame || ((flags 256) && pPlayer->initialized))
        {
            if (
pPlayer->IsAlive() ? (flags 2) : (flags 1))
                continue;
            if (
pPlayer->IsBot() ? (flags 4) : (flags 8))
                continue;
            if ((
flags 16) && (pPlayer->teamId != team))
                continue;
            if ((
flags 128) && (pPlayer->pEdict->v.flags FL_PROXY))
                continue;
            if (
flags 32)
            {
                if (
flags 64)
                {
                    if (
stristr(pPlayer->name.chars(), sptemp) == NULL)
                        continue;
                }
                else if (
strstr(pPlayer->name.chars(), sptemp) == NULL)
                    continue;
            }
            
aPlayers[iNum++] = i;
        }
    }

    *
iMax iNum;
    
    return 
1;

__________________

Last edited by edon1337; 01-18-2017 at 09:37.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-18-2017 , 10:19   Re: How can i return the whole team money value ?
Reply With Quote #16

You forget that get_players does the loop in a module, it's faster. It also return only valid players. When you loop from 1 to maxplayers you loop all possible player indexes.

You can just search, this was discussed a million times.
__________________

Last edited by HamletEagle; 01-18-2017 at 10:20.
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 01-18-2017 , 11:13   Re: How can i return the whole team money value ?
Reply With Quote #17

Added validity check. Also people are exaggerating the module speed, it's not like it is 300x faster.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-18-2017 , 11:29   Re: How can i return the whole team money value ?
Reply With Quote #18

The matter is to keep good practices. I'm really not going to debate again why it's better to use get_players in most of cases.
__________________

Last edited by HamletEagle; 01-18-2017 at 11:29.
HamletEagle 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 18:10.


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