• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Jailkeeper + paying [request]

Try this one then.

Code:
ocal talkNode = 0

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureSay(cid, type, msg)                             npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos)                 npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                             npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                             npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                     npcHandler:onThink() end
-- OTServ event handling functions end


local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
        
function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end

    player_gold = getPlayerItemCount(cid,2148)
    player_plat = getPlayerItemCount(cid,2152)*100
    player_crys = getPlayerItemCount(cid,2160)*10000
    player_money = player_gold + player_plat + player_crys
    
    local cost = 1337
    local outPos = {x = 100, y = 100, z = 10}
    
    if msgcontains(msg,'yes') then
        if talkNode == 0 then
            selfSay('Then you will need to pay ' .. cost .. ' gold. Do you wanna pay that amount?')
            talkNode = 1
        elseif talkNode == 1 then
            if player_money >= cost then
                doPlayerRemoveMoney(cid,cost)
                doTeleportThing(cid,outPos)
            end                
        end
    end    
    return TRUE
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
 
b4 u close i made that edit already :/ in my post, but still ur the best :D i am just improving xDD
hmm second gonna check evo source and edit this post.
PHP:
local talkNode = 0

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureSay(cid, type, msg)                             npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos)                 npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                             npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                             npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                     npcHandler:onThink() end
-- OTServ event handling functions end


local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
        
function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end

    player_gold = getPlayerItemCount(cid,2148)
    player_plat = getPlayerItemCount(cid,2152)*100
    player_crys = getPlayerItemCount(cid,2160)*10000
    player_money = player_gold + player_plat + player_crys
    
    local cost = 1337
    local outPos = {x = 100, y = 100, z = 10}
    
    if msgcontains(msg,'yes') then
        if talkNode == 0 then
            selfSay('Then you will need to pay ' .. cost .. ' gold. Do you wanna pay that amount?')
            talkNode = 1
        elseif talkNode == 1 then
            if player_money >= cost then
                DoPlayerRemoveMoney(cid, cost)
                doTeleportThing(cid,outPos)
            end                
        end
    end    
    return TRUE
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
 
b4 u close i made that edit already :/ in my post, but still ur the best :D i am just improving xDD

Haha, your script wouldn't work anyway, you wrote DoPlayerRemoveMoney instead of doPlayerRemoveMoney. ;)
 
Haha, your script wouldn't work anyway, you wrote DoPlayerRemoveMoney instead of doPlayerRemoveMoney. ;)
that was great help lol a D instead of d made my script fail o_O
@dediol i wont mind some rep as well XD
 
acutally Clary you are right, you atleast tryed to help me in my search for my perfect jailkeeper, instead of some other guys that only flame that Evo sucks :p
 
Thanks and like the fact somebody said yeah if you dont got money then you cant leave, well thats youre own fault then cause you dont need to bot ;) And like this its easier to punish cheaters instead of banning them always. Cause banning people = people leave the server :(
 
Sorry, I missed the message that he should say when you haven't got enough money, so take this script instead. ;)

Code:
local talkNode = 0

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureSay(cid, type, msg)                             npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos)                 npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                             npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                             npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                     npcHandler:onThink() end
-- OTServ event handling functions end


local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
        
function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end

    player_gold = getPlayerItemCount(cid,2148)
    player_plat = getPlayerItemCount(cid,2152)*100
    player_crys = getPlayerItemCount(cid,2160)*10000
    player_money = player_gold + player_plat + player_crys
    
    local cost = 1337
    local outPos = {x = 100, y = 100, z = 10}
    
    if msgcontains(msg,'yes') then
        if talkNode == 0 then
            selfSay('Then you will need to pay ' .. cost .. ' gold. Do you wanna pay that amount?')
            talkNode = 1
        elseif talkNode == 1 then
            if player_money >= cost then
                doPlayerRemoveMoney(cid,cost)
                doTeleportThing(cid,outPos)
            else
                selfSay('You haven\'t got enough money.')
            end                
        end
    end    
    return TRUE
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
 
some help plx?


Code:
you need to add this to global.lua

function pay(cid, amount)

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		
	if player_money >= amount then
		doPlayerRemoveMoney(cid, amount)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You do not have enough money.")
	end
end

i think so
 
No need... You only need this:
PHP:
local talkNode = 0

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureSay(cid, type, msg)                             npcHandler:onCreatureSay(cid, type, msg) end
function onThingMove(creature, thing, oldpos, oldstackpos)                 npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                             npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                             npcHandler:onCreatureTurn(creature) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                     npcHandler:onThink() end
-- OTServ event handling functions end


local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
        
function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end

    local cost = 1337
    local outPos = {x = 100, y = 100, z = 10}
    
    if msgcontains(msg,'yes') then
        if talkNode == 0 then
            selfSay('Then you will need to pay ' .. cost .. ' gold. Do you wanna pay that amount?')
            talkNode = 1
        elseif talkNode == 1 then
            if doPlayerRemoveMoney(cid,cost) == FALSE then
                doTeleportThing(cid,outPos)
            else
                selfSay('You haven\'t got enough money.')
            end                
        end
    end    
    return TRUE
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

the function returns 0 if you don't got money... if it doesn't work, just remove the " == FALSE" :)

Cuz im unsure whether it returns 0 or false xD
 
Back
Top