• 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 Change Premium points for diamonds

atakashi

New Member
Joined
Jan 20, 2009
Messages
15
Reaction score
0
Good evening, I am in need of an npc to take all premium_points of the person and tranform in Diamond 2147.
IE example.
I have 123 premium_points, talk to the npc "hi", "change", "yes".
He's going to take all my premium_points in case the "123" and will give me 123x Diamond.
 
Create a new npc and into script past this:
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

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 info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '"..getPlayerGUID(cid).."'")
   if(info:getID() == -1) then
       return true
   end
   local premium_points = info:getDataInt("premium_points")
   info:free()   
   
   local item_id = 2147
   
   if(msgcontains(msg, 'change')) then
       if(info > 0) then
           selfSay('Do you want to exchange your '.. info ..' premium points into '.. info ..' diamonds?', cid)
           talkState[talkUser] = 1
       else
           selfSay('You don\'t have any premium points, come back later.', cid)
           talkState[talkUser] = 0
       end
   elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
       doPlayerAddItem(cid, item_id, info)
       db.executeQuery("UPDATE `accounts` SET `premium_points` = 0 WHERE `id` = '"..getPlayerGUID(cid).."'");
       selfSay('Here you are.', cid)
       talkState[talkUser] = 0
   elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
       talkState[talkUser] = 0
       selfSay('Ok then, bye.', cid)
   end
   return true
end

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