banimod / etpro / ettv forums Forum Index banimod / etpro / ettv forums
Bani's Discussion Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

renam action

 
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding
View previous topic :: View next topic  
Author Message
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Thu Jun 25, 2009 8:47 am    Post subject: renam action Reply with quote

Code:
function RenameUser(clientNum, newname)
  local userinfo = et.trap_GetUserinfo(clientNum)
  userinfo = et.Info_SetValueForKey(userinfo, "name", newname)
local name = string.gsub(userinfo, "^3@+^1%w+", "")
  et.trap_SetUserinfo(clientNum, name)
  et.ClientUserinfoChanged(clientNum)
end



if modified this code (thx to luke4ward)
i want to change @+ to nothing but its somehow not working :S
Back to top
View user's profile Send private message MSN Messenger
bennz



Joined: 06 Feb 2007
Posts: 9

PostPosted: Thu Jun 25, 2009 9:43 am    Post subject: Reply with quote

Code:
local name = string.gsub(userinfo, "^3@+^1%w+", "")


well pattern machting...

Code:
"^3@+^1%w+"

--> a ^ represents beginning of a string! Escape it & it will match the color code ^3

Manual says: "You can use the escape `%ยด not only for the magic characters, but also for all other non-alphanumeric characters. When in doubt, play safe and put an escape. "




edit: e.g.
Code:
local name = string.gsub(userinfo, "%^3%@+^1[%S]+", "")

--> somewhere in that string: color code ^3, followed by one or more
@, color code ^1 and everything but a space character.

"^3@^1affenarsch more nick" --> " more nick"
"start ^3@^1affenarsch more nick" --> "start more nick"


or

Code:
local name = string.gsub(userinfo, "%^3%@+^1.+", "")

--> somewhere in that string: color code ^3, followed by one or more
@, color code ^1 and everything else.

"^3@^1affenarsch more nick" --> ""
"start ^3@^1affenarsch more nick" --> "start "




greetz


Last edited by bennz on Thu Jun 25, 2009 10:40 am; edited 1 time in total
Back to top
View user's profile Send private message
crazyfrag



Joined: 01 Oct 2004
Posts: 105

PostPosted: Thu Jun 25, 2009 10:26 am    Post subject: Reply with quote

Code:
"\"^3\"@+"\^1\"%w+"


is this correct (sry im not that lua guru) :S
Back to top
View user's profile Send private message MSN Messenger
bennz



Joined: 06 Feb 2007
Posts: 9

PostPosted: Thu Jun 25, 2009 10:53 am    Post subject: Reply with quote

hehe

btw: crazy posted his reply before i edited my post with examples, so don't laugh Thumbs up
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    banimod / etpro / ettv forums Forum Index -> ET Modding All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group