• 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 for premium days

mmheo

New Member
Joined
Sep 14, 2017
Messages
157
Reaction score
1
hello guys anyone can help me in npc sell premium days for event token

to be like this

Playe : hi

Npc : Hello (playername) I sell premium days for tokens tell me how many days you need to buy?

player: for example 5

npc : do you need to buy 5 premium days for 5 tokens?

player : yes

Npc : Gratz you have add 5 premium days to your account

0.4
 
Solution
X
yes but where when player say premium npc say blblablalbalballablalabalba its just edit for remove tokens and money
lines 30, 31 & 32
LUA:
    elseif talkState[talkUser] == 0 and msgcontains(msg, "premium") then
        selfSay("Please tell me how many days of premium you would like to purchase.", cid)
        talkState[talkUser] = 0
replace 111111111111111111111111111111111111111111111111111111111111111111111111111
with the itemid of the item you are using.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local xmsg = {}

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 greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
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
  
    local temp = tonumber(msg)
    if talkState[talkUser] == 0 and temp ~= nil and temp > 0 then
        selfSay("Do you want to buy " .. msg .. " premium days for " .. msg .. " tokens?", cid)
        xmsg[cid] = msg
        talkState[talkUser] = 1
      
    elseif talkState[talkUser] == 1 and msgcontains(msg, "yes") then
        local tempCount = tonumber(xmsg[cid])
        if getPlayerItemCount(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111) >= tempCount then
            doPlayerRemoveItem(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111, tempCount)
            doPlayerAddPremiumDays(cid, tempCount)
            selfSay("Thank you for your patronage!", cid)
        else
            selfSay("You don't have enough tokens for " .. xmsg[cid] .. " premium days.", cid)
        end
        talkState[talkUser] = 0
      
    else
        selfSay("Sorry? I don't understand.", cid)
        talkState[talkUser] = 0
    end
  
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
replace 111111111111111111111111111111111111111111111111111111111111111111111111111
with the itemid of the item you are using.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local xmsg = {}

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 greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
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
 
    local temp = tonumber(msg)
    if talkState[talkUser] == 0 and temp ~= nil and temp > 0 then
        selfSay("Do you want to buy " .. msg .. " premium days for " .. msg .. " tokens?", cid)
        xmsg[cid] = msg
        talkState[talkUser] = 1
     
    elseif talkState[talkUser] == 1 and msgcontains(msg, "yes") then
        local tempCount = tonumber(xmsg[cid])
        if getPlayerItemCount(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111) >= tempCount then
            doPlayerRemoveItem(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111, tempCount)
            doPlayerAddPremiumDays(cid, tempCount)
            selfSay("Thank you for your patronage!", cid)
        else
            selfSay("You don't have enough tokens for " .. xmsg[cid] .. " premium days.", cid)
        end
        talkState[talkUser] = 0
     
    else
        selfSay("Sorry? I don't understand.", cid)
        talkState[talkUser] = 0
    end
 
    return true
end

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

this npc always tell me Sorry? I don't understand.
 
its work fine ty but need 2 small edit
1:: when player say premium npc reply bblalblabalbalbalbalbaba
2: one day of premium = 1 token and 2 crystal coins
Should've asked for this in your original post.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local xmsg = {}

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 greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
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
   
    local temp = tonumber(msg)
    if talkState[talkUser] == 0 and temp ~= nil and temp > 0 then
        selfSay("Do you want to buy " .. msg .. " premium days for " .. msg .. " tokens and " .. (temp * 2) .. " crystal coins?", cid)
        xmsg[cid] = msg
        talkState[talkUser] = 1
       
    elseif talkState[talkUser] == 0 and msgcontains(msg, "premium") then
        selfSay("Please tell me how many days of premium you would like to purchase.", cid)
        talkState[talkUser] = 0
   
    elseif talkState[talkUser] == 1 and msgcontains(msg, "yes") then
        local tempCount = tonumber(xmsg[cid])
        if getPlayerItemCount(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111) >= tempCount and getPlayerMoney(cid) >= (tempCount * 2) then
            doPlayerRemoveItem(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111, tempCount)
            doPlayerRemoveMoney(cid, (tempCount * 2))
            doPlayerAddPremiumDays(cid, tempCount)
            selfSay("Thank you for your patronage!", cid)
        else
            selfSay("You don't have the required resources to trade for " .. xmsg[cid] .. " premium days.", cid)
        end
        talkState[talkUser] = 0
   
    else
        selfSay("Sorry? I don't understand.", cid)
        talkState[talkUser] = 0
    end
   
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Should've asked for this in your original post.
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local xmsg = {}

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 greet(cid)   talkState[cid] = 0   return true end

function getNpcName()
    return getCreatureName(getNpcId())
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
  
    local temp = tonumber(msg)
    if talkState[talkUser] == 0 and temp ~= nil and temp > 0 then
        selfSay("Do you want to buy " .. msg .. " premium days for " .. msg .. " tokens and " .. (temp * 2) .. " crystal coins?", cid)
        xmsg[cid] = msg
        talkState[talkUser] = 1
      
    elseif talkState[talkUser] == 0 and msgcontains(msg, "premium") then
        selfSay("Please tell me how many days of premium you would like to purchase.", cid)
        talkState[talkUser] = 0
  
    elseif talkState[talkUser] == 1 and msgcontains(msg, "yes") then
        local tempCount = tonumber(xmsg[cid])
        if getPlayerItemCount(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111) >= tempCount and getPlayerMoney(cid) >= (tempCount * 2) then
            doPlayerRemoveItem(cid, 111111111111111111111111111111111111111111111111111111111111111111111111111, tempCount)
            doPlayerRemoveMoney(cid, (tempCount * 2))
            doPlayerAddPremiumDays(cid, tempCount)
            selfSay("Thank you for your patronage!", cid)
        else
            selfSay("You don't have the required resources to trade for " .. xmsg[cid] .. " premium days.", cid)
        end
        talkState[talkUser] = 0
  
    else
        selfSay("Sorry? I don't understand.", cid)
        talkState[talkUser] = 0
    end
  
    return true
end

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

yes but where when player say premium npc say blblablalbalballablalabalba its just edit for remove tokens and money
 
Back
Top