AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Optimize Plugin (https://forums.alliedmods.net/showthread.php?t=309208)

PurposeLessx 07-17-2018 13:07

Optimize Plugin
 
Hey friends, I make a plugin. It has 3951 lines so I want to make it optimized for server.
In menus, what I should use?

Code:

static data[6], name[32], access, callback, key;
menu_item_getinfo(menu, item, access, data, charsmax(data), _, _, callback);
key = str_to_num(data);

// or

new data[6], name[32], access, callback;
menu_item_getinfo(menu, item, access, data, charsmax(data), _, _, callback);
new key = str_to_num(data);


klippy 07-17-2018 13:11

Re: Optimize Plugin
 
It doesn't matter.

PurposeLessx 07-17-2018 13:19

Re: Optimize Plugin
 
So what should I do for optimizing plugin?

Example commands;

PHP Code:

//#define MAX_CLIENTS                     32 
            
new TeamName:team;
            for(new 
Uid 1Uid <= MAX_CLIENTSUid++)
            {
                
team get_member(Uidm_iTeam);

                if(
team == TEAM_CT && is_user_alive(Uid))
                {
                    
set_entvar(Uidvar_takedamageDAMAGE_NO);
                    
set_entvar(Uidvar_health99999.0);
                    
unammocuk[Uid] = true;
                }
            }
            
clcmd_ctmenu(id);
            
rh_emit_sound2(00CHAN_AUTOsound_godmodeVOL_NORMATTN_NORMATTN_NORM0PITCH_NORM); 


OciXCrom 07-17-2018 13:28

Re: Optimize Plugin
 
For starters, using get_players() to loop all players.

PurposeLessx 07-17-2018 13:37

Re: Optimize Plugin
 
Quote:

Originally Posted by OciXCrom (Post 2604299)
For starters, using get_players() to loop all players.

The all servers which use my plugin is 32 players. Do I need check it?

OciXCrom 07-17-2018 13:42

Re: Optimize Plugin
 
Do they have all 32 players online 24/7? Probably not.
The only right way to loop all players is by using get_players().

PurposeLessx 07-17-2018 13:46

Re: Optimize Plugin
 
Quote:

Originally Posted by OciXCrom (Post 2604306)
Do they have all 32 players online 24/7? Probably not.
The only right way to loop all players is by using get_players().

Is get_players more optimized than for(new .... , also ?

maqi 07-17-2018 14:00

Re: Optimize Plugin
 
Quote:

Originally Posted by PurposeLessx (Post 2604308)
Is get_players more optimized than for(new .... , also ?

What kind of question is this ?

PurposeLessx 07-17-2018 14:18

Re: Optimize Plugin
 
My english is not good enough as you all. My bad.
I guess you understand my question, so there is no problem :D.

"Is using get_players more optimized than using for(new Uid = 1 ; Uid <= 32 ; Uid++)"

OciXCrom 07-17-2018 14:33

Re: Optimize Plugin
 
If it wasn't, would I be writing this in a thread that says "OPTIMIZE PLUGIN"?


All times are GMT -4. The time now is 17:16.

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