• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

100 event tokens make 200 premium points.

Imfreezing

Krossa Kapitalismen
Joined
Jun 7, 2012
Messages
1,009
Solutions
1
Reaction score
88
Location
Edron
Hello otland,ive searched around for a bit of time for this,but didn't know what to search on,so ,well
however,i want a npc script for 0.4 3884 so you can sell 100 event tokens you get from event for 200 premium points
i use gesior
i use tfs 0.4
trunk 3884
any help would be alot appriacted
:D
 
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

    if msgcontains(msg, "token") then
        selfSay("Do you want to trade 100 tokens for 200 premium points?", cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, 9020) >= 100 then
            doPlayerRemoveItem(cid, 9020, 100)
            doPlayerAddPremiumDays(cid, 2)
            db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 200 WHERE `id` = " .. getPlayerAccountId(cid))
            selfSay("Here you go, 200 premium points has been transfered to your account!", cid)
        else
            selfSay("Sorry, it seems like you're short on tokens.", cid)
        end
        talkState[talkUser] = 0
    elseif msgcontains(msg, "no") and isInArray({1}, talkState[talkUser]) then
        selfSay("Maybe next time.", cid)
        talkState[talkUser] = 0
    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

function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    if msgcontains(msg, "token") then
        selfSay("Do you want to trade 100 tokens for 200 premium points?", cid)
        talkState[talkUser] = 1
    elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
        if getPlayerItemCount(cid, 9020) >= 100 then
            doPlayerRemoveItem(cid, 9020, 100)
            doPlayerAddPremiumDays(cid, 2)
            db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 200 WHERE `id` = " .. getPlayerAccountId(cid))
            selfSay("Here you go, 200 premium points has been transfered to your account!", cid)
        else
            selfSay("Sorry, it seems like you're short on tokens.", cid)
        end
        talkState[talkUser] = 0
    elseif msgcontains(msg, "no") and isInArray({1}, talkState[talkUser]) then
        selfSay("Maybe next time.", cid)
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
thank you sooo much
 
Back
Top