Raised This Month: $32 Target: $400
 8% 

Round Start Money


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 09-30-2011 , 21:13   Round Start Money
Reply With Quote #1

This Plugin show a teammate's money in hud (Using a set_hudmessage not direct_hudmessage) during a freezetime.

* If a no Freezetime, no money to show


PHP Code:
    /*Only Call event if Round is really End
    And Prevent to show money if
    server is restarted (sv_restart) or Game Commencing!*/
    
register_logevent("RoundEnd",2,"1=Round_End"); 


I made a two versions :

- With a Freezetime and Without Freezetime, (See Attachments):

- 0.0.5 Fixed Hudmessage to CTs and TRs.
- 0.0.4 Added Pcvar 'pFreezetime', changed loops 'See: Optimizing Plugins (AMX Mod X Scripting) - AlliedModders Wiki'
- 0.0.3 (Fixed a set_task time + TRs & CTs Loop)
- 0.0.2 (Fixed Hudmessage)
- 0.0.1 (Initial Relase)
Attached Files
File Type: sma Get Plugin or Get Source (RoundMoney_Freezetime.sma - 818 views - 1.7 KB)
File Type: sma Get Plugin or Get Source (RoundMoney_No_Freezetime.sma - 811 views - 1.5 KB)
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 10-04-2011 at 00:42.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nur56
Member
Join Date: Apr 2007
Old 10-02-2011 , 06:39   Re: Round Start Money
Reply With Quote #2

PHP Code:
public RoundEnd() set_task(5.1,"RoundStart"); 
really bad practice

PHP Code:
new Float:Freezetime get_cvar_float("mp_freezetime"); 
Use pcvars.. they are much faster and much more efficient

PHP Code:
    for(new i;iNum;i++)
    {
        new 
szName[32];
        
get_user_name(iPlayers[i],szName,charsmax(szName));

        new 
Money cs_get_user_money(iPlayers[i]);

        switch(
cs_get_user_team(iPlayers[i]))
        {
            case 
CS_TEAM_TposTR += formatex(HudTextTR[posTR],511-posTR,"%s ($ %d)^n",szName,Money);

            case 
CS_TEAM_CTposCT += formatex(HudTextCT[posCT],511-posCT,"%s ($ %d)^n",szName,Money);
        }
    } 

Hogs CPU, cache iPlayers[i]

same goes for the other loop





Also.. why set_task(5.1) on round end when you can simply hook round start ???


Nice idea but needs some optimization
Nur56 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-03-2011 , 16:47   Re: Round Start Money
Reply With Quote #3

Quote:
/*Only Call event if Round is really End
And Prevent to show money if
server is restarted (sv_restart) or Game Commencing!*/
register_logevent("RoundEnd",2,"1=Round_End");
Tested...

If used a sv_restart 1, the hudmessage dont appear.
Only if a round really is ended.

Example: If mp_startmoney is 16000.
Obviously you do not need a sample of the money.

Use witch round_start if you want..
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 10-03-2011 at 16:49. Reason: :P
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nur56
Member
Join Date: Apr 2007
Old 10-03-2011 , 16:58   Re: Round Start Money
Reply With Quote #4

Make a global var, hook GameCommencing and Server restart, set var to 1, hook round start, check var, if it's 1 then don't print HUD, if it's 0 then print normally, hook round end, set var to 0.

much much better than hard-coding round start, if a plugin forces mp_freezetime to a different value then the admin can't use this plugin.
Nur56 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-03-2011 , 17:10   Re: Round Start Money
Reply With Quote #5

OK, i will be fix.

EDIT:

A Simple set_task() func. VS hook a 2 ~ 3 Events??

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 10-03-2011 at 17:19. Reason: :)
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nur56
Member
Join Date: Apr 2007
Old 10-03-2011 , 17:36   Re: Round Start Money
Reply With Quote #6

Man you don't understand... hardcoding is always wrong... if any plugin forces mp_freezetime too, roundstart will be called late/early.

you have set_task(5.1).... if a plugin OTHER THAN YOURS has mp_freezetime 3, the admin will have to go and change that to maybe set_task 3.9 or something... do you understand now?

there is nothing to "test"

so just hook the events and it will be much better
Nur56 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-03-2011 , 18:02   Re: Round Start Money
Reply With Quote #7

Fixed

0.0.5 - Fixed Hudmessage to CTs and TRs.
0.0.4 - Added Pcvar (pFreezetime), changed loops (See: Optimizing Plugins (AMX Mod X Scripting) - AlliedModders Wiki)

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 10-04-2011 at 00:41. Reason: 0.0.5 - Fixed Hudmessage to CTs and TRs.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Nur56
Member
Join Date: Apr 2007
Old 10-04-2011 , 07:39   Re: Round Start Money
Reply With Quote #8

Man never post your first plugin...

You STILL didn't understand. sorry but I don't think this will be approved until you fix what I told you because an approver will tell you the same thing
Nur56 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 10-04-2011 , 13:39   Re: Round Start Money
Reply With Quote #9

First plugin?

Kkk...
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-04-2011 , 14:26   Re: Round Start Money
Reply With Quote #10

Redundant, unapproved.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:29.


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