Hello,
The script below works correctly on TFS 1.2 however on TFS 1.3 it doesn't. Probably the functions have changed, could anyone check?
The script below works correctly on TFS 1.2 however on TFS 1.3 it doesn't. Probably the functions have changed, could anyone check?
Lua:
local config = {
newNameLength = {4, 20},
itemid = 2112
}
local array = {"-","1","2","3","4","5","6","7","8","9","0","<",">","/","|","~","!","@","#","$","%","^","&","*","(",")","_","=",",","."}
function setPlayerName(cid, currentName, newName)
if not isPlayer(cid) then return false end
doRemoveCreature(cid)
db.query(string.format('UPDATE [ICODE]players[/ICODE] SET [ICODE]name[/ICODE] = %s WHERE name = %s;', db.escapeString(newName), db.escapeString(currentName)))
return true
end
function onSay(cid, words, param, channel)
if (param == '') then
doPlayerSendCancel(cid, 'Command requires param')
return true
end
if getPlayerItemCount(cid,2112) < 1 then
doPlayerSendCancel(cid,"You Dont Have Change Name Item")
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
return true
end
if not param then
doPlayerSendCancel(cid, string.format('Use: %s <newname>', words))
return true
end
if string.find(param,"1") or string.find(param,"2") or string.find(param,"1") or string.find(param,"3") or string.find(param,"4") or string.find(param,"5") or
string.find(param,"6") or string.find(param,"7") or string.find(param,"8") or string.find(param,"9") or string.find(param,"0") or string.find(param,"-") or
string.find(param,"=") or string.find(param,"<") or string.find(param,">") or string.find(param,"/") or string.find(param,"&") or string.find(param,"@") then
doPlayerSendCancel(cid, "This Name Is Invalid")
return true
end
local length = string.len(param)
if math.min(math.max(length, config.newNameLength[1]), config.newNameLength[2]) ~= length then
doPlayerSendCancel(cid, string.format('New name has to be between %i and %i characters long.', config.newNameLength[1], config.newNameLength[2]))
return true
end
doPlayerRemoveItem(cid,2112,1)
setPlayerName(cid, getPlayerName(cid),param)
return true
end
Last edited: