AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get the player with the most frags being made (https://forums.alliedmods.net/showthread.php?t=272366)

Al3 09-28-2015 14:18

Get the player with the most frags being made
 
PHP Code:

get_leaders (&team1, &team2)
{
    new 
team1Frags 0team1ID 0;
    new 
team2Frags 0team2ID 0;
    
    for(new 
1<= 32i++)
    {
        new 
iFrags=        get_user_frags        (i);
        new 
CsTeams:iTeam=    cs_get_user_team    (i)
        
        if(
iFrags team1Frags && iTeam == CS_TEAM_T)
        {
            
team1Frags iFrags;
            
team1ID i;
            continue;
        }
        if(
iFrags team2Frags && iTeam == CS_TEAM_CT)
        {
            
team2Frags iFrags;
            
team2ID i;
        }
    }
    
team1 team1ID;
    
team2 team2ID;


is that the only way I can get the index of the client with the highest score ?

redivcram 09-28-2015 14:48

Re: Get the player with the most frags being made
 
Why do you ask? If it works, why do you want another way?

Al3 09-28-2015 14:52

Re: Get the player with the most frags being made
 
Because that it works doesn't mean it is good in:
- quality
- readability
- performance
- value
- works independently (in all the cases)

And when you are coding a mod, I think you must especially emphasize on these things.
And in my case, suspiciously that's the right way to go..
Though I have trouble figuring out another way.

redivcram 09-28-2015 15:01

Re: Get the player with the most frags being made
 
As I see it, this code is pretty damn well written... not talking about the spaces, syntaxes that satisfy me. The math looks good

Al3 09-28-2015 15:06

Re: Get the player with the most frags being made
 
Thanks (not sure if you are being serious or not). I just know that loops are slow, especially with fillings where the HLPL doesn't optimize with say branch prediction.
Also I am kinda new to amxmodx programming and I don't really trust myself yet.
Moreover, a lot of things I see are removed from "C". Not only syntactically but also in semantic manner.

redivcram 09-28-2015 15:22

Re: Get the player with the most frags being made
 
No no, I'm serious...

Well, amxmodx programming is just like every other programming, you just need to get to know modules and includes with their natives, Yes... and modified too, which makes it easier

Al3 09-28-2015 15:34

Re: Get the player with the most frags being made
 
Yes. Redundant features from the "C" are removed there.
I still miss pointers though. And structs on second place.

wickedd 09-28-2015 17:01

Re: Get the player with the most frags being made
 
@Al3
I will give you some friendly advice, search before posting. Because most likely the question has been asked before.

Al3 09-28-2015 17:04

Re: Get the player with the most frags being made
 
This trivial advice.

I searched. I could still search forever I guess..

Bugsy 09-28-2015 22:25

Re: Get the player with the most frags being made
 
Do you only need to know who the single highest fragger is, his number of frags, and which team they are on? Are there any other details to your request? I don't want to code something and then you tell me it doesn't do what you want.


All times are GMT -4. The time now is 22:15.

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