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

Simple Slots Reservation


Post New Thread Reply   
 
Thread Tools Display Modes
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-13-2014 , 16:02   Re: Simple Slots Reservation
Reply With Quote #21

Quote:
Originally Posted by Arkshine View Post
Some thoughts while I'm passing here:
  • Use formatex. Actually since you don't use arguments, I don't see why you're using vformat.
  • No reason to use static on admins.
  • This would be welcomed you add some comments in your plugin about what does the plugin, listing/explaining cvars.
Made even better
__________________
Jhob94 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-13-2014 , 16:10   Re: Simple Slots Reservation
Reply With Quote #22

Well, if I had one last complaint, is PLUGIN and VERSION are used three times, you should use new const here. Just better memory management.
__________________

Last edited by Arkshine; 10-13-2014 at 16:11.
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-13-2014 , 16:17   Re: Simple Slots Reservation
Reply With Quote #23

Quote:
Originally Posted by Arkshine View Post
Well, if I had one last complaint, is PLUGIN and VERSION are used three times, you should use new const here. Just better memory management.
I never really understood the difference between using define and const for this things. I know this isn't a scripting help forum, but can you explain me or pm why?
Once i used scripting help forum and i got solution but then someone asked why i did like that and not the other way and i didn't knew why. Since that day i like to know the whys. Some people got "spammed" with stupid scripting questions

Edit:
Updated! And i have a feeling that i am gonna get banned
__________________

Last edited by Jhob94; 10-13-2014 at 16:34.
Jhob94 is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 10-13-2014 , 16:46   Re: Simple Slots Reservation
Reply With Quote #24

It's simple, define is a preprocessor directive which is replaced during compilation. So if you #define SOME_STRING "some_string" and use it either in a function that is called frequently or on multiple places, the memory will be allocated (and free'd) each time the string is used, which is a waste of computing power (not that it really matters, though).

Where as with a constant, the memory is allocated only once when the constant is initialized and stays in memory until it is free'd. Using the constant will point to the memory rather than reallocate it, which can potentionally save memory operations at the cost of constant memory usage.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 10-13-2014 at 16:46.
Backstabnoob is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-13-2014 , 16:51   Re: Simple Slots Reservation
Reply With Quote #25

Code:
#define PLUGIN "Simple Slots Reservation" #define VERSION "0.0.6"

After compilation, same string is replaced everywhere.
Compiler allocates 3 times the same string:

Code:
public plugin_init() {     register_plugin("Simple Slots Reservation", "0.0.6", "Jhob94")     register_cvar("Simple Slots Reservation", "0.0.6", FCVAR_SPONLY|FCVAR_SERVER)     set_cvar_string("Simple Slots Reservation", "0.0.6") }


VS


Code:
new const PLUGIN[] = "Simple Slots Reservation"; new const VERSION[] = "0.0.6";

After compilation, string is allocated one time and this will use references
anywhere string is repeated.

Code:
public plugin_init() {     register_plugin(referenceString_1, referenceString_2, "Jhob94")     register_cvar(referenceString_1, referenceString_2, FCVAR_SPONLY|FCVAR_SERVER)     set_cvar_string(referenceString_1, referenceString_2) }


Basically, if you have a string which is referenced more than one time, this is good idea to use new const


EDIT: Shit, ninja'd! \o/

Though I'm not sure to agree to
Quote:
the memory will be allocated (and free'd) each time the string is used, which is a waste of computing power (not that it really matters, though).
Maybe I've misunderstood, but string is allocated one time and is referenced anyway by an address ; the point is just for a same string repeated x times, plugin will allocate x times with a x addresses.
__________________

Last edited by Arkshine; 10-13-2014 at 16:58.
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-13-2014 , 16:58   Re: Simple Slots Reservation
Reply With Quote #26

Roger that, thanks both

Updated
__________________
Jhob94 is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 10-13-2014 , 17:00   Re: Simple Slots Reservation
Reply With Quote #27

Quote:
Originally Posted by Arkshine
Maybe I've misunderstood, but string is allocated one time and is referenced anyway by an address ; the point is just for a same string repeated x times, plugin will allocate x times with a x addresses.
That's good information, thanks.
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-13-2014 , 17:01   Re: Simple Slots Reservation
Reply With Quote #28

While you are on it, here the french translation with accents:

Code:
[fr]
DROPPED_RES = Désolé, un admin vient de prendre sa place réservée, tu as été éjecté du serveur.
__________________
Arkshine is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-13-2014 , 17:05   Re: Simple Slots Reservation
Reply With Quote #29

Quote:
Originally Posted by Arkshine View Post
While you are on it, here the french translation with accents:

Code:
[fr]
DROPPED_RES = Désolé, un admin vient de prendre sa place réservée, tu as été éjecté du serveur.
This is ML from default amxx system. I don't think it's a good idea to change it here, people shouldn't be forced to replace it. I just uploaded for the case someone lost the file somehow.
__________________
Jhob94 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-13-2014 , 17:24   Re: Simple Slots Reservation
Reply With Quote #30

Ah. Then you should not attach it, because if file is changed upstream (which is going to be the case), people will think it's the right version and will replace it. There is no reason to attach it really. Don't bother with it.
__________________
Arkshine 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 04:41.


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