Raised This Month: $ Target: $400
 0% 

give hat by rank


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Caldeum
Senior Member
Join Date: Jul 2010
Location: United Kingdom
Old 09-16-2012 , 13:58   give hat by rank
Reply With Quote #1

Hello, can anyone optimize this code ? cause server get laggy after 10~ rounds.

PHP Code:
new g_topEnt33 ];

new 
MODEL_1[ ] = "models/1.mdl";
new 
MODEL_2[ ] = "models/2.mdl";

public 
CheckPlayerRankid )
{
    new 
stats], bodyhits];
    new 
iRank;
     
iRank get_user_statsidstatsbodyhits );
    
    if ( 
iRank && <= iRank <= 10 )
        
GiveHatidMODEL_1 );
    else if ( 
iRank && 11 <= iRank <= 20 )
        
GiveHatidMODEL_2 );
    
    return 
PLUGIN_CONTINUE;
}

public 
GiveHatid, const s_Model[ ] )
{
    if ( 
is_user_aliveid ) )
    {
        new 
iEnt g_topEntid ];
        if ( !
pev_validiEnt ) )
        {
            
iEnt engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
            
set_peviEntpev_movetypeMOVETYPE_FOLLOW );
            
set_peviEntpev_aimentid );
            
engfuncEngFunc_SetModeliEnts_Model );
        }
        else
            
engfuncEngFunc_RemoveEntityiEnt );
    }
}

public 
client_infochangedid )
{
    new 
player_name32 ], newName32 ];
    
get_user_nameidplayer_name31 );
    
get_user_infoid"name"newName31 );
    
    if ( !
equalinewNameplayer_name ) )
        
set_task1.0"CheckPlayerRank"id );

__________________
Of all the things I lost, I miss my brain the most.
Caldeum is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 09-16-2012 , 14:07   Re: give hat by rank
Reply With Quote #2

im not sure but i think this is for amxmodx..
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 09-16-2012 , 15:30   Re: give hat by rank
Reply With Quote #3

Quote:
Originally Posted by Zephyrus View Post
im not sure but i think this is for amxmodx..
is for amxmodx

edit: this code don't lag your server

edit2: you never save the ent in g_topEnt[id]
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 09-16-2012 at 16:06.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
Caldeum
Senior Member
Join Date: Jul 2010
Location: United Kingdom
Old 09-16-2012 , 23:51   Re: give hat by rank
Reply With Quote #4

ohh sorry wrong forum. Players gets choke with this code. Or choke goes by models?
__________________
Of all the things I lost, I miss my brain the most.
Caldeum is offline
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 08:22.


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