1--Player rename by Mock the bear (MTB)
2function sugested() --GName generator
3 local cons = {'b','c','d','f','g','h','i','j','k','l','m','n',' p','q','r','s','t','v','x','y','z'}
4 local vog = {"a",'e','i','o','u'}
5 local sibalas = {}
6 for i=1,#cons do
7 for e=1,#vog do
8 table.insert(sibalas,1,cons[i]..vog[e])
9 end
10 end
11 local total = ""
12 for i=1,math.random(1,2) do
13 local nam = ""
14 for i=1,math.random(2,4) do
15 nam = nam..sibalas[math.random(1,#sibalas)]
16 end
17 if math.random(1,2) == 1 then
18 nam = nam..vog[math.random(1,#vog)]
19 elseif math.random(1,2) == 2 then
20 nam = nam..cons[math.random(1,#vog)]
21 end
22 total = total..(i == 2 and ' ' or '')..nam:sub(1,1):upper()..nam:sub(2,-1)
23 end
24 return total
25end
26function onSay(player, words, param)
27 local split = param:splitTrimmed(" ")
28 if param == 'gen' then
29
30 return false
31 end
32 local param1, param2 = param:match('(.-)[;:,.]%s*(.+)')
33 param = param1 or param
34 param2 = param2 or sugested()
35 if not param then
36 player:popupFYI("Nenhum nome foi digitado.")
37 return false
38 end
39 if param2:len() <= 2 or param2:len() > 20 then
40
41 return false
42 end
43 if param2:match('[%a%d%s%u%l]+') ~= param2 then
44 player:popupFYI("Somente letras de A-Z ou Numeros de 0-9.")
45 return false
46 end
47
48 param2 = param2:sub(1,1):upper()..param2:sub(2,-1)
49 local p2 = Creature(param)
50 if p2 and p2:isPlayer() and param1 == player:getName() then
51 if param2 ~= player:getName() then
52 local newname = param2:gsub(" ", "")
53 local Test = db.storeQuery("SELECT name FROM players WHERE name = '" ..newname.. "';")
54 if Test then
55
56 return false
57 end
58 if Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE) then
59 local SALDO_VIP = PlayerVipCoins(player, 00)
60 if SALDO_VIP >= 250 then
61 local id = p2:getGuid()
62 PlayerVipCoins(player, 01, 250)
63
64 p2:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
65 addEvent(doRemoveCreature, 3000, p2.uid)
66 addEvent(function(id, newname)
67 db.query("UPDATE `players` SET `name` = '"..newname.."' WHERE `id` = "..id)
68 end, 3100, id, newname)
69 return false
70 else
71
72 return false
73 end
74 else
75 player:popupFYI("Somente em Protection Zone (PZ).")
76 return false
77 end
78 else
79
80 return false
81 end
82 else
83
84 return false
85 end
86
87 return false
88end
89