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

Lua Help with NPC SCRIPT

Rossii

Member
Joined
Mar 27, 2012
Messages
366
Reaction score
6
Location
England
Can somebody give me a script were when you have 50 Christmas tokens (renamed to Tokens) you can goto NPC and trade them in for 10 vip coins??

ill rep
 
vip.xml
LUA:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="NPC" script="vip.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
 <look type="151" head="76" body="53" legs="109" feet="115" addons="3"/>
</npc>

data/npc/scripts
vip.lua
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
        local cycmsg = 'Hello'
        local noimsg = 'You wanna changed your tokens?'
        local deny      = 'Your are sure?' 

    if msgcontains(msg, 'help') or msgcontains(msg, 'trade') then
                selfSay('Me can make {changed}, for changed your tokens..', cid)
       
        elseif msgcontains(msg, 'changed') then
        selfSay('You wanna changed your 50 tokens for 10 vip coins?', cid)
        talkState[talkUser] = 1
       
        elseif talkState[talkUser] == 1 then
                if msgcontains(msg, 'yes') then
                        if doPlayerTakeItem(cid, 2487, 50) == true then  -- 2487 - changed for tokens ID
                                doPlayerAddItem(cid, 5887, 10) ---  changed for ID vipcoins
                                selfSay(cycmsg, cid)
                                talkState[talkUser] = 0
                        else
                                selfSay(noimsg, cid)
                        end
                else
                        selfSay(deny, cid)
                end
                talkState[talkUser] = 0
        end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top