• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Change Account Information & Player Names In-game

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
The Forgotten Server 0.3.6pl1
This is not really that special, but it is very helpful to have. I thought it might save people some time instead of accessing their databases.

Features:
  • Checks if the new name already exists or not.
  • Checks if the new account number already exists or not.
  • While changing the players name, it will check if he is name locked or not.

Examples:
Code:
/pass <player_name_here>, <new_password_here>
/acc <player_name_here>, <new_account_here>
/name <player_name_here>, <new_name_here>

data/talkactions/talkactions.xml
PHP:
<talkaction log="yes" words="/pass;/acc;/name" access="5" event="script" value="account.lua"/>

data/talkactions/scripts/account.lua
Code:
function onSay(cid, words, param, channel)
	local p = string.explode(param, ',')
	if(param == "") then
		doPlayerSendCancel(cid, "Command requires param.")
		return true
	end
	if(words == "/pass") then
		if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
			return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
		end
		return db.executeQuery("UPDATE `accounts` SET `password` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s account password to " .. p[2] .. ".")
	end
	if(words == "/acc") then
		if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
			return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
		elseif(db.getResult("SELECT `id` FROM `accounts` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
			return doPlayerSendCancel(cid, "Sorry, but account [" .. p[2] .. "] already exists.")
		end
		return db.executeQuery("UPDATE `accounts` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s account number to " .. p[2] .. ".")
	end
	if(words == "/name") then
		if(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1) then
			return doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.")
		elseif(isPlayerBanished(p[1], PLAYERBAN_LOCK)) then
			return doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.")
		elseif(db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1) then
			return doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.")
		end
		return db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. ".")
	end
end
 
...
Code:
function onSay(cid, words, param, channel)
	local p = string.explode(param, ',')
	return param == "" and doPlayerSendCancel(cid, "Command requires param.") or words == "/pass" and (db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1 and doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.") or db.executeQuery("UPDATE `accounts` SET `password` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s account password to " .. p[2] .. ".")) or words == "/acc" and (db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1 and doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.") or db.getResult("SELECT `id` FROM `accounts` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1 and doPlayerSendCancel(cid, "Sorry, but account [" .. p[2] .. "] already exists.") or db.executeQuery("UPDATE `accounts` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s account number to " .. p[2] .. ".")) or words == "/name" and (db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[1]) .. ";"):getID() == -1 and doPlayerSendCancel(cid, "Sorry, but player [" .. p[1] .. "] does not exist.") or isPlayerBanished(p[1], PLAYERBAN_LOCK) and doPlayerSendCancel(cid, "Sorry, but " .. p[1] .. " is name locked.") or db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(p[2]) .. ";"):getID() == 1 and doPlayerSendCancel(cid, "Sorry, but the name [" .. p[2] .. "] already exists.") or db.executeQuery("UPDATE `players` SET `name` = '" .. p[2] .. "' WHERE name = '" .. p[1] .. "';") and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have changed " .. p[1] .. "'s name to " .. p[2] .. "."))
end
 
I could have made it like that, but it's not as easy for most people to configure.

Thanks for the comments.

//JDB
 
Nice script! But I have this error:
[13/04/2010 15:07:05] data/talkactions/scripts/account.lua:24: attempt to call global 'isPlayerBanned' (a nil value)
[13/04/2010 15:07:05] stack traceback:
[13/04/2010 15:07:05] data/talkactions/scripts/account.lua:24: in function <data/talkactions/scripts/account.lua:1>

Can u help me?
 
I have no such error using 0.3.6pl1. That function must not be working on your version.
 
Bug: unlimited number of letters of the nickname

Well if you have a problem with "God's" giving names that are 25 character's long, then I think you should reevaluate your situation.
 
Back
Top