AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   [ZP] Addon: AmmoPacks Leader (https://forums.alliedmods.net/showthread.php?t=114116)

Kiske 01-02-2010 01:30

[ZP] Addon: AmmoPacks Leader
 
2 Attachment(s)
[ZP] Addon: AmmoPacks Leader
By Kiske


~ [ { Description } ] ~
This plugin is simple.
It will detect who is the player with more ammo packs and show it with a print.


~ [ { Cvars } ] ~
zp_leader_msj (default: 2)
/*
zp_leader_msj 0. Plugin Disable.
zp_leader_msj 1. Message at RoundStart.
zp_leader_msj 2. Message when you say or say_team "/leader".
zp_leader_msj 3. Both.
*/

~ [ { ML } ] ~
This Post: http://forums.alliedmods.net/showthread.php?t=113163

~ [ { Pictures } ] ~
[IMG]http://img694.**************/img694/403/testingd.png[/IMG]
~ [ { Credits } ] ~
Starsailor - For the Stock: "GetMaxNumIndex()"
AfteR - For translating the Post.
Asd' - For the Test and for one Fix.
gladius - For the Test and for repair ML.
~ [ { Downloads } ] ~
v1.0 - 19 Views
v1.1 - 9 Views



gladius 01-02-2010 01:53

Re: [ZP] Addon: AmmoPacks Leader
 
ML fixed, you know what I am talking :)

simple plugin, but useful

KadiR 01-02-2010 03:45

Re: [ZP] Addon: AmmoPacks Leader
 
Nice plugin! :)

and leader is with one ''d'', so you're right! :mrgreen:

Russiaboy 01-02-2010 07:33

Re: [ZP] Addon: AmmoPacks Leader
 
maybe you make one plugin who gain the most Ammo packs in current map?

01101101 01-02-2010 11:08

Re: [ZP] Addon: AmmoPacks Leader
 
Some things are shit-coded.

Several examples:
PHP Code:

    if ( get_pcvar_num(leader_msj) == )
        return; 

--->
PHP Code:

    if (!get_pcvar_num(leader_msj))
        return; 

PHP Code:

public RoundStart()
{
    if ( 
get_pcvar_num(leader_msj) != )
        
set_task(2.2"Leader"// I use this set_task to the message appears then of "welcome_msg"


Could still be 0. Your way to use cvars just sucks. First of all you should block nothing on map start, otherwise, players then won't be able to set it to another num.

!= 2
Still can be 0

Just use two conditions, won't be buggy and performance won't be affected.

Same error here

PHP Code:

public CheckLeader(id)
{
    if ( 
get_pcvar_num(leader_msj) != )
    { 

Then, not sure about this, should check amxmodx source code but:

PHP Code:

static iPlayers[32], iNum get_players(iPlayersiNum

Not sure about if get_players resets values, this could bug like hell.

So, anything related with cvars must be rewritten.

Kiske 01-02-2010 13:36

Re: [ZP] Addon: AmmoPacks Leader
 
Quote:

Originally Posted by KadiR (Post 1039786)
Nice plugin! :)

and leader is with one ''d'', so you're right! :mrgreen:

Thanks!


Quote:

Originally Posted by Russiaboy (Post 1039926)
maybe you make one plugin who gain the most Ammo packs in current map?

Not work.
Most of the players before the end of the map, spend their AmmoPacks, then the leader would have very little: S


Sory for my English
.


Quote:

Originally Posted by 01101101 (Post 1040091)
Some things are shit-coded.

Several examples:
PHP Code:

    if ( get_pcvar_num(leader_msj) == )
        return; 

--->
PHP Code:

    if (!get_pcvar_num(leader_msj))
        return; 

PHP Code:

public RoundStart()
{
    if ( 
get_pcvar_num(leader_msj) != )
        
set_task(2.2"Leader"// I use this set_task to the message appears then of "welcome_msg"


Could still be 0. Your way to use cvars just sucks. First of all you should block nothing on map start, otherwise, players then won't be able to set it to another num.

!= 2
Still can be 0

Just use two conditions, won't be buggy and performance won't be affected.

Same error here

PHP Code:

public CheckLeader(id)
{
    if ( 
get_pcvar_num(leader_msj) != )
    { 

Then, not sure about this, should check amxmodx source code but:

PHP Code:

static iPlayers[32], iNum get_players(iPlayersiNum

Not sure about if get_players resets values, this could bug like hell.

So, anything related with cvars must be rewritten.

Fix everything and some things you told me delete them because it might cause bugs.

Sory for my English.


Ciio 01-02-2010 13:48

Re: [ZP] Addon: AmmoPacks Leader
 
Nice idea..

xPaw 01-02-2010 15:07

Re: [ZP] Addon: AmmoPacks Leader
 
Here's better example to get leader

Code:
public ShowLeader( ) {     new iAmmoPacks;     new iLeader = GetLeader( iAmmoPacks );         // [ .. ] } GetLeader( &iAmmoPacks ) {     new iPlayers[ 32 ], iNum, id, iLeader, iPacks;     get_players( iPlayers, iNum, "ch" );         for( i = 0; i < iNum; i++ ) {         id     = iPlayers[ i ];         iPacks = zp_get_user_ammo_packs( id );                 if( iPacks > iAmmoPacks ) {             iAmmoPacks = iPacks;             iLeader    = id;         }     }         return iLeader; }

01101101 01-02-2010 15:21

Re: [ZP] Addon: AmmoPacks Leader
 
Quote:

Originally Posted by xPaw (Post 1040378)
Here's better example to get leader

Code:
public ShowLeader( ) {     new iAmmoPacks;     new iLeader = GetLeader( iAmmoPacks );         // [ .. ] } GetLeader( &iAmmoPacks ) {     new iPlayers[ 32 ], iNum, id, iLeader, iPacks;     get_players( iPlayers, iNum, "ch" );         for( i = 0; i < iNum; i++ ) {         id     = iPlayers[ i ];         iPacks = zp_get_user_ammo_packs( id );                 if( iPacks > iAmmoPacks ) {             iAmmoPacks = iPacks;             iLeader    = id;         }     }         return iLeader; }

Why not just

PHP Code:

stock getleader()
{
    new 
maxleader
    
for(new ig_maxplayersi++)
    {
        if(
zp_get_user_ammo_packs(i) > max)
        
leader i
        max 
zp_get_user_ammo_packs(i)
    }
    return 
leader



xPaw 01-02-2010 15:42

Re: [ZP] Addon: AmmoPacks Leader
 
You calling native 2 times, you dont check if user connected, also you forget { }


All times are GMT -4. The time now is 14:46.

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