Hi there!
I have a script which checks a players name and then compares them with the userid table in our database. If the 2 values match then the client can connect to our server.
This works, on client connect. But when they're in-game they're still able to change their playername into something else without a action on this.
I've tried this with OnClientSettingsChanged(client) but it isn't responding.
PHP Code:
public OnPluginStart()
{
StartSQL()
}
public OnClientSettingsChanged(client)
{
decl String:name[32];
GetClientName(client, name, sizeof(name));
CheckUserAgain(client, name)
}
public GotDatabase(Handle:owner, Handle:hndl, const String:error[], any:data)
{
if (hndl == INVALID_HANDLE)
{
LogError("Database error: %s", error);
}
else
{
hDatabase = hndl;
}
}
StartSQL()
{
SQL_TConnect(GotDatabase);
}
/////////////////////////////////////////
//FUNCTION: Check if UserID is all good//
////////////////////////////////////////
CheckUserAgain(userid, const String:name[])
{
decl String:query[255];
Format(query, sizeof(query), "SELECT userid FROM cpay_users WHERE userid = '%s'", name);
SQL_TQuery(hDatabase, T_CheckUserID, query, userid)
}
public T_CheckUserAgain(Handle:owner, Handle:hndl, const String:error[], any:client)
{
/* Make sure the client didn't disconnect while the thread was running */
if (!IsClientConnected(client))
{
return;
}
if (hndl == INVALID_HANDLE)
{
LogError("Query failed! %s", error);
PrintToChat(client, "There went something wrong...");
}
else if (!SQL_GetRowCount(hndl))
{
KickClient(client, "Illegal playername");
}
}
The main goal is to get the player kicked within a few seconds if they don't change their name back into what's registered in our database.
Does anyone has any suggestions on how to use either OnClientSettingsChanged() or to get the players name automatically changed / be kicked in a few seconds?
Thnx in advance!!