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

NPC bless only for storage

Mefiu

New Member
Joined
Mar 2, 2008
Messages
221
Reaction score
0
Hello.
I change a little this script that only vip player with storage 11551 can buy all blesses.
But even if im VIP NPC say "Sorry you are not VIP".
What's wrong ??

Lua:
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

    bless2 = getPlayerBlessing(cid,2)
    tbless = 'Sorry, but you already have this blessing.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings for only 40k, are you prepared to pay and are you VIP ?'
    mbless = 'Oh. You do not have enough money.' 
    gbless = 'Now the Gods blessed you.'
    pbless = 'Sorry, you are not VIP'
    price = 40000
    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 msgcontains(msg, 'vip bless') then
            if getPlayerStorageValue(cid, 11551) then
            if player_money >= price then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            else
                selfSay(pbless, cid)
                talkState[talkUser] = 0
            end
        else
            selfSay(mbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if bless2 then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, price) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok than.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
if getPlayerStorageValue(cid, 11551) then
to
Lua:
if getPlayerStorageValue(cid, 11551) ~= -1 then
 
Try this one

Lua:
  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


    tbless = 'Sorry, but you are already blessed.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings for only '..cost..' are you prepared to pay and are you VIP ?'
    mbless = 'Oh. You do not have enough money.'
    gbless = 'You are now blessed.'
    pbless = 'Sorry, you are not VIP'
	cost = 20000 -- 20k change to your price.

    if msgcontains(msg, 'vip bless') then
            if getPlayerStorageValue(cid, 11551) == TRUE then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            elseif getPlayerStorageValue(cid, 11551) == FALSE then
                selfSay(pbless, cid)
                talkState[talkUser] = 0
            end
        else
            selfSay(mbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if getPlayerBlessing(cid, 2) then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Never scripted a NPC :( xD

makromang0 1 second before me :)
 
Lua:
if getPlayerStorageValue(cid, 11551) then
to
Lua:
if getPlayerStorageValue(cid, 11551) ~= -1 then

It still doesn't work.

@Zonet
Testing it now :>

@edit
It's not working.. You missed 2 end tags, but after adding it next error :

Code:
'<eof>' expected near 'else' at line 37

Here is code
Lua:
  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


    tbless = 'Sorry, but you are already blessed.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings for only '..cost..' are you prepared to pay and are you VIP ?'
    mbless = 'Oh. You do not have enough money.'
    gbless = 'You are now blessed.'
    pbless = 'Sorry, you are not VIP'
        cost = 40000 -- 20k change to your price.

    if msgcontains(msg, 'vip bless') then
            if getPlayerStorageValue(cid, 11551) == TRUE then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            elseif getPlayerStorageValue(cid, 11551) == FALSE then
                selfSay(pbless, cid)
                talkState[talkUser] = 0
            end
        end
	end
	else
            selfSay(mbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if getPlayerBlessing(cid, 2) then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Btw. im using 0.3.2 TFS
 
Last edited:
Lua:
  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


    tbless = 'Sorry, but you are already blessed.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings for only '..cost..' are you prepared to pay and are you VIP ?'
    mbless = 'Oh. You do not have enough money.'
    gbless = 'You are now blessed.'
    pbless = 'Sorry, you are not VIP'
        cost = 20000 -- 20k change to your price.

    if msgcontains(msg, 'vip bless') then
            if getPlayerStorageValue(cid, 11551) == TRUE then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            elseif getPlayerStorageValue(cid, 11551) == FALSE then
                selfSay(pbless, cid)
                talkState[talkUser] = 0
            end
        else
            selfSay(mbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if getPlayerBlessing(cid, 2) then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok then.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
try

or

Lua:
  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

    bless2 = getPlayerBlessing(cid,2)
    tbless = 'Sorry, but you already have this blessing.'
    tbless2 = 'Sorry, but you already have one blessing, and u cant buy all others.'
    obless = 'I will give to you all blessings for only 40k, are you prepared to pay and are you VIP ?'
    mbless = 'Oh. You do not have enough money.'
    gbless = 'Now the Gods blessed you.'
    pbless = 'Sorry, you are not VIP'
    price = 40000
    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 msgcontains(msg, 'vip bless') then
            if getPlayerStorageValue(cid, 11551) == TRUE then
            if player_money >= price then
                selfSay(obless, cid)
                talkState[talkUser] = 2
            else
                selfSay(pbless, cid)
                talkState[talkUser] = 0
            end
        else
            selfSay(mbless, cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
        talkState[talkUser] = 0
         if bless2 then
            selfSay(tbless, cid)
        else
            if doPlayerRemoveMoney(cid, price) == TRUE then
                doPlayerAddBlessing(cid, 1)
                doPlayerAddBlessing(cid, 2)
                doPlayerAddBlessing(cid, 3)
                doPlayerAddBlessing(cid, 4)
                doPlayerAddBlessing(cid, 5)
                selfSay(gbless, cid)
            else
                selfSay(mbless, cid)
            end
        end

------------------------------------------------ confirm no ------------------------------------------------
    elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
        selfSay('Ok than.', cid)
        talkState[talkUser] = 0
    end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Both of ur script don't work.

In second no errors but when im talkin to NPC i have same problem like i said in first post.

Code:
21:30 Test: vip bless
21:30 Deruno: Sorry, you are not VIP

But Test has vip ...
 
Back
Top