Page 1 of 1

et_ClientCommand can't get cmd "name" ?

Posted: Wed Feb 20, 2008 10:48 am
by Luk4ward
What is going on? Is it connected to the fact that punkbuster or etadmin mod capturing the command before lua or smth?

p.s im talking about client command:

Code: Select all

/name

Posted: Wed Feb 20, 2008 3:13 pm
by Major Zeman
I believe the /name command doesn't get sent to the server at all. It should be processed on client side already, and you should only get userinfo changed or sometihng liek that (which you can intercept with lua).

Posted: Fri Feb 22, 2008 5:13 am
by Luk4ward
i see, thx for reply ! Im trying to create some name limit mod which will not kick a player and instead of it after the limit it will restoring original name. Im using Hadro's code but the only problem is now how to set the nick and block from setting the nick because i can't run et_clientcommand its very complicated ;[

so far i got, but its not working:

Code: Select all

function et.trap_Maxname(clientNum, ret)

local msg = string.format("cpmsay  \"^3ID: ^g" .. clientNum ..  "^7 reached the name change limit. ^1Restoring original name !\n")
et.trap_SendConsoleCommand(et.EXEC_APPEND, msg)
et.trap_SendServerCommand(clientNum, string.format("print \"" .. ret .. "\n"))

local userinfo = et.trap_GetUserinfo( clientNum  )

local infostring = et.Info_RemoveKey( userinfo, "name" )							
local setstring = et.Info_SetValueForKey( infostring, "name", origin_name[clientNum] )

			et.trap_SetUserinfo( clientNum, setstring )
			
end
edit:

debugged it and vars are ok but its not changing the nick ;/

Posted: Fri Feb 22, 2008 8:42 am
by McSteve
At a glance, I'm not sure you need "et.Info_RemoveKey" at all. Further, I had a look back at Gotenks' rename function in Powermod (because I've used that before and I know it works).

Code: Select all

function RenameUser(PlayerID,Name)
	local userinfo = et.trap_GetUserinfo( PlayerID )
	local PlayerName = et.Q_CleanStr( et.Info_ValueForKey( userinfo, "name" ) )
	userinfo = et.Info_SetValueForKey( userinfo, "name", Name )
	et.trap_SetUserinfo( PlayerID, userinfo )
	
	et.trap_SendConsoleCommand(et.EXEC_APPEND, "mute " .. "\"" .. PlayerName .. "\"" .. "\n" )
	PlayerName = et.Q_CleanStr( et.Info_ValueForKey( userinfo, "name" ) )
	et.trap_SendConsoleCommand(et.EXEC_APPEND, "unmute " .. "\"" .. PlayerName .. "\"" .. "\n" )
end
Your code more or less uses the same lines as his but your problem might be in updating the userinfo. You can see that Gotenks used a little mute/unmute handywork, which I think forces the new info on the client (I'm assuming this since it appears to mute with the old name and then unmute with the newname).

Other than that, I could only suggest spamming your code with debugging print lines, checking all of your variables (inc info) at each step in your code.

Best of luck, hope you get sorted.

Posted: Fri Feb 22, 2008 9:58 am
by Luk4ward
hey, thx for the help but this code is not working either :<

as u can see setstring got modified name but it is not setting and userinfo is still the same ;/

btw SetUserinfo is putting the name at the end of userinfo, is it ok?

Posted: Fri Feb 22, 2008 2:13 pm
by Hadr0
this alternative seems to work for me:

Code: Select all

function RenameUser&#40;clientNum, newname&#41;
  local userinfo = et.trap_GetUserinfo&#40;clientNum&#41;
  userinfo = et.Info_SetValueForKey&#40;userinfo, "name", newname&#41;
  et.trap_SetUserinfo&#40;clientNum, userinfo&#41;
  et.ClientUserinfoChanged&#40;clientNum&#41;
end

Posted: Fri Feb 22, 2008 5:05 pm
by Luk4ward
Cheers now its working somehow, wooha another module done. Many thx Hadro i have already added you on my credits' list ;)

It will be added into new version of this . Propably tomorrow i will post it to public,

thx for all the help, much appreciated