This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

sixteenK


Post New Thread Reply   
 
Thread Tools Display Modes
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-03-2012 , 13:20   Re: sixteenK
Reply With Quote #21

Quote:
Originally Posted by Arkshine View Post
Kind of useless, poorly coded, and it's clear you are a beginner and you don't know really what you're doing.

Unapproved.
how is it poorly coded?
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-06-2012 , 14:11   Re: sixteenK
Reply With Quote #22

For show activity, you should use amxmisc.inc stocks :

PHP Code:
/**
 * Standard method to show activity to one single client. 
 * This is useful for messages that get pieced together by many language keys.
 * This depends on the amx_show_activity cvar.  See documentation for more details.
 *
 * @param idtarget    The user id of the person to display to.  0 is invalid.
 * @param idadmin    The user id of the person doing the action.
 * @param name        The name of the person doing the action.
 * @param fmt        The format string to display.  Do not put the "ADMIN:" prefix in this.
 */
stock show_activity_id(idtargetidadmin, const name[], const fmt[], any:...) 
And when performed on a whole team or on all players :

PHP Code:
/**
 * Standard method to show activity to clients connected to the server.
 * This depends on the amx_show_activity cvar.  See documentation for more details.
 *
 * @param id        The user id of the person doing the action.
 * @param name        The name of the person doing the action.
 * @param fmt        The format string to display.  Do not put the "ADMIN:" prefix in this.
 */
stock show_activityid, const name[], const fmt[], any:... ) 
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-06-2012 , 14:25   Re: sixteenK
Reply With Quote #23

  • You check one or two letters with a native. A bit overkill, simply check one letter. Like :
    Replace that :
    Spoiler

    by
    Spoiler
  • Don't re-index arrays. In the loop below, cache the value of players[i]. (optimization)
  • Use the existing define for the flags in cmd_target. For a better readability.
  • Your TELLALL code : it should be moved inside your first check ( sz_name[0] == '@' ). Here, you could use a switch and checking the first letter too, and using formatex.
  • In set_money function : the use of pcvar is a must. You could use the show_activity stock, since it's ready for that and will reflect all the possible value for the cvar.

Btw, why are you give only 16k money ? There are plugins which removes the limit.
__________________

Last edited by Arkshine; 06-06-2012 at 14:26.
Arkshine is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-07-2012 , 13:13   Re: sixteenK
Reply With Quote #24

Quote:
Originally Posted by ConnorMcLeod View Post
For show activity, you should use amxmisc.inc stocks :

PHP Code:
/**
 * Standard method to show activity to one single client. 
 * This is useful for messages that get pieced together by many language keys.
 * This depends on the amx_show_activity cvar.  See documentation for more details.
 *
 * @param idtarget    The user id of the person to display to.  0 is invalid.
 * @param idadmin    The user id of the person doing the action.
 * @param name        The name of the person doing the action.
 * @param fmt        The format string to display.  Do not put the "ADMIN:" prefix in this.
 */
stock show_activity_id(idtargetidadmin, const name[], const fmt[], any:...) 
And when performed on a whole team or on all players :

PHP Code:
/**
 * Standard method to show activity to clients connected to the server.
 * This depends on the amx_show_activity cvar.  See documentation for more details.
 *
 * @param id        The user id of the person doing the action.
 * @param name        The name of the person doing the action.
 * @param fmt        The format string to display.  Do not put the "ADMIN:" prefix in this.
 */
stock show_activityid, const name[], const fmt[], any:... ) 
much thanks! i was unaware of those stocks.

Quote:
Originally Posted by Arkshine View Post
  • You check one or two letters with a native. A bit overkill, simply check one letter. Like :
    Replace that :
    Spoiler

    by
    Spoiler
  • Don't re-index arrays. In the loop below, cache the value of players[i]. (optimization)
  • Use the existing define for the flags in cmd_target. For a better readability.
  • Your TELLALL code : it should be moved inside your first check ( sz_name[0] == '@' ). Here, you could use a switch and checking the first letter too, and using formatex.
  • In set_money function : the use of pcvar is a must. You could use the show_activity stock, since it's ready for that and will reflect all the possible value for the cvar.

Btw, why are you give only 16k money ? There are plugins which removes the limit.
Oh! i didn't know switch statements could use chars. That'll def make that easier. As for that code, i just pulled it from the documentation; didn't put much thought into it.
What do you mean about using the existing flags for cmd_target()?
That's a pretty good idea....completely skip that check by using the original one.
As for the default 16000....that's just the engine's default max; and the plugin's name. Woudln't you think this plugin would be obsolete in servers that mod the max money anyway? Though i think i might look into getting the server's max money, rather than a hard-coded value.

EDIT: looking at the optimization wiki about re-indexing arrays....i wouldn't have though that would be more efficient. Things like this is why i love programming. the most random things are the most efficient.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-07-2012 at 14:08.
Liverwiz is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-07-2012 , 13:57   Re: sixteenK
Reply With Quote #25

About cmd_target, you should always look at the available .inc, and you would see the constants :

Spoiler


About 16000, well, since the limit can be removed, there is no really reason to keep giving 16000 instead of letting the admin choosing what they want. What I say is : be customizable. Just saying, the plugin is still kind of redundant, but just because it's unapproved, doesn't mean you can't improve it and maybe turn it out in a new thing.
__________________
Arkshine is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-07-2012 , 14:15   Re: sixteenK
Reply With Quote #26

Quote:
Originally Posted by Arkshine View Post
About cmd_target, you should always look at the available .inc, and you would see the constants :

Spoiler


About 16000, well, since the limit can be removed, there is no really reason to keep giving 16000 instead of letting the admin choosing what they want. What I say is : be customizable. Just saying, the plugin is still kind of redundant, but just because it's unapproved, doesn't mean you can't improve it and maybe turn it out in a new thing.
i think the wiki should have those constants, it'd make me cry less.
And i agree that customization is always the way to go. But some things you just don't want people to change. And i don't really care much about it getting "approved" i'm just learning, growing, and having fun.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-07-2012 , 14:37   Re: sixteenK
Reply With Quote #27

Quote:
Originally Posted by Liverwiz View Post
i think the wiki should have those constants
They've been added now.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-07-2012 , 15:21   Re: sixteenK
Reply With Quote #28

Quote:
Originally Posted by Exolent[jNr] View Post
They've been added now.
Sweet! i love it when things get done. Much thanks!



EDIT: UPDATED! version 2.3
Optimized, added MONEY define to customize how much money is given (default 16000)
Let me know what yoda thinks.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-07-2012 at 21:51.
Liverwiz 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 14:32.


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