gmstrikker
Well-Known Member
- Joined
- Jul 30, 2014
- Messages
- 458
- Solutions
- 1
- Reaction score
- 50
It selling promotes, ok, its work...
But when i say hi, him dont talk nothing
But when i say hi, him dont talk nothing
Code:
<parameter key="message_greet" value="Hello, |PLAYERNAME|. I sell {promotion}"/>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="[NPC]The King" script="data/npc/scripts/promote.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="332" head="21" body="87" legs="107" feet="95"/>
<parameters>
<parameter key="message_greet" value="Hello, |PLAYERNAME|. I sell {promotion}"/>
</parameters>
</npc>
Code:
local config = {
promote1 = 20000, -- preço da primeira promotion
promote2 = 10000000, -- preço da segunda promotion
rookPromote1 = {13, 10000}, -- {id da vocação, preço}
rookPromote2 = {14, 5000000} -- {id da vocação, preço}
}
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 creatureSayCallback(cid, type, msg)
msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if not npcHandler:isFocused(cid) then
return false
end
local price
if (getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 4) then
price = 20000
elseif (getPlayerVocation(cid) >= 5 and getPlayerVocation(cid) <= 8) then
price = 10000000
elseif (getPlayerVocation(cid) == 0) then
price = 10000
elseif (getPlayerVocation(cid) == 13) then
price = 5000000
end
if msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
if (getPlayerLevel(cid) < 20 ) then
selfSay("You need level 20 to be promoted!", cid)
return true
end
if getPlayerVocation(cid) == 0 or getPlayerVocation(cid) == config.rookPromote1[1] then
selfSay("Do you want to buy promotion for " .. price .. " gold coins?", cid)
talkState[talkUser] = 2
elseif getPlayerVocation(cid) > 8 and getPlayerVocation(cid) < config.rookPromote1[1] then
selfSay("Sorry, you are already promoted.", cid)
talkState[talkUser] = 0
elseif not isPremium(cid) and ((getPlayerVocation(cid) > 4 and getPlayerVocation(cid) < config.rookPromote1[1]) or getPlayerVocation(cid) == config.rookPromote1[1]) then
selfSay("Sorry, you must be VIP to buy second promotion.", cid)
talkState[talkUser] = 0
else
selfSay("Do you want to buy promotion for " .. price .. " gold coins?", cid)
talkState[talkUser] = 1
end
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
if doPlayerRemoveMoney(cid, price) then
doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
selfSay("You are now promoted!", cid)
else
selfSay("Sorry, you do not have enough money.", cid)
end
end
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
if getPlayerVocation(cid) == 0 then
if doPlayerRemoveMoney(cid, config.rookPromote1[2]) then
doPlayerSetPromotionLevel(cid, 1)
selfSay("You are now promoted!", cid)
else
selfSay("Sorry, you do not have enough money.", cid)
end
elseif getPlayerVocation(cid) == config.rookPromote1[1] then
if not isPremium(cid) then
selfSay("Sorry, you must be VIP to buy second promotion.", cid)
talkState[talkUser] = 0
return 1
end
if doPlayerRemoveMoney(cid, config.rookPromote2[2]) then
doPlayerSetPromotionLevel(cid, 2)
selfSay("You are now promoted!", cid)
else
selfSay("Sorry, you do not have enough money.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'bye') then
selfSay("Good bye, " .. getPlayerName(cid) .. "!", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: