CoSmiN 31 Posted March 2, 2019 Descarcare: Mega || Girlshare || Zippyshare [sursa=RestrictNames.sp]#include <sourcemod> #include <sdktools> new String: RestrictedNamesFile[ PLATFORM_MAX_PATH ] new Handle: RestrictedNames = INVALID_HANDLE Handle: HandleMethod Handle: BackupName Handle: KickReason Handle: MinNameLen public Plugin:myinfo = { name = "Restricted Names: Basic", author = "tre3fla", description = "Filtreaza numele jucatorilor", version = "1.0", url = "http://extreamcs.com/forum" } public OnPluginStart( ) { HandleMethod = CreateConVar( "sm_restricted_names_action", "3", "0=dezactivat, 1=kick, 2=schimba numele, 3=sterge partea interzisa din nume" ) BackupName = CreateConVar( "sm_default_name", "CSGO Player", "Numele in care sa fie redenumiti jucatorii cu nume interzise" ) KickReason = CreateConVar( "sm_kick_reason", "Your name is not allowed", "Mesajul care sa ii apara daca primeste kick pentur ca are nume interzis" ) MinNameLen = CreateConVar( "sm_min_name_lenght", "3", "Minim cate caractere sa aiba numele pentru a putea fi folosit" ) HookUserMessage( GetUserMessageId( "SayText2" ), SayText2, true ) HookEvent( "player_changename", OnNameChange ) } public void OnMapStart( ) { LoadRestrictedNames( ) } public OnClientPutInServer( client ) { CheckClientName( client ) } public Action:OnNameChange( Handle:event, const String:name[ ], bool:dontBroadcast ) { new UserID = GetEventInt( event, "userid" ) new client = GetClientOfUserId( UserID ) if( IsClientInGame( client ) && !IsFakeClient( client ) ) { decl String:NewName[ MAX_NAME_LENGTH ] decl String:OldName[ MAX_NAME_LENGTH ] GetEventString( event, "oldname", OldName, sizeof( OldName ) ) GetEventString( event, "newname", NewName, sizeof( NewName ) ) decl String: LargeBuffer[ 1024 ] for( new i = 0; i < GetArraySize( RestrictedNames ); i++ ) { GetArrayString( RestrictedNames, i, LargeBuffer, sizeof( LargeBuffer ) ) if( StrContains( NewName, LargeBuffer ) != -1 ) { SetClientName( client, OldName ) PrintToChat( client, "* Name change attempt failed!\x02 Your choosen name is not allowed!" ) return Plugin_Changed } if( GetConVarInt( MinNameLen ) > 0 && strlen( NewName ) < GetConVarInt( MinNameLen ) ) { SetClientName( client, OldName ) PrintToChat( client, "*\x02 Name change attempt failed!" ) PrintToChat( client, "* Your\x04 name\x01 must have at least\x05 %d\x01 characters!", GetConVarInt( MinNameLen ) ) return Plugin_Stop } } } return Plugin_Continue } public CheckClientName( client ) { if( IsClientInGame( client ) && client > 0 && client < MaxClients ) { decl String: LargeBuffer[ 1024 ] decl String: Name[ 32 ] GetClientName( client, Name, sizeof( Name ) ) for( new i = 0; i < GetArraySize( RestrictedNames ); i++ ) { GetArrayString( RestrictedNames, i, LargeBuffer, sizeof( LargeBuffer ) ) if( StrContains( Name, LargeBuffer ) != -1 ) { switch( GetConVarInt( HandleMethod ) ) { case 1: { decl String: ReasonBuffer[ 128 ] GetConVarString( KickReason, ReasonBuffer, sizeof( ReasonBuffer ) ) KickClient( client, "%s", ReasonBuffer ) } case 2: { decl String: NameBuffer[ 32 ] GetConVarString( BackupName, NameBuffer, sizeof( NameBuffer ) ) SetClientName( client, NameBuffer ) } case 3: { ReplaceString( Name, sizeof( Name ), LargeBuffer, "" ) SetClientName( client, Name ) if( TrimString( Name ) && StrEqual( Name, "" ) ) { decl String: NameBuffer[ 32 ] GetConVarString( BackupName, NameBuffer, sizeof( NameBuffer ) ) SetClientName( client, NameBuffer ) } } } } if( GetConVarInt( MinNameLen ) > 0 && strlen( Name ) < GetConVarInt( MinNameLen ) ) { decl String: NameBuffer[ 32 ] GetConVarString( BackupName, NameBuffer, sizeof( NameBuffer ) ) SetClientName( client, NameBuffer ) } } } } public Action:SayText2( UserMsg:msg_id, Handle:bf, players[ ], playersNum, bool:reliable, bool:init ) { new String:buffer[ 25 ] if( GetUserMessageType( ) == UM_Protobuf ) { PbReadString( bf, "msg_name", buffer, sizeof( buffer ) ) if( StrEqual( buffer, "#Cstrike_Name_Change" ) ) { return Plugin_Handled } } return Plugin_Continue } public LoadRestrictedNames( ) { RestrictedNames = CreateArray( 1024 ) BuildPath( Path_SM, RestrictedNamesFile, sizeof( RestrictedNamesFile ), "configs/RestrictedNames.txt" ) new Handle: RestrictedNamesText = OpenFile( RestrictedNamesFile, "r" ) new String: ResultsBuffer[ 1024 ] while( !IsEndOfFile( RestrictedNamesText ) && ReadFileLine( RestrictedNamesText, ResultsBuffer, sizeof( ResultsBuffer ) ) ) { ReplaceString( ResultsBuffer, sizeof( ResultsBuffer ), "\n", "", false ) PushArrayString( RestrictedNames, ResultsBuffer ) } }[/sursa] Nume: Name Restrict Autor: tre3fla Versiune: free Descriere: Blocheaza, modifica, interzice sau schimba complet numele jucatorilor daca au un nume pe care nu doriti sa-l aiba pe serverul vostru. De asemenea nu permite jucatorilor sa aiba numele prea mic ( setabil prin cvar ). Blocheaza si mesajul ala in chat gen "X changed his name to Y" pentru a se evita spam-ul. Convar-uri (se adauga in server.cfg): sm_restricted_names_action 0 = Pluginul nu filtreaza numele de pe server, jucatorii isi pot pune ce nume vor 1 = Da kick jucatorilor cu nume interzise 2 = Schimba numele jucatorilor intr-un nume setat de voi 3 = Sterge partea nedorita din nume (de exemplu daca voi nu vreti sa aibe numele Marius iar pe jucator il cheama Ion Marius, va sterge Marius din nume si pe jucator il va chema doar Ion sm_default_name "Nume Dorit" - default "CSGO Player", numele default in care sa fie redenumiti jucatorii cu nume interzise sm_kick_reason "Motiv-ul kick-ului" - default "Your Name is not allowed", ce sa ii arate jucatorului daca primeste kick datorita numelui interzis sm_min_name_lenght - Cate caractere trebuie sa aiba minim un nume, default 3 caractere Instalare: 1. Fisierul RestrictedNames.sp se adauga in addons/sourcemod/scripting 2. Fisierul RestrictedNames.smx se adauga in addons/sourcemod/plugins 3. Fisierul RestrictedNames.txt se adauga in addons/sourcemod/configs Daca nu aveti fisierul RestrictedNames.txt in folderul configs pluginul NU VA FUNCTIONA! Este foarte important ca numele sa fie scris exact asa si sa aibe extensia .txt! Share this post Link to post Share on other sites More sharing options...