psychosisneamia
~Beginner~
- Joined
- Jun 7, 2012
- Messages
- 162
- Reaction score
- 7
I am using a Mount seller npc the script is
The problem is the npc does not take any money from the players.. Can anyone tell me why and how to fix it? Thank you~!!!
Code:
local table = {
["Rented Horse 1"] = {price = 10000, id = 22},
["Rented Horse 2"] = {price = 25000, id = 25},
["Rented Horse 3"] = {price = 30000, id = 26}
}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if table[msg] then
local t = table[msg]
talkState[talkUser] = 1
if getPlayerPremiumDays(cid) >= 0 then
if not getPlayerMount(cid, t.id) then
if doPlayerRemoveMoney(cid, t.cena) then
doPlayerAddMount(cid, t.id)
selfSay("You lost "..t.price.." gp! for mount!", cid)
talkState[talkUser] = 0
else
selfSay("Sorry, you do not have enough money!", cid)
talkState[talkUser] = 0
end
else
selfSay("You already have this mount!", cid)
talkState[talkUser] = 0
end
else
selfSay("You must be Premium!", cid)
talkState[talkUser] = 0
end
else
selfSay('The mounts I currently have to rent are {Rented Horse 1} {Rented Horse 2} and my favorite {Rented Horse 3}, So which will it be stranger?', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
The problem is the npc does not take any money from the players.. Can anyone tell me why and how to fix it? Thank you~!!!