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

[REQ/CSGO] Player name changer basted on SteamID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bjerrecs
New Member
Join Date: Jan 2017
Old 01-21-2017 , 16:13   [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #1

Hello everyone,

I have now been looking for a long time for a plugin
which would make me have a data base whit a lot of SteamIDs
and a name that matches withthis ID.

I have found bits here and there, but nothing that has worked.

But why?

I tournament manager at eSport.dk and we are very mad that our csgo players have strange names,
that are not so nice (swear words, words with sexual sense) and we would like to change these players
to a name that they send to us, that we then have in a Database, so we can call it later.

can this be done?
Its just like how ESEA, CEVO and FaceIT is doing it

sorry if my english is a bit rusty ;)

Best Regards
Simon Bjerre
Admin @ eSport.dk
bjerrecs is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-21-2017 , 20:58   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #2

I'll be happy to help you out. What's your database structure like?

Last edited by headline; 01-21-2017 at 21:00.
headline is offline
bjerrecs
New Member
Join Date: Jan 2017
Old 01-22-2017 , 06:56   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #3

Hello Headline!

The database can be set up so it's easiest for you,
and to add players from registration a forum

Thanks for the quick reply
Can you add me on steam?
It is a lot easier

Steam Accound
bjerrecs is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-06-2017 , 10:50   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #4

Was this one ever resolved?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 02-06-2017 , 15:19   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #5

Quote:
Originally Posted by arne1288 View Post
Was this one ever resolved?
PHP Code:
/* [CS:GO] Name Enforcer for esportdk
 *
 * Copyright (C) 2016 Michael Flaherty // michaelwflaherty.com // [email protected]
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see http://www.gnu.org/licenses/.
 *
 * Thanks to ThatOneGuy for SQL snippets
 */

#include <sourcemod>
#include <sdktools>

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_VERSION "1.1"

Database myDatabase null;

char ga_sSteamID[MAXPLAYERS 1][32];
char ga_sForcedName[MAXPLAYERS 1][MAX_NAME_LENGTH];

bool ga_bLoaded[MAXPLAYERS 1] = {false, ...};
bool g_bLateLoad;

public 
APLRes AskPluginLoad2(Handle hMyselfbool bLatechar[] sErrorint err_max)
{
    
g_bLateLoad bLate;
    
    return 
APLRes_Success;
}

public 
Plugin myinfo =
{
    
name "[CS:GO] Name Enforcer",
    
author "Headline",
    
description "A simple MySQL name enforcer",
    
version PLUGIN_VERSION,
    
url "http://www.michaelwflaherty.com"
}

public 
void OnPluginStart()
{
    
HookEvent("player_changename"Event_NameChange);

    
ConnectDB();
}

/* Configs are good! We can load in */
public void OnAutoConfigsBuffered()
{
    
ConnectDB();
}

public 
void OnConfigsExecuted()
{
    
/* Database has not been set yet, so do it. */
    
if (myDatabase == null
    {
        
ConnectDB();
    }
    
    
/* If the plugin was loaded in late, we want to load in every client now. */
    
if (g_bLateLoad)
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsValidClient(i))
            {
                
GetClientAuthId(iAuthId_Steam2ga_sSteamID[i], sizeof(ga_sSteamID[]));
                
ReplaceString(ga_sSteamID[i], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");
                
                if (
StrContains(ga_sSteamID[i], "STEAM_"true) != -1// valid
                
{
                    
LoadClient(i);
                }
                else 
// invalid try again
                
{
                    
CreateTimer(10.0RefreshSteamIDGetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
                }
            }
        }
    }
}

public 
void OnClientConnected(int client)
{
    
ResetClientVars(client);
}

public 
void OnClientDisconnect(int client)
{
    
ResetClientVars(client);
}

public 
void OnClientPostAdminCheck(int client)
{
    
LoadClient(client);
}

public 
Action Event_NameChange(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
IsValidClient(client))
    {
        
char clientName[MAX_NAME_LENGTH];
        
event.GetString("newname"clientNamesizeof(clientName));

        if (!
StrEqual(clientNamega_sForcedName[client]))
        {
            
PrintToChat(client"[SM] Your name must be \"%s\""ga_sForcedName[client]);
            
CreateTimer(0.1Timer_ChangeNameGetClientUserId(client));
        }
    }
}

public 
Action Timer_ChangeName(Handle timerint userid)
{
    
OnClientLoaded(GetClientOfUserId(userid));
}

void OnClientLoaded(int client)
{
    
char clientName[MAX_NAME_LENGTH];
    
GetClientName(clientclientNamesizeof(clientName));
    
    if (!
StrEqual(clientNamega_sForcedName[client]))
    {
        
SetClientName(clientga_sForcedName[client]);
    }
}

/******************************************************************
******************************** SQL *****************************
*******************************************************************/

void ConnectDB()
{
    if (
myDatabase == null)
    {
        
Database.Connect(SQLCallback_Connect"hl_esportdk");
    }
}


/* SQL Callback On First Connection */
public void SQLCallback_Connect(Database db, const char[] errorany data)
{
    if(
db == null)
    {
        
SetFailState("Error connecting to database. %s"error);
    }
    else
    {
        
myDatabase db;
    }
}


// DESCRIPTION: Called when a client loads in.
void LoadClient(int client)
{
    if (!
IsValidClient(client))
    {
        return;
    }

    
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
ReplaceString(ga_sSteamID[client], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");
    
    if (
StrContains(ga_sSteamID[client], "STEAM_"true) == -1//if ID is invalid
    
{
        
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    
    if (
myDatabase == null//connect not loaded - retry to give it time
    
{
        
CreateTimer(1.0RepeatCheckRankGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    else 
// db is good, grab data
    
{
        
char sQuery[300];
        
Format(sQuerysizeof(sQuery), "SELECT `ingamenavn` FROM bruger WHERE steamid=\"%s\""ga_sSteamID[client]);
        
myDatabase.Query(SQLCallback_CheckSQLsQueryGetClientUserId(client));
    }
}

public 
void SQLCallback_CheckSQL(Database dbDBResultSet results, const char[] errorint userid)
{
    if (
db == null)
    {
        
ConnectDB();
    }
    
    
int client GetClientOfUserId(userid); // we passed the connecting clients id
    
if (!IsValidClient(client)) // If they left or something happened (always check validity at every step)
    
{
        return;
    }
    else 
// They're valid
    
{
        if (
results.RowCount != 0// client exists in db
        
{
            
results.FetchRow();
            
            
results.FetchString(0ga_sForcedName[client], sizeof(ga_sForcedName[]));
            
            
ga_bLoaded[client] = true;
            
OnClientLoaded(client);
        }
    }
}

/******************************************************************
**************************** SQL TIMERS ***************************
*******************************************************************/

public Action RepeatCheckRank(Handle hTimerint iUserID)
{
    
LoadClient(GetClientOfUserId(iUserID));
}

public 
Action RefreshSteamID(Handle hTimerint iUserID)
{
    
int client GetClientOfUserId(iUserID);
    
    if (!
IsValidClient(client))
    {
        return;
    }

    
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
ReplaceString(ga_sSteamID[client], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");

    if (
StrContains(ga_sSteamID[client], "STEAM_"true) == -1//still invalid - retry again
    
{
        
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    else 
// valid
    
{
        
LoadClient(client);
    }
}



/******************************************************************
*********************** HELPER FUNCTIONS **************************
*******************************************************************/


void ResetClientVars(int client)
{
    
ga_bLoaded[client] = false;
    
ga_sSteamID[client] = "";
    
ga_sForcedName[client] = "";
}

bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

headline is offline
Kikerechu
New Member
Join Date: Apr 2017
Old 04-17-2017 , 06:46   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #6

Quote:
Originally Posted by Headline View Post
PHP Code:
/* [CS:GO] Name Enforcer for esportdk
 *
 * Copyright (C) 2016 Michael Flaherty // michaelwflaherty.com // [email protected]
 * 
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with 
 * this program. If not, see http://www.gnu.org/licenses/.
 *
 * Thanks to ThatOneGuy for SQL snippets
 */

#include <sourcemod>
#include <sdktools>

#pragma newdecls required
#pragma semicolon 1

#define PLUGIN_VERSION "1.1"

Database myDatabase null;

char ga_sSteamID[MAXPLAYERS 1][32];
char ga_sForcedName[MAXPLAYERS 1][MAX_NAME_LENGTH];

bool ga_bLoaded[MAXPLAYERS 1] = {false, ...};
bool g_bLateLoad;

public 
APLRes AskPluginLoad2(Handle hMyselfbool bLatechar[] sErrorint err_max)
{
    
g_bLateLoad bLate;
    
    return 
APLRes_Success;
}

public 
Plugin myinfo =
{
    
name "[CS:GO] Name Enforcer",
    
author "Headline",
    
description "A simple MySQL name enforcer",
    
version PLUGIN_VERSION,
    
url "http://www.michaelwflaherty.com"
}

public 
void OnPluginStart()
{
    
HookEvent("player_changename"Event_NameChange);

    
ConnectDB();
}

/* Configs are good! We can load in */
public void OnAutoConfigsBuffered()
{
    
ConnectDB();
}

public 
void OnConfigsExecuted()
{
    
/* Database has not been set yet, so do it. */
    
if (myDatabase == null
    {
        
ConnectDB();
    }
    
    
/* If the plugin was loaded in late, we want to load in every client now. */
    
if (g_bLateLoad)
    {
        for (
int i 1<= MaxClientsi++)
        {
            if (
IsValidClient(i))
            {
                
GetClientAuthId(iAuthId_Steam2ga_sSteamID[i], sizeof(ga_sSteamID[]));
                
ReplaceString(ga_sSteamID[i], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");
                
                if (
StrContains(ga_sSteamID[i], "STEAM_"true) != -1// valid
                
{
                    
LoadClient(i);
                }
                else 
// invalid try again
                
{
                    
CreateTimer(10.0RefreshSteamIDGetClientUserId(i), TIMER_FLAG_NO_MAPCHANGE);
                }
            }
        }
    }
}

public 
void OnClientConnected(int client)
{
    
ResetClientVars(client);
}

public 
void OnClientDisconnect(int client)
{
    
ResetClientVars(client);
}

public 
void OnClientPostAdminCheck(int client)
{
    
LoadClient(client);
}

public 
Action Event_NameChange(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
IsValidClient(client))
    {
        
char clientName[MAX_NAME_LENGTH];
        
event.GetString("newname"clientNamesizeof(clientName));

        if (!
StrEqual(clientNamega_sForcedName[client]))
        {
            
PrintToChat(client"[SM] Your name must be \"%s\""ga_sForcedName[client]);
            
CreateTimer(0.1Timer_ChangeNameGetClientUserId(client));
        }
    }
}

public 
Action Timer_ChangeName(Handle timerint userid)
{
    
OnClientLoaded(GetClientOfUserId(userid));
}

void OnClientLoaded(int client)
{
    
char clientName[MAX_NAME_LENGTH];
    
GetClientName(clientclientNamesizeof(clientName));
    
    if (!
StrEqual(clientNamega_sForcedName[client]))
    {
        
SetClientName(clientga_sForcedName[client]);
    }
}

/******************************************************************
******************************** SQL *****************************
*******************************************************************/

void ConnectDB()
{
    if (
myDatabase == null)
    {
        
Database.Connect(SQLCallback_Connect"hl_esportdk");
    }
}


/* SQL Callback On First Connection */
public void SQLCallback_Connect(Database db, const char[] errorany data)
{
    if(
db == null)
    {
        
SetFailState("Error connecting to database. %s"error);
    }
    else
    {
        
myDatabase db;
    }
}


// DESCRIPTION: Called when a client loads in.
void LoadClient(int client)
{
    if (!
IsValidClient(client))
    {
        return;
    }

    
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
ReplaceString(ga_sSteamID[client], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");
    
    if (
StrContains(ga_sSteamID[client], "STEAM_"true) == -1//if ID is invalid
    
{
        
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    
    if (
myDatabase == null//connect not loaded - retry to give it time
    
{
        
CreateTimer(1.0RepeatCheckRankGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    else 
// db is good, grab data
    
{
        
char sQuery[300];
        
Format(sQuerysizeof(sQuery), "SELECT `ingamenavn` FROM bruger WHERE steamid=\"%s\""ga_sSteamID[client]);
        
myDatabase.Query(SQLCallback_CheckSQLsQueryGetClientUserId(client));
    }
}

public 
void SQLCallback_CheckSQL(Database dbDBResultSet results, const char[] errorint userid)
{
    if (
db == null)
    {
        
ConnectDB();
    }
    
    
int client GetClientOfUserId(userid); // we passed the connecting clients id
    
if (!IsValidClient(client)) // If they left or something happened (always check validity at every step)
    
{
        return;
    }
    else 
// They're valid
    
{
        if (
results.RowCount != 0// client exists in db
        
{
            
results.FetchRow();
            
            
results.FetchString(0ga_sForcedName[client], sizeof(ga_sForcedName[]));
            
            
ga_bLoaded[client] = true;
            
OnClientLoaded(client);
        }
    }
}

/******************************************************************
**************************** SQL TIMERS ***************************
*******************************************************************/

public Action RepeatCheckRank(Handle hTimerint iUserID)
{
    
LoadClient(GetClientOfUserId(iUserID));
}

public 
Action RefreshSteamID(Handle hTimerint iUserID)
{
    
int client GetClientOfUserId(iUserID);
    
    if (!
IsValidClient(client))
    {
        return;
    }

    
GetClientAuthId(clientAuthId_Steam2ga_sSteamID[client], sizeof(ga_sSteamID[]));
    
ReplaceString(ga_sSteamID[client], sizeof(ga_sSteamID[]), "STEAM_1""STEAM_0");

    if (
StrContains(ga_sSteamID[client], "STEAM_"true) == -1//still invalid - retry again
    
{
        
CreateTimer(10.0RefreshSteamIDGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    }
    else 
// valid
    
{
        
LoadClient(client);
    }
}



/******************************************************************
*********************** HELPER FUNCTIONS **************************
*******************************************************************/


void ResetClientVars(int client)
{
    
ga_bLoaded[client] = false;
    
ga_sSteamID[client] = "";
    
ga_sForcedName[client] = "";
}

bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

Hey Headline, I'm a web developer and I want to implement nickname change with our database. I have a few questions because I'm really noob at scripting.

-Where is the line to enter MySQL credentials?

-How should I activate this on my server(s)? Should I create a file, where?

Thanks for your time, and sorry for the newbish questions.

Have a great day.
Kikerechu is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 04-17-2017 , 15:04   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #7

Quote:
Originally Posted by Kikerechu View Post
Hey Headline, I'm a web developer and I want to implement nickname change with our database. I have a few questions because I'm really noob at scripting.

-Where is the line to enter MySQL credentials?

-How should I activate this on my server(s)? Should I create a file, where?

Thanks for your time, and sorry for the newbish questions.

Have a great day.
If you wish to use this plugin without editing it, the table name must be called "bruger", the column with the ingame name should be "ingamenavn", and the column with the steamids should be called "steamid".

Besides this, sql information is input into databases.cfg in sourcemod/configs/ under "hl_esportdk"

https://wiki.alliedmods.net/SQL_Admi...#Configuration
headline is offline
EduArT
Junior Member
Join Date: Oct 2011
Old 04-11-2018 , 15:01   Re: [REQ/CSGO] Player name changer basted on SteamID
Reply With Quote #8

For a simple server use, it would be great to have a /addons/sourcemod/configs/admin-names.ini in wich you add the player name and steamid like: "EduArT" "STEAM_1:0_12221" . Me for one I would really use this to track my admins activity.
__________________


EduArT is offline
Reply



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 23:36.


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