• 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!

Solved Svargrond NPC take money even if already paid

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,348
Reaction score
76
Location
Germany
Here is the script can someone rewrite to so the NPC only take money once if you say greenshore for example again he takes the money again.
Just like he would say <<< You already paid.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 enterArena(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local cost = 0
    local levelname = ''
    if getPlayerStorageValue(cid, 42355) < 1 then
        cost = 1000
        levelname = 'greenshore'
        levelneeded = 30
    elseif getPlayerStorageValue(cid, 42355) == 1 then
        cost = 5000
        levelname = 'scrapper'
        levelneeded = 50
    elseif getPlayerStorageValue(cid, 42355) == 2 then
        cost = 10000
        levelname = 'warlord'
        levelneeded = 80
    end
    if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
        if(getPlayerLevel(cid) >= levelneeded) then
            if(getPlayerMoney(cid) >= cost) then
                doPlayerRemoveMoney(cid, cost)
                npcHandler:say('Now you can go to test.', cid)
                setPlayerStorageValue(cid, 42351, 1)
            else
                npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
           end
        else
            npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
        end
        npcHandler:resetNpc()
    elseif string.lower(keywords[1]) == 'no' then
        npcHandler:say('Come back later then!', cid)
        npcHandler:resetNpc()
    else
        if getPlayerStorageValue(cid, 42355) < 3 then
            npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
        else
            npcHandler:say('You did all arena levels.',cid)
        end
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to try the arena?')
local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
   
local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
   
local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
   
npcHandler:addModule(FocusModule:new())
 
You can edit the if statement:
Lua:
 if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
To something that also checks the storage value of 42351.

Make an else then statement and put the following:
Lua:
 npcHandler:say(You already paid..', cid)

Have to dig into the script to remake it for you, but I don't have time now, hope this helps.
 
Hope you have time later cause I don't want to mess it up xD


Code:
    if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
        if(getPlayerLevel(cid) >= levelneeded) then
            if(getPlayerMoney(cid) >= cost) then
                doPlayerRemoveMoney(cid, cost)
                npcHandler:say('Now you can go to test.', cid)
                setPlayerStorageValue(cid, 42351, 1)
            else
                npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
            end
        else
            npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
        end
            else
            npcHandler:say('You already paid..', cid)
 
Added storage check
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 enterArena(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local cost = 0
    local levelname = ''
    if getPlayerStorageValue(cid, 42355) < 1 then
        cost = 1000
        levelname = 'greenshore'
        levelneeded = 30
    elseif getPlayerStorageValue(cid, 42355) == 1 then
        cost = 5000
        levelname = 'scrapper'
        levelneeded = 50
    elseif getPlayerStorageValue(cid, 42355) == 2 then
        cost = 10000
        levelname = 'warlord'
        levelneeded = 80
    end
    if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
        if getPlayerStorageValue(cid, 42351) < 1 then
            if(getPlayerLevel(cid) >= levelneeded) then
                if(getPlayerMoney(cid) >= cost) then
                    doPlayerRemoveMoney(cid, cost)
                    npcHandler:say('Now you can go to test.', cid)
                    setPlayerStorageValue(cid, 42351, 1)
                else
                    npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
                end
            else
                npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
            end
        else
            npcHandler:say('You have already paid.', cid)
        end
        npcHandler:resetNpc()
    elseif string.lower(keywords[1]) == 'no' then
        npcHandler:say('Come back later then!', cid)
        npcHandler:resetNpc()
    else
        if getPlayerStorageValue(cid, 42355) < 3 then
            npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
        else
            npcHandler:say('You did all arena levels.',cid)
        end
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to try the arena?')

local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
  
local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
    node1:addChildKeywordNode(yesNode)
    node1:addChildKeywordNode(noNode)
  
npcHandler:addModule(FocusModule:new())
 
Back
Top