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

Premium Points Exchanger {NPC}

3li Xiber

Active Member
Joined
Dec 29, 2014
Messages
395
Reaction score
31
Hello Otlanders,
I made alot of threads about this request months ago but no one was able to make this npc!:
I want npc to trade gold nuggets+soul orbs for Premium Points.
I want him to trade with me Fourth Times like picture show :
First time : 150 gn+100 soul orbs
Second time : 250gn + 250 soul orbs
Third Time : 350gn+350 orbs
Fourth Time : 400 gn + 400 soul orbs
every time from the fourth time it gives 8 points to the player.
BO476j1.png

Rep++
 
Code:
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
local config = {
   [1] = {soul = 150,nuggets = 250, PP = 1},
   [2] = {soul = 150,nuggets = 250, PP = 5},
   [3] = {soul = 150,nuggets = 250, PP = 7},
   [4] = {soul = 150,nuggets = 250, PP = 8}
--[5] = {soul needed, nuggets needed, reward premium points}
}
local Storage = 9910
local maxStorage = 4
local itemId = {5550,2157} -- item id of Soul, Item id of nuggets
function creatureSayCallback(cid, type, msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) <= 0 and 1 or getPlayerStorageValue(cid,Storage))
  local s = config[getPlayerStorageValue(cid,Storage)]
   if msgcontains(msg, 'trade') then
     if s then
       selfSay("Do You want to recieve "..s.PP.." Premium Points for "..s.soul.." soul Orb and "..s.nuggets.." Gold nuggets?", cid)
       talkState[talkUser] = 2
     end
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
     if s then
       if getPlayerItemCount(cid, itemId[1]) >= s.soul and getPlayerItemCount(cid, itemId[2]) >= s.nuggets then
         doPlayerRemoveItem(cid, itemId[1],s.soul)
         doPlayerRemoveItem(cid, itemId[2],s.nuggets)
         selfSay("Congratulation, You now can enjoy your "..s.PP.." Premium Points.", cid)
         db.executeQuery("UPDATE `accounts` SET premium_point = premium_point + '" .. s.PP .. "' WHERE id = " .. getPlayerGUID(cid) .. ";")
         if getPlayerStorageValue(cid,Storage) < maxStorage then
           doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) + 1)
         end
       end
     end
   end     
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Not tested
 
Code:
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
local config = {
   [1] = {soul = 150,nuggets = 250, PP = 1},
   [2] = {soul = 150,nuggets = 250, PP = 5},
   [3] = {soul = 150,nuggets = 250, PP = 7},
   [4] = {soul = 150,nuggets = 250, PP = 8}
   --[5] = {soul needed, nuggets needed, reward premium points}
}
local Storage = 9910
local maxStorage = 4
local itemId = {5550,2157} -- item id of Soul, Item id of nuggets
function creatureSayCallback(cid, type, msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) <= 0 and 1 or getPlayerStorageValue(cid,Storage))
  local s = config[getPlayerStorageValue(cid,Storage)]
   if msgcontains(msg, 'trade') then
     if s then
       selfSay("Do You want to recieve "..s.PP.." Premium Points for "..s.soul.." soul Orb and "..s.nuggets.." Gold nuggets?", cid)
       talkState[talkUser] = 2
     end
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
     if s then
       if getPlayerItemCount(cid, itemId[1]) >= s.soul and getPlayerItemCount(cid, itemId[2]) >= s.nuggets then
         doPlayerRemoveItem(cid, itemId[1],s.soul)
         doPlayerRemoveItem(cid, itemId[2],s.nuggets)
         selfSay("Congratulation, You now can enjoy your "..s.PP.." Premium Points.", cid)
         db.executeQuery("UPDATE `accounts` SET premium_point = premium_point + '" .. s.PP .. "' WHERE id = " .. getPlayerGUID(cid) .. ";")
         if getPlayerStorageValue(cid,Storage) < maxStorage then
           doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) + 1)
         end
       else
         selfSay("You Dont have the needed items..", cid)
       end
     else
       selfSay("You dont have any availability to trade", cid)
     end
   end     
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
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
local config = {
   [1] = {soul = 150,nuggets = 250, PP = 1},
   [2] = {soul = 150,nuggets = 250, PP = 5},
   [3] = {soul = 150,nuggets = 250, PP = 7},
   [4] = {soul = 150,nuggets = 250, PP = 8}
   --[5] = {soul needed, nuggets needed, reward premium points}
}
local Storage = 9910
local maxStorage = 4
local itemId = {5550,2157} -- item id of Soul, Item id of nuggets
function creatureSayCallback(cid, type, msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) <= 0 and 1 or getPlayerStorageValue(cid,Storage))
  local s = config[getPlayerStorageValue(cid,Storage)]
   if msgcontains(msg, 'trade') then
     if s then
       selfSay("Do You want to recieve "..s.PP.." Premium Points for "..s.soul.." soul Orb and "..s.nuggets.." Gold nuggets?", cid)
       talkState[talkUser] = 2
     end
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
     if s then
       if getPlayerItemCount(cid, itemId[1]) >= s.soul and getPlayerItemCount(cid, itemId[2]) >= s.nuggets then
         doPlayerRemoveItem(cid, itemId[1],s.soul)
         doPlayerRemoveItem(cid, itemId[2],s.nuggets)
         selfSay("Congratulation, You now can enjoy your "..s.PP.." Premium Points.", cid)
         db.executeQuery("UPDATE `accounts` SET premium_point = premium_point + '" .. s.PP .. "' WHERE id = " .. getPlayerGUID(cid) .. ";")
         if getPlayerStorageValue(cid,Storage) < maxStorage then
           doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) + 1)
         end
       else
         selfSay("You Dont have the needed items..", cid)
       end
     else
       selfSay("You dont have any availability to trade", cid)
     end
   end    
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
15:02 Exchanger: You Dont have the needed items..
and i got the items into my backpack
 
Code:
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
local config = {
   [1] = {soul = 150,nuggets = 250, PP = 1},
   [2] = {soul = 150,nuggets = 250, PP = 5},
   [3] = {soul = 150,nuggets = 250, PP = 7},
   [4] = {soul = 150,nuggets = 250, PP = 8}
   --[5] = {soul needed, nuggets needed, reward premium points}
}
local Storage = 9910
local maxStorage = 4
local itemId = {5550,2157} -- item id of Soul, Item id of nuggets
function creatureSayCallback(cid, type, msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) <= 0 and 1 or getPlayerStorageValue(cid,Storage))
  local s = config[getPlayerStorageValue(cid,Storage)]
   if msgcontains(msg, 'trade') then
     if s then
       selfSay("Do You want to recieve "..s.PP.." Premium Points for "..s.soul.." soul Orb and "..s.nuggets.." Gold nuggets?", cid)
       talkState[talkUser] = 2
     end
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
     if s then
       if getPlayerItemCount(cid, itemId[1]) >= s.soul and getPlayerItemCount(cid, itemId[2]) >= s.nuggets then
         doPlayerRemoveItem(cid, itemId[1],s.soul)
         doPlayerRemoveItem(cid, itemId[2],s.nuggets)
         selfSay("Congratulation, You now can enjoy your "..s.PP.." Premium Points.", cid)
         db.executeQuery("UPDATE `accounts` SET premium_point = premium_point + " .. s.PP .. " WHERE id = " .. getPlayerGUID(cid) .. ";")
         if getPlayerStorageValue(cid,Storage) < maxStorage then
           doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) + 1)
         end
       else
         selfSay("You Dont have the needed items..", cid)
       end
     else
       selfSay("You dont have any availability to trade", cid)
     end
   end     
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This should fix it, the rest is up to you,i am done here xD
 
Code:
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + '" .. s.PP .. "' WHERE id = '" ..getPlayerAccountId(cid) .. "';")

¬¬
 
Last edited:
any one can repair @tetra20 script ?? @Musztang solved the problem of add_point
but the main script have problem : i can do the fourth step of exchanger many times and it dont stop
i need it to do 4x times only not more !
 
Code:
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
local config = {
   [1] = {soul = 150,nuggets = 250, PP = 1},
   [2] = {soul = 150,nuggets = 250, PP = 5},
   [3] = {soul = 150,nuggets = 250, PP = 7},
   [4] = {soul = 150,nuggets = 250, PP = 8}
   --[5] = {soul needed, nuggets needed, reward premium points}
}
local Storage = 9910
local maxStorage = 4
local itemId = {5550,2157} -- item id of Soul, Item id of nuggets
function creatureSayCallback(cid, type, msg)
  local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) <= 0 and 1 or getPlayerStorageValue(cid,Storage))
  local s = config[getPlayerStorageValue(cid,Storage)]
   if getPlayerStorageValue(cid,Storage) >= 4 then
     selfSay("You Can not Trade anymore", cid)
     return true
   end
   
   if msgcontains(msg, 'trade') then
     if s then
       selfSay("Do You want to recieve "..s.PP.." Premium Points for "..s.soul.." soul Orb and "..s.nuggets.." Gold nuggets?", cid)
       talkState[talkUser] = 2
     end
   elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
     if s then
       if getPlayerItemCount(cid, itemId[1]) >= s.soul and getPlayerItemCount(cid, itemId[2]) >= s.nuggets then
         doPlayerRemoveItem(cid, itemId[1],s.soul)
         doPlayerRemoveItem(cid, itemId[2],s.nuggets)
         selfSay("Congratulation, You now can enjoy your "..s.PP.." Premium Points.", cid)
         db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + '" .. s.PP .. "' WHERE id = '" ..getPlayerAccountId(cid) .. "';")
         if getPlayerStorageValue(cid,Storage) < maxStorage then
           doPlayerSetStorageValue(cid, Storage, getPlayerStorageValue(cid,Storage) + 1)
         end
       else
         selfSay("You Dont have the needed items..", cid)
       end
     else
       selfSay("You dont have any availability to trade", cid)
     end
   end     
  return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top