Raised This Month: $12 Target: $400
 3% 

Automatically changes the server password


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joez252
Member
Join Date: Apr 2019
Old 07-13-2020 , 12:15   Automatically changes the server password
Reply With Quote #1

Hello,

I need plugin that automatically changes the server password after a server restart or a match end and i need to always choose the password that is written in the .txt file.

txt. file should look like this:

x4f7d
gh5fd
lbfs89
fptf6m
ldpze1

and I need it to change gradually from top to bottom.
joez252 is offline
Rowdy4E
Junior Member
Join Date: Nov 2018
Location: Czech Republic
Old 07-14-2020 , 21:52   Re: Automatically changes the server password
Reply With Quote #2

- Customize your passwords in this path: configs/ServerPasswords.cfg

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_NAME "Password Changer"
#define PLUGIN_AUTHOR "Rowdy4E."
#define PLUGIN_URL "https://steamcommunity.com/profiles/76561198307962930"
#define PLUGIN_DESC "Password changer. One or multiple passwords."
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>

#pragma newdecls required

char cConfigFile[255];
ArrayList passwords;

public 
Plugin myinfo 
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
description PLUGIN_DESC,
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
};


public 
void OnMapStart() {
    
LoadConfig();
    
setNextPassword();
}

void setNextPassword() {
    if (
passwords.Length == 0)
        return;
    
    
char cPassword[128];
    
GetConVarString(FindConVar("sv_password"), cPasswordsizeof(cPassword));
    
    
int index FindStringInArray(passwordscPassword);
    if (
index != -&& (passwords.Length-1) > index) {
        
index++;
    } else {
        
index 0;
    }
            
    
passwords.GetString(indexcPasswordsizeof(cPassword));
    
SetConVarString(FindConVar("sv_password"), cPassword);
    
    for (
int m 03m++) {
        
PrintToServer("***[%s] Current sv_password: %s"PLUGIN_NAMEcPassword);
    }
}

void LoadConfig() {
    
passwords CreateArray(128);
    
    
BuildPath(Path_SMcConfigFilesizeof(cConfigFile), "configs/ServerPasswords.cfg");
    
Handle file;
    
    if (!
FileExists(cConfigFile)) {
        
file OpenFile(cConfigFile"w");
        if (
file != null) {
            
WriteFileLine(file"password_1\npassword_2\npassword_3");
            
delete file;
        }
    }
    
    
file OpenFile(cConfigFile"r");
    if (
file != null) {
        
char buffer[255];
        while (
ReadFileLine(filebuffersizeof(buffer))) {
            if (
strlen(buffer) > && buffer[strlen(buffer) - 1] == '\n')
                  
buffer[strlen(buffer) - 1] = '\0';
            
            
TrimString(buffer);
                
            if (
strlen(buffer) == 0)
                continue;
                
            
PushArrayString(passwordsbuffer);
        }
        
        
delete file;
    }

Attached Files
File Type: smx passwordchanger.smx (5.0 KB, 21 views)
File Type: sp Get Plugin or Get Source (passwordchanger.sp - 87 views - 1.9 KB)
__________________

Last edited by Rowdy4E; 07-15-2020 at 01:17.
Rowdy4E is offline
joez252
Member
Join Date: Apr 2019
Old 07-15-2020 , 05:27   Re: Automatically changes the server password
Reply With Quote #3

Thanks, i will try it.
joez252 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 16:18.


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