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

How do I hook and rewrite a namechange?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tender
Junior Member
Join Date: Nov 2005
Location: Sweden
Old 08-19-2008 , 08:55   How do I hook and rewrite a namechange?
Reply With Quote #1

I tried this code...
PHP Code:
    HookEvent("player_changename"Event_namechangeEventHookMode_Pre);

public 
Action:Event_namechange(Handle:event, const String:name[], bool:dontBroadcast){
    
    
SetEventString(event,"newname" ,"Player");
    
    return 
Plugin_Continue;

... everyone trying to change nick should be named Player. But it has no effect at all. Is something wrong in my code? Is there an other way to rewrite a name change?
Tender is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 08-19-2008 , 10:16   Re: How do I hook and rewrite a namechange?
Reply With Quote #2

Changing the event won't change the player's name. Use ClientCommand(client, "name Player");.
bl4nk is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-19-2008 , 10:37   Re: How do I hook and rewrite a namechange?
Reply With Quote #3

return Plugin_Handled, instead of Plugin_Continue, this will block their name change. Then you can put in the command bl4nk said above.
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Tender
Junior Member
Join Date: Nov 2005
Location: Sweden
Old 08-19-2008 , 12:28   Re: How do I hook and rewrite a namechange?
Reply With Quote #4

Thanx!! I'll try that.
Tender is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 08-19-2008 , 13:20   Re: How do I hook and rewrite a namechange?
Reply With Quote #5

Quote:
Originally Posted by Pinkfairie View Post
return Plugin_Handled, instead of Plugin_Continue, this will block their name change. Then you can put in the command bl4nk said above.
You uh sure about that? It might block the "Player X has changed their name to X" in chat but their name I would think still changes.
__________________
Greyscale is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-19-2008 , 14:00   Re: How do I hook and rewrite a namechange?
Reply With Quote #6

yeah it would block the chat, but i might need to clarify that Plugin_Continue should be the default return, and return Plugin_Handled conditionally if your changing the name. This will block their name change but allow the second name change to go through as normal.
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 08-19-2008 , 14:18   Re: How do I hook and rewrite a namechange?
Reply With Quote #7

Ok so returning Plugin_Handled in that event allows them to change their name again immediately? No "fuse time" that makes them wait until next round or whatever it is?
__________________
Greyscale is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 08-19-2008 , 21:10   Re: How do I hook and rewrite a namechange?
Reply With Quote #8

I believe so
__________________
"Every man is guilty of all the good he did not do"
DiscoBBQ is offline
Tender
Junior Member
Join Date: Nov 2005
Location: Sweden
Old 08-20-2008 , 06:26   Re: How do I hook and rewrite a namechange?
Reply With Quote #9

Thanx for helping me =)

Returning Plugin_Handled will only block the text message, not the actual name change. So.. a ClientCommand for changing nick can't be done whithin 10 seconds, otherwise you'll get "Name change denied (rate exceeded)." in your ingame console.
I made a timer for this, but.. is it possible to temporary remove the namechange rate limit? Is there a server cvar that specifies these 10 seconds or is it client side?
Tender 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 06:23.


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