• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Change Name Script

Nastix

tyskiots.pl coming soon
Joined
Mar 21, 2009
Messages
29
Reaction score
1
Hi, I need script (talkactions) which will change nick of player.
For example.
Before:
Nast
(-_-)
\|/
/ \

After:
GM Nast
(-_-)
\|/
/ \

I give rep :)

Ps. I using TFS0.3.1PL (850)
 
I made a script, feel free to ask to someone make it shorten.
What it does? When your GOD says "/changename Player Name,New Name", it will popup an message to the player you changed the name saying "XXXXXX has changed your name to NEWNAME. Please relog your account when kicked." And he will be automatically kicked in 3 seconds, changing his name(He will need to relog account).

Make a file called changename.lua in yours talkactions/scripts folder and add this(Config is on the top of the script]:
Code:
-------------------------------- Change Name script by Nandonalt - Config Below
-- Time, in seconds, that the player will have to read the message.
local seconds = 4
--------------


local function changeName(param)
guid = getPlayerGUID(param.pid)
		        doRemoveCreature(param.pid)
  db.executeQuery("UPDATE `players` SET `name` = '"..param.params[2].."' WHERE `id` = " .. guid .. ";")
  		        		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Player with name: '..param.params[1]..' changed to name: '..param.params[2]..'.') 
  		        		end      		        		
  		        		

function onSay(cid, words, param)
    dofile("./config.lua")
    name = getCreatureName(cid)
    params = string.explode(param,",")
    pid = getPlayerByNameWildcard(params[1])
      
 if params[1] ~= "" and params[2] ~= "" then       
   	if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. params[1] .. " is not online.")
		else
		        doPlayerPopupFYI(pid, name.." has changed your name to "..params[2]..".\nRelog your account when kicked.")
		         addEvent(changeName, seconds * 1000, {cid = cid, pid = pid, params = params})

		        		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Will change player "..params[1].."'s name to "..params[2].." in "..seconds.." seconds.")  
				return true
	end     
    else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Usage: /changename Playername,Newname')                                            
   
end
return 1
end

And in talkactions.xml, add:
Code:
<talkaction log="yes" words="/changename" access="5" event="script" value="changename.lua"/>

I'm not very good on making short scripts, but test this script i made.
 
Lua:
-- Change Name script by Nandonalt - Config Below
local seconds = 4 -- Time, in seconds, that the player will have to read the message.

	local function changeName(param)
		local guid = getPlayerGUID(param.pid)
		doRemoveCreature(param.pid)
		db.executeQuery("UPDATE `players` SET `name` = '"..param.params[2].."' WHERE `id` = " .. guid .. ";")
		doRemoveCreature(guid)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Player with name: '..param.params[1]..' changed to name: '..param.params[2]..'.') 
		return true
	end      		        		
  		        		

function onSay(cid, words, param)
    dofile("./config.lua")
    name = getCreatureName(cid)
    params = string.explode(param,",")
    pid = getPlayerByNameWildcard(params[1]) 
	if params[1] ~= "" and params[2] ~= "" then       
		if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. params[1] .. " is not online.")
		else
		    doPlayerPopupFYI(pid, name.." has changed your name to "..params[2]..".\nRelog your account when kicked.")
		    addEvent(changeName, seconds * 1000, {cid = cid, pid = pid, params = params})
		    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Will change player "..params[1].."'s name to "..params[2].." in "..seconds.." seconds.")  
			return true
		end     
    else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Usage: /changename Playername, Newname')                                            
	end
	return true
end
 
Back
Top