Raised This Month: $ Target: $400
 0% 

Check player namechange


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-13-2008 , 16:40   Check player namechange
Reply With Quote #1

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(clientnamesizeof(name));
    
CheckUserAgain(clientname)
}
 
 
 
public 
GotDatabase(Handle:ownerHandle: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(querysizeof(query), "SELECT userid FROM cpay_users WHERE userid = '%s'"name);
    
SQL_TQuery(hDatabaseT_CheckUserIDqueryuserid)

 
 
public 
T_CheckUserAgain(Handle:ownerHandle: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!!

Last edited by Corrosive; 08-14-2008 at 08:22.
Corrosive is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-13-2008 , 18:27   Re: Check player namechange
Reply With Quote #2

Hook the player_changename event. http://wiki.alliedmods.net/Generic_Source_Events
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-13-2008 , 19:13   Re: Check player namechange
Reply With Quote #3

Could you give me an example maybe? I don't really know how to do this.

thnx.
Corrosive is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-13-2008 , 19:23   Re: Check player namechange
Reply With Quote #4

http://wiki.alliedmods.net/Events_%2...%29#Post_Hooks
bl4nk is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-13-2008 , 19:57   Re: Check player namechange
Reply With Quote #5

So if i get this right, i should be able to change clients playername automatically?
Corrosive is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-14-2008 , 08:15   Re: Check player namechange
Reply With Quote #6

Honestly, i don't have a clue on how to implent the player_namechange event into the script i've made. The script mentioned above works.. it kicks the player when it changes playername. But i think this is kinda radical.

It would be more clientfriendly if the server instantly changes the name back into what it says in the database. And gives a message to client in chat with something like "You're not allowed to change your name on this server".

PHP Code:
 
public T_CheckUserAgain(Handle:ownerHandle: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))
    {
        
PrintToChat(client"You're not allowed to change your name on this server.");
    }


Above is a piece of the threaded CheckUserAgain function.. When player changes name it prints a message to client's chat. I guess that new event player_changename should be called somewhere here to?

The question is, how can i define this?

Last edited by Corrosive; 08-14-2008 at 13:40.
Corrosive is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-14-2008 , 09:39   Re: Check player namechange
Reply With Quote #7

bl4nk linked to the exact example code that you need, so what's the problem?
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Corrosive
Junior Member
Join Date: Aug 2008
Old 08-14-2008 , 13:54   Re: Check player namechange
Reply With Quote #8

Quote:
Originally Posted by DJ Tsunami View Post
bl4nk linked to the exact example code that you need, so what's the problem?
The problem is, that i'm quite new at this.. In the example given they're talking about "If someone dies". This is totally different..

.. so please, can you kick me a bit at the right direction?

Grtz
Corrosive is offline
Fredd
Veteran Member
Join Date: Jul 2007
Old 08-18-2008 , 05:07   Re: Check player namechange
Reply With Quote #9

let me break it down yo...jk lol

1. if you want to change their name back after they change it, you could use the player change nick event as Tsunami/bl4nk said but the here is the catch, you can't and won't be able to change their at that time due to what you call the "change nick fuse time" or something which makes you wait x seconds to be able to change your nick again due to the fact that the only way i could think of to change a player name in sourcemod is by using "ClientCommand(client, "name ...."" so as i said you will need to create a timer and then change it back...yeah people will be able to see the message in chat but you could simply block the "SayText" user message in pre mode of the player change name event...and that is solution #1 ;]

2. solutions #2 doesn't exist until you get interested in writing a sourcemod extension or mms plugin
__________________
Need a private coder? AMXX, SourceMOD, MMS? PM me!
Fredd 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 13:13.


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