Hi,
I've seen various scripts to create an item that allows you to change your nickname... But how to exclude nicknames such as "GM" "Tutor" "Admin".....?
For TFS 1.4.2
I found one for 1.2 T.F.S but without what I'm looking for and it probably won't work on 1.4.2:
I've seen various scripts to create an item that allows you to change your nickname... But how to exclude nicknames such as "GM" "Tutor" "Admin".....?
For TFS 1.4.2
I found one for 1.2 T.F.S but without what I'm looking for and it probably won't work on 1.4.2:
This should work for 1.0, 1.1, 1.2
local x = {
length = {['min'] = 4, ['max'] = 20},
itemid = 8189
}
function setPlayerName(cid, newName)
local player = Player(cid)
local name = db.escapeString(player:getName())
newName = db.escapeString(newName)
player:remove()
db.query('UPDATEplayers
SETname
= '.. newName ..' WHERE name = '.. name ..';')
end
function correctNameLength(str)
local value = str:len()
return x.length['min'] >= value and x.length['max'] <= value
end
function onSay(cid, words, param, channel)
local player = type(cid) == "userdata" and cid or Player(cid)
if not param or param == '' then
player:sendCancelMessage('Use: '.. words ..' <newname>')
return true
end
local position, item = player:getPosition(), ItemType(x.itemid)
if player:getItemCount(x.itemid) < 1 then
player:sendCancelMessage("You do not have enough ".. item:getName()..".")
position:sendMagicEffect(CONST_ME_POFF)
return true
end
if param:find("[^%a%s]") then
player:sendCancelMessage("This name ".. param .." is invalid")
return true
end
if not correctNameLength(param) then
player:sendCancelMessage("The new name has to be between " .. x.length['min'] .. " and " .. x.length['max'] .. " characters.")
return true
end
item:remove()
setPlayerName(player:getId(), param)
return true
end