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

Optimize Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-17-2018 , 13:07   Optimize Plugin
Reply With Quote #1

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);
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-17-2018 , 13:11   Re: Optimize Plugin
Reply With Quote #2

It doesn't matter.
__________________
klippy is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-17-2018 , 13:19   Re: Optimize Plugin
Reply With Quote #3

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); 
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }


Last edited by PurposeLessx; 07-17-2018 at 13:19.
PurposeLessx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-17-2018 , 13:28   Re: Optimize Plugin
Reply With Quote #4

For starters, using get_players() to loop all players.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 07-17-2018, 13:34
Celena Luna
This message has been deleted by Celena Luna. Reason: nvm
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-17-2018 , 13:37   Re: Optimize Plugin
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
For starters, using get_players() to loop all players.
The all servers which use my plugin is 32 players. Do I need check it?
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-17-2018 , 13:42   Re: Optimize Plugin
Reply With Quote #6

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

Last edited by OciXCrom; 07-17-2018 at 13:43.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-17-2018 , 13:46   Re: Optimize Plugin
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
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 ?
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }

PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-17-2018 , 14:00   Re: Optimize Plugin
Reply With Quote #8

Quote:
Originally Posted by PurposeLessx View Post
Is get_players more optimized than for(new .... , also ?
What kind of question is this ?
__________________
stuff
maqi is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 07-17-2018 , 14:18   Re: Optimize Plugin
Reply With Quote #9

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

"Is using get_players more optimized than using for(new Uid = 1 ; Uid <= 32 ; Uid++)"
__________________
A plugin that is needed for every server.
PHP Code:
public client_connect(id)
{
    if(
get_user_iq(id) < 80)
    {
        
server_cmd("kick #%d 'You have kicked from the server because your IQ is not high enough'"get_user_userid(id));
    }


Last edited by PurposeLessx; 07-17-2018 at 14:18.
PurposeLessx is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-17-2018 , 14:33   Re: Optimize Plugin
Reply With Quote #10

If it wasn't, would I be writing this in a thread that says "OPTIMIZE PLUGIN"?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 19:47.


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