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

[ZP] Addon: AmmoPacks Leader


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
Kiske
Veteran Member
Join Date: May 2009
Old 01-02-2010 , 01:30   [ZP] Addon: AmmoPacks Leader
Reply With Quote #1

[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


Attached Files
File Type: sma Get Plugin or Get Source (zp_aps_leader.sma - 4151 views - 3.6 KB)
File Type: txt aps_leader.txt (734 Bytes, 2425 views)
__________________


Last edited by Kiske; 01-03-2010 at 00:30. Reason: Update Version to 1.4
Kiske is offline
Send a message via Skype™ to Kiske
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 01-02-2010 , 01:53   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #2

ML fixed, you know what I am talking

simple plugin, but useful
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
KadiR
Unnecessary Member
Join Date: Aug 2008
Location: Zürich / Switzerland
Old 01-02-2010 , 03:45   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #3

Nice plugin!

and leader is with one ''d'', so you're right!
KadiR is offline
Russiaboy
BANNED
Join Date: May 2009
Location: ZombiePlague is my Home
Old 01-02-2010 , 07:33   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #4

maybe you make one plugin who gain the most Ammo packs in current map?
Russiaboy is offline
Send a message via MSN to Russiaboy Send a message via Skype™ to Russiaboy
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-02-2010 , 11:08   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #5

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.
01101101 is offline
Kiske
Veteran Member
Join Date: May 2009
Old 01-02-2010 , 13:36   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #6

Quote:
Originally Posted by KadiR View Post
Nice plugin!

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


Quote:
Originally Posted by Russiaboy View Post
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 View Post
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.

__________________


Last edited by Kiske; 01-02-2010 at 13:39.
Kiske is offline
Send a message via Skype™ to Kiske
Ciio
Veteran Member
Join Date: Oct 2009
Location: Arica, Chile
Old 01-02-2010 , 13:48   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #7

Nice idea..
__________________
Ciio is offline
Send a message via MSN to Ciio
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-02-2010 , 15:07   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #8

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; }
__________________
xPaw is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-02-2010 , 15:21   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #9

Quote:
Originally Posted by xPaw View Post
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

01101101 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-02-2010 , 15:42   Re: [ZP] Addon: AmmoPacks Leader
Reply With Quote #10

You calling native 2 times, you dont check if user connected, also you forget { }
__________________
xPaw 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 01:33.


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