AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   give hat by rank (https://forums.alliedmods.net/showthread.php?t=196186)

Caldeum 09-16-2012 13:58

give hat by rank
 
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 );



Zephyrus 09-16-2012 14:07

Re: give hat by rank
 
im not sure but i think this is for amxmodx..

rak 09-16-2012 15:30

Re: give hat by rank
 
Quote:

Originally Posted by Zephyrus (Post 1800769)
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]

Caldeum 09-16-2012 23:51

Re: give hat by rank
 
ohh sorry wrong forum. Players gets choke with this code. Or choke goes by models?


All times are GMT -4. The time now is 08:22.

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