View Full Version : How to supress Servermessage?
nachtcomet
07-31-2007, 08:54 AM
Hi there,
I'am new with scriptings Plugins for HL:DoD. Now I tried to write a Plugin which will do the following:
- there is a File called "reserved.ini" in the config folder, in which are STEAMIDs and Names("STEAMIDxxxxxxx" "aReservedName" and so on)
- If someone connecteds with a reserved Name, the clients STEAMID is checked against the File - If the Client has not the correct SteamID the client will be renamed (NiceNickButWrongSTEAMID) and there will be a public Chatmessage.
- If someone trys to change the Name, the Clients STEAMID will be checked against the file too - If the Clients STEAMID isn't correct, the Client will be renamed back to the old Name BUT (now the Problem) the Server always say "XYZ has change his Name to ZYX"
How to supress this Message (or otherwise) who to post a Messege after the Server Announcement?
{
client_cmd(0, "spk fvox/alert")
client_print(0,print_chat,"+++ [RName] %s hat versucht einen geschuetzen Namen zu benutzen +++",name)
set_user_info(id,"name",name)
engclient_cmd (id,"name",name)
client_cmd(id,"name ",name)
}
this is the part of the code in which I try to rename the Client back - but how to
- supress the Servers Namechange Annoucement OR
- how to post a Chatmessage AFTER the Annoucement?
sorry for my bad english ;)
diamond-optic
07-31-2007, 01:53 PM
something like this in the plugin_init:
register_event("TextMsg","change_name","a","1=3","2=#game_changed_name")then add this function to the plugin:
public change_name()
{
return PLUGIN_HANDLED
}that will block the name change chat text (at least i think..idk i just did this real quick)
of course you would have to add a little more to it according to your other code to determine if it should be blocked or allowed or whatever
and if you need to get the user names & id in the change_name fucntion you can use this in it:
new old_name[32], new_name[32]
read_data(3,old_name,31)
read_data(4,new_name,31)
new userID = get_user_index(old_name)so you could probably use something with that to check if the name is valid for the steamid right from that function, might make it easier to block/allow the chat print
and to print a chat message with that data could be something like:
client_print(0, print_chat, "%s has changed their name to %s", old_name, new_name)
Wilson [29th ID]
07-31-2007, 06:38 PM
Also, check out a similar plugin that Tatsu made for reference:
http://dodplugins.net/forums/showthread.php?t=660
nachtcomet
07-31-2007, 06:56 PM
Sure, there is more Code.
I used public client_infochanged(id) {} to check if a Namechange was done.
//Datei_STEAMID[] and Datei_Name[] are read from reservednicks.ini
public client_infochanged(id){
if (is_user_connected(id)){
new STEAMID[32], NeuerName[32], Name[32]
new Fertig=0
get_user_info(id, "name", NeuerName,31)
get_user_authid(id,STEAMID,31)
get_user_name(id,Name,31)
for (new i = 0; i < numPlayers; i++) {
if(equal(Datei_Name, NeuerName))
{
if(!equal(Datei_STEAMID[i], STEAMID) && !Fertig)
{
client_print(0,print_chat,"+++ [RName] %s hat versucht den reservierten Namen %s zu benutzen +++",Name,NeuerName)
set_user_info(id,"name",Name)
engclient_cmd (id,"name",Name)
client_cmd(id,"name ",Name)
Fertig=1
}
}
}
This Code do to trick (rename to old Name to prevent using a registered Name) but Server will show "XYZ has change his Name to ZXY" under the Warning of RName (the desired name of this plugin).
This "register_event("TextMsg","change_name","a","1=3","2=#game_changed_name")"
this will do what?
Notice the Server that all Nickchange-Text-Event will go through my Plugin? so "client_infochanged" wont be necessary anymore?
nachtcomet
09-24-2007, 06:10 PM
sorry to pop in again, but i dont get it.
this is what i wrote since last post
(got a break because of the family - so now i am on it again)
#include <amxmodx>
#include <amxmisc>
new DateiSteamID[500][32]
new DateiSpielername[500][32]
new AnzahlSpieler
public plugin_init()
{
register_event("TextMsg","change_name","a","1=3","2=#game_changed_name")
register_plugin("R(e)Name", "0.1", "nachtmacher")
register_cvar("dod_R(e)Name_plugin", "Version 0.1", FCVAR_SERVER|FCVAR_SPONLY)
new Dateiname[64]
get_configsdir(Dateiname , 63)
format(Dateiname, 63, "%s/reservednicks.ini", Dateiname)
ladeSpieler(Dateiname)
return PLUGIN_CONTINUE
}
ladeSpieler(Dateiname[])
{
if (!file_exists(Dateiname))
{
log_message("R(e)Name - Fehler - %s nicht gefunden",Dateiname)
}
else
{
new text[256]
new line = 0
new textLen
while (read_file(Dateiname,line++,text,255,textLen))
{
if (text[0] == ';') continue
parse(text, DateiSteamID[AnzahlSpieler],31,DateiSpielername[AnzahlSpieler], 31)
++AnzahlSpieler
}
log_message("R(e)Name - %s gelesen - %s Eintraege gefunden",Dateiname,AnzahlSpieler)
}
return 1
}
public client_connect(id)
{
new SteamID[32], Name[32]
new Fertig=0
get_user_authid(id,SteamID,31)
get_user_name(id,Name,31)
for (new i = 0; i < AnzahlSpieler; i++)
{
if(equal(SteamID, DateiSteamID[i]))
{
client_print(0,print_chat,"+++ [R(e)Name] Spieler %s wurde entsprechend der Clanrules umbenannt in %s +++",Name,DateiSpielername[i])
set_user_info(id,"name",DateiSpielername[i])
Fertig=1
}
}
if (!Fertig)
{
for (new i = 0; i < AnzahlSpieler; i++)
{
if(equal(Name, DateiSpielername[i]))
{
if (!equal(SteamID,DateiSteamID[i]))
{
client_print(0,print_chat,"+++ [R(e)Name] Spieler %s hat versucht mit einem reservierten Namen (%s) zu joinen +++",SteamID, Name)
set_user_info(id,"name","Nice Nick but wrong STEAM ID")
Fertig=1
}
}
}
}
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
if (is_user_connected(id))
{
new NeuerName[32], AlterName[32], SteamID[32]
new Fertig=0
get_user_info (id, "name", NeuerName, 31)
get_user_authid (id, SteamID, 31)
get_user_name (id, AlterName, 31)
for (new i = 0; i < AnzahlSpieler; i++)
{
if(equal(SteamID, DateiSteamID[i]) && !Fertig)
{
if(!equal(DateiSpielername[i], NeuerName))
{
client_print(0,print_chat,"+++ [R(e)Name] Spieler %s hat unerlaubterweise versucht seinen Namen nach %s zu aendern +++",AlterName,NeuerName)
set_user_info(id,"name",AlterName)
Fertig=1
}
}
}
if (!Fertig)
{
for (new i = 0; i < AnzahlSpieler; i++)
{
if(equal(DateiSpielername[i], NeuerName))
{
if (!equal(SteamID, DateiSteamID[i]))
{
client_print(0,print_chat,"+++ [R(e)Name] Spieler %s hat versucht einen geschuetzten Namen (%s) zu benutzen +++",AlterName,NeuerName)
set_user_info(id,"name",AlterName)
Fertig=1
}
}
}
}
if (!Fertig)
{
if (!equal(NeuerName,AlterName))
{
client_print(0, print_chat, "+++ [R(e)Name] Spieler %s hat sich umbenannt in %s",AlterName,NeuerName)
}
}
}
return PLUGIN_CONTINUE
}
public change_name()
{
return PLUGIN_HANDLED
}
the plugin does the trick.
- if you are in reservednicks.ini - you cant connect with every nick - but you get renamed (clanrules - admins have to play with the right nick).
- if you try to connect with a reserved name without the right steamid - you got renamed to "nice nick but wrong steam id"
- if you try to rename yourself to a reserved nick - you will be noticed to have the wrong streamid.
- if you try to rename yourself and you are on the list - you will be notice that this is forbidden
BUT
this lousy servermessage "X has changed his name to Y" is everytime written into public chat (even if you are forbidden to change your name).
on a german AMXX it looks like this (testerchen is a reserved name)
+++ [R(e)Name] Spieler test hat versucht einen geschuetzten Namen (testerchen) zu benutzen +++
* test hat Namen zu testerchen geändert
the bold one is the one i dont want to show.
any further comments? i tried to find out more about "register_event", but all i found out was not very helpfull (where to find all possible "TextMsg" events? as a example).
sorry for the bad english
Wilson [29th ID]
09-24-2007, 07:55 PM
Try changing the PLUGIN_CONTINUE to a PLUGIN_HANDLED in the 2nd to last function.
If that doesn't work, perhaps you'll have to block the TextMsg message.
nachtcomet
09-24-2007, 09:16 PM
i have tried it - but isn't working.
can you tell me how to "block" the TextMsg?
thx in advance
Wilson [29th ID]
09-24-2007, 10:52 PM
Check out dod STEAMID MSG for an example and better understanding of how to hook that.
FeuerSturm
09-25-2007, 02:41 AM
you can take a look at my "personal" name force plugin as i force my
clan members to play with their predefined nicknames as well while
blocking the name change message:
=|[76AD]|= TatsuSaisei
09-25-2007, 11:32 PM
;7021']Also, check out a similar plugin that Tatsu made for reference:
http://dodplugins.net/forums/showthread.php?t=660
Yikes !! A forgottten plugin... I never got around to "completing" this... I have a personal version that has half of what I wanted to publicly include, but never "officially" made any such plugin for public use as of yet...
but thanx for the mention Wilson...
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.