Bem hoje estou aki postando um npc ke vende vip!
Ele está funcionando corretamente e espero que gostem , realmente não foi flood , eu que fiz.
Primeiramente vá em data/npc e crie uma pasta chamada vip.xml.
nela cole isto :
<?xml version="1.0" encoding="UTF-8"?><npc name="Vip" script="data/npc/scripts/vip.lua" walkinterval="3000" floorchange="0" access="5" >
<health now="150" max="150"/>
<look type="332" head="78" body="86" legs="114" feet="116" addons="0" corpse="2212"/>
<parameters>
<parameter key="message_greet" value="Oi |PLAYERNAME|. Eu vendo { Vip }."/>
<parameter key="message_farewell" value="Volte Sempre."/>
</parameters>
</npc>
Depois vá em scripts e crie uma pasta chamada vip.lua , nela cole isto :
-- Vip Sistem By Zero
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local node1 = keywordHandler:addKeyword({'vip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Se Você Quise Compra Vip So Fala { days } .'})
function creatureSayCallback(cid, type, msg)
p = 10000 -- Valor Da Premium account Em GP
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
---------- MSGs ----------
if msgcontains(msg, 'premium') or msgcontains(msg, 'Premium') or msgcontains(msg, 'premium') or msgcontains(msg, 'Premium Accounts') or msgcontains(msg, 'days') then
selfSay('Pois Bem , Cada Dia De Vip Custa '..p..' GPs, Quantos Dias Você Deseja Comprar?', cid)
talkState[talkUser] = 1
---== compra por GPs ==---
elseif talkState[talkUser] == 1 then
if getNumber(msg) < 350 then
n = getNumber(msg)
if n ~= 0 then
if getPlayerMoney(cid) > p*n then
selfSay('Dias de Vip: {'..n..'} por {'..n*(p)..'} GPs?', cid)
talkState[talkUser] = 3
else
selfSay('Você Nao Tem Gold Suficientes Para Comprar {'..n..'} Dias De Vip.', cid)
talkState[talkUser] = 0
end
else
selfSay('Escolha Um Numero Acima De Zero.', cid)
talkState[talkUser] = 0
end
else
selfSay('Você Nao Pode Comprar Mais Que 350 Dias De Vip.', cid)
talkState[talkUser] = 0
end
elseif talkState[talkUser] == 3 then ---== GPs ==---
if msgcontains(msg, 'yes') or msgcontains(msg, 'sim') or msgcontains(msg, 'SIM') or msgcontains(msg, 'YES') then
if getPlayerPremiumDays(cid)+n <= 350 then
if (doPlayerRemoveMoney(cid, p*n) ~= TRUE) then
npcHandler:say('Voce Nao Tem Gold Suficientes!', cid)
talkState[talkUser] = 0
else
doPlayerAddPremiumDays(cid, n)
selfSay('Compra Efetuada Com Sucesso , Dias De Vip:{ '..n..' }.', cid)
talkState[talkUser] = 0
end
else
npcHandler:say('Voce Nao Pode Ter Mais Que 350 Dias De Vip!', cid)
talkState[talkUser] = 0
end
end
elseif msgcontains(msg, 'no') or msgcontains(msg, 'nao') or msgcontains(msg, 'não') or msgcontains(msg, 'NO') or msgcontains(msg, 'NAO') or msgcontains(msg, 'NÃO')then
selfSay('Tudo Bem.', cid)
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
-- function maded by Gesior--
function getNumber(txt) --return number if its number and is > 0, else return 0
x = string.gsub(txt,"%a","")
x = tonumber(x)
if x ~= nill and x > 0 then
return x
else
return 0
end
end
Assim estará feito o npc , mas enquanto ao lugar que será vip?
Vá em data/movements e abra o arquivo movements.xml , depois cole esta tag :
<movevent type="StepIn" uniqueid="13700" event="script" value="vipe.lua"/>
Oque está em vermelho , é o UniqueId que vc colocará nos "chao" que somente vips poderam passar.
Logo em seguida vá em scripts e crie uma pasta chamada vipe.lua.
Nela cole isto :
-- Vip System by Zerofunction onStepIn(cid, item, position, fromPosition)
local config = {
msgDenied = "Vc nao e vip , compre no npc vip.",
msgWelcome = "Seja Bem Vindo a Area vip."
}
if getPlayerPremiumDays(cid) <= 0 then
doTeleportThing(cid, fromPosition, true)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgDenied)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
return true
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.msgWelcome)
return true
end
Obrigado , espero que gostem.