@Limos Your the best i awaken you~
Cant get the script to teleport the player it stoped working after i added the table / config not sure what im doing wrong but yeah just a test script atm would like to have it working.
Cant get the script to teleport the player it stoped working after i added the table / config not sure what im doing wrong but yeah just a test script atm would like to have it working.
Code:
local table = {
["spot 1"] = { cost = 250, location = {x = 1112, y = 999, z = 5}},
["spot 2"] = { cost = 50000, location = {x = 1112, y = 999, z = 5}}
}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local t = table[msg]
if(msgcontains(msg, 'bring me to '.. msg ..'')) then
if getPlayerMoney(cid) >= t.cost then
npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
doTeleportThing(cid, t.location)
elseif getPlayerMoney(cid) <= t.cost then
npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
end
elseif(msgcontains(msg, ''.. msg ..'')) then
if getPlayerMoney(cid) >= t.cost then
npcHandler:say("Do you want to goto ".. msg .." for ".. t.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
talkState[talkUser] = 1
elseif getPlayerMoney(cid) <= t.cost then
npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, t.cost) == true then
npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
doTeleportThing(cid, t.location)
talkState[talkUser] = 0
else
npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Ok.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: