AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   name blocking, changing (https://forums.alliedmods.net/showthread.php?t=143507)

m0v3 11-20-2010 20:18

name blocking, changing
 
Hi,

I have this function , using which you can change player name to the one you want , also blocking name changing for players. It works also for dead people , what is pretty handy for me, but causes server lags , chokes , sometimes (not always ) even svc_bad's. Is there a better solution for the aim I want, or can my function be optimised in any ways? Thank You.

Working, but still laggy solution:
PHP Code:

public plugin_init() {
    
    
register_plugin("test","0.1","m0v3")
    
    
register_forward(FM_ClientUserInfoChanged"forward_client_userinfochanged"
}

public 
forward_client_userinfochanged(idbuffer) {

    if ( !
IsConnected[id] )
        return 
FMRES_IGNORED
        
    
static val[32];
    static 
name[33];
    static 
neimas[36];
   
formatex(neimascharsmax(neimas), "[%03i].%s"SKILLplayer_name[id])
    
get_user_name(idnamecharsmax(name))
    
    
engfunc(EngFunc_InfoKeyValuebuffer"name"valsizeof val 1);
    
    if ( 
equal(name neimas) && equal(val neimas) )
        return 
FMRES_IGNORED
        

    engfunc
(EngFunc_SetClientKeyValueidbuffer"name"neimas);
   
    
engclient_cmdid "name ^"%s^"" player_name[id] );

    return 
FMRES_SUPERCEDE



fysiks 11-20-2010 21:52

Re: name blocking, changing
 
If you are going to be putting stats in someones name then you should do it using engclient_cmd(id, "name", newname) and you can also, when they change their name just re-add the stats to it. (not really helping on your issue but that's my thoughts).

You can also change:

Code:

    if ( SKL < 100 )
            format( neimas , 35 , "[0%i].%s" , SKL , player_name[id] )
    else
            format( neimas , 35 , "[%i].%s" , SKL , player_name[id] )

to just:
Code:

formatex(neimas, charsmax(neimas), "[%03i].%s", SKL, player_name[id])

m0v3 11-21-2010 07:14

Re: name blocking, changing
 
Whats the difference between engclient_cmd ant client_cmd ?

Quote:

and you can also, when they change their name just re-add the stats to it
It could be , but in my situation , the name is fixed.

Code:

formatex(neimas, charsmax(neimas), "[%02i].%s", SKL, player_name[id])

%02i - what exactly does this do ?

Exolent[jNr] 11-21-2010 09:44

Re: name blocking, changing
 
Quote:

Originally Posted by m0v3 (Post 1353571)
%02i - what exactly does this do ?

Formats an integer.
2 = minimum length ("3" -> " 3". notice the space)
0 = replace spacers with zeros ("3" -> "03")

It actually should be "%03i" for 3 digits.

reinert 11-21-2010 09:53

Re: name blocking, changing
 
#manager @aitvaras ??? :3:3

m0v3 11-21-2010 16:25

Re: name blocking, changing
 
@Exolent[jNr]
Thank You, will use :)

@reinert
Taip ;)

To thread

Still lagg problem exists.


All times are GMT -4. The time now is 11:20.

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