This code does not seem to work:
Code: Select all
@PreEvent('player_changename')
def on_changename(event):
return EventAction.BLOCK
Am I missing something?
Code: Select all
@PreEvent('player_changename')
def on_changename(event):
return EventAction.BLOCK
L'In20Cible
Syntax: Select all
@PreHook(get_virtual_function(engine_server, 'ClientCommand'))
def _pre_client_command(args):
"""Block name changes started by the server.
Pre-hook on IVEngineServer::ClientCommand to block the name changes.
"""
if args[2] == 'name "%s"':
return 0
Syntax: Select all
ConVar cl_name ( "name","unnamed", FCVAR_ARCHIVE | FCVAR_USERINFO | FCVAR_PRINTABLEONLY | FCVAR_SERVER_CAN_EXECUTE, "Current user name", CL_NameCvarChanged );
Zeus wrote:I'm creating an plugin to integrate my discord with my TF2 servers; and want to force names to be sync'd. I need to be able to prevent players from changing their name.
This code does not seem to work:Code: Select all
@PreEvent('player_changename')
def on_changename(event):
return EventAction.BLOCK
Am I missing something?
Code: Select all
@PreEvent('player_changename')
def OnChangeName(args):
client = Player.from_userid(args.get_int('userid'))
client.set_name(args.get_string('oldname'))
return EventAction.BLOCK
Sam wrote:I understand correctly?
Syntax: Select all
m_ConVars->SetString( "name", m_Name );
m_Server->UserInfoChanged( m_nClientSlot );
InvisibleSoldiers wrote:Sam wrote:I understand correctly?
No, this is possible, although I'm not sure, will only block a chat message, and he needs more global preventing.Syntax: Select all
else if ( Q_strcmp( "player_changename", eventname ) == 0 )
{
if ( !hudChat )
return;
const char *pszOldName = event->GetString("oldname");
if ( PlayerNameNotSetYet(pszOldName) )
return;
wchar_t wszOldName[MAX_PLAYER_NAME_LENGTH];
g_pVGuiLocalize->ConvertANSIToUnicode( pszOldName, wszOldName, sizeof(wszOldName) );
wchar_t wszNewName[MAX_PLAYER_NAME_LENGTH];
g_pVGuiLocalize->ConvertANSIToUnicode( event->GetString( "newname" ), wszNewName, sizeof(wszNewName) );
wchar_t wszLocalized[100];
g_pVGuiLocalize->ConstructString( wszLocalized, sizeof( wszLocalized ), g_pVGuiLocalize->Find( "#game_player_changed_name" ), 2, wszOldName, wszNewName );
char szLocalized[100];
g_pVGuiLocalize->ConvertUnicodeToANSI( wszLocalized, szLocalized, sizeof(szLocalized) );
hudChat->Printf( CHAT_FILTER_NAMECHANGE, "%s", szLocalized );
InvisibleSoldiers wrote:Sam wrote:I understand correctly?
void CBaseClient::SetName:Syntax: Select all
m_ConVars->SetString( "name", m_Name );
m_Server->UserInfoChanged( m_nClientSlot );
Yes, you are right, didn't notice the simple function
Sam wrote:
There is a leaked version of the Source Engine 2007, public Source SDK released by Valve and reverse engineered versions of the Source SDK.Sam wrote:"I have the disassemblers and source code on all computers with fast internet xD"
Ayuto wrote:There is a leaked version of the Source Engine 2007, public Source SDK released by Valve and reverse engineered versions of the Source SDK.Sam wrote:"I have the disassemblers and source code on all computers with fast internet xD"
Syntax: Select all
@PreEvent('player_changename')
def pre_player_changename(gevent):
player = Player.from_userid(gevent['userid'])
# Update scoreboard.
player.set_name(gevent['oldname'])
gevent['newname'] = gevent['oldname']
return EventAction.BLOCK
Return to “Plugin Development Support”
Users browsing this forum: No registered users and 90 guests