Raised This Month: $ Target: $400
 0% 

Help me optimize this !


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
newcomer
Member
Join Date: Aug 2011
Old 06-24-2012 , 02:49   Help me optimize this !
Reply With Quote #1

I try write this plugin. All working like what I want. But it make server lag and high ping. I think problem at FM_PlayerPreThink but I don't know how to fix it. Anyone here can help me optimize or teach me better way.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Testing"
#define VERSION "1.0"
#define AUTHOR "Newcomer"

enum SpecStatus {
    
    
SPEC_ALLOWED 0,
    
SPEC_FORBIDDEN
};

new 
SpecStatus:g_iStatus[33] = { SPEC_ALLOWED, ... };
new 
g_iHudSync;
new 
ScreenFade

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);    
    
register_forward(FM_PlayerPreThink"fwdPlayerPreThink"0);
    
register_clcmd("say on""on");
    
register_clcmd("say ""off");
    
g_iHudSync CreateHudSyncObj();    
    
ScreenFade get_user_msgid("ScreenFade")

}

public 
client_disconnect(id)
{
remove_task(id)
}

public 
on(id)
{
    if (
access(id,ADMIN_IMMUNITY))
    {
        
g_iStatus[id] = SPEC_FORBIDDEN;
        
client_print(idprint_chat"Turned ON!");
        
set_task1.0"wel_msg"id""0"b" );
    }
    else
    {
        
client_print(idprint_chat"You're not allow this");        
    }
}

public 
off(id)
{
        
g_iStatus[id] = SPEC_ALLOWED;    
        
client_print(idprint_chat"Turn OFF!");    
        
remove_task(id)
}

public 
fwdPlayerPreThink(client)
{
    if(
is_user_alive(client))
        return 
FMRES_IGNORED;
    
    static 
iTarget;
    
iTarget pev(clientpev_iuser2);
    
    if(!
is_user_alive(iTarget))
        return 
FMRES_IGNORED;    

    if(
g_iStatus[iTarget] != SPEC_ALLOWED && !access(client,ADMIN_IMMUNITY))
    {
    new 
name[32]
    
get_user_name(iTarget,name,31
    
set_hudmessage(255255255, -1.00.306.04.00.10.1);
    
ShowSyncHudMsg(clientg_iHudSync"%s Turned ON",name);    
    
make_ScreenFade(client000x0004000255);             
    return 
FMRES_HANDLED;
    }
    return 
FMRES_IGNORED;
}

make_ScreenFade(clientdurationholdtimeflagsrgba)
{
    
message_begin(MSG_ONEScreenFade_client);
    
write_short(duration);
    
write_short(holdtime);
    
write_short(flags);
    
write_byte(r);
    
write_byte(g);
    
write_byte(b);
    
write_byte(a);
    
message_end();
}  
public 
wel_msg(id)
{    
    if (
is_user_alive(id))
    {
    
set_hudmessage2552552550.450.00200.021.00.10.2, -);
    
ShowSyncHudMsgidg_iHudSync"Turn ON");
    }

newcomer is offline
 


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 06:12.


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