• 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 lotery.

Taifun Patteh

New Member
Joined
Mar 5, 2011
Messages
21
Reaction score
0
Need NPC lotery vials. NPC take 100 vials for scroll, but 20% probably.

thanks for your helps.

sorry bad english!!
 
NPC Sandra lua script

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)            npcHandler:eek:nCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:eek:nCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:eek:nCreatureSay(cid, type, msg)    end
function onThink()                        npcHandler:eek:nThink()                        end
function onPlayerEndTrade(cid)            npcHandler:eek:nPlayerEndTrade(cid)            end
function onPlayerCloseChannel(cid)        npcHandler:eek:nPlayerCloseChannel(cid)        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

--[[ MAGE START 1 addon, female
    <outfit id="3">
        <list gender="0" lookType="138" name="Mage"/>
        <list gender="1" lookType="130" name="Mage"/>
]]
    local sandraStor = 8022
    local getSandraStor = getCreatureStorage(cid, sandraStor)
    local raymond_mission2 = 8043
    local getStorage1 = getCreatureStorage(cid, raymond_mission2)
   
    if doMessageCheck(msg, 'vial') then
        if getSandraStor == 1 then
            selfSay('Would you like to get a lottery ticket instead of the deposit for your vials.', cid)
            talkState[talkUser] = 11
        else
            selfSay('We have a special offer right now for depositing vials. Are you interested in hearing it?', cid)
            talkState[talkUser] = 1
        end
    elseif talkState[talkUser] == 1 and doMessageCheck(msg, 'yes') then
        npcHandler:say('The Premy Island academy has introduced a bonus system. Each time you deposit 100 vials without claiming the money for it, you will receive a lottery ticket. ...', cid)
        npcHandler:say('Some of these lottery tickets will grant you a special potion belt accessory, if you bring the ticket to me. ...', cid, 4000)
        npcHandler:say('If you join the bonus system now, I will ask you each time you are bringing back 100 or more vials to me whether you claim your deposit or rather want a lottery ticket. ...', cid, 8000)
        npcHandler:say('Of course, you can leave or join the bonus system at any time by just asking me for the \'bonus\'. ...', cid, 12000)
        npcHandler:say('Would you like to join the bonus system now?', cid, 16000)
        talkState[talkUser] = 2  
    elseif talkState[talkUser] == 2 and doMessageCheck(msg, 'yes') then
        selfSay('Great! I\'ve signed you up for our bonus for lottery {vial}. From now on, you will have the chance to win the potion belt addon!', cid)
        doCreatureSetStorage(cid, sandraStor, 1)
        talkState[talkUser] = 0  

    elseif talkState[talkUser] == 11 and doMessageCheck(msg, 'yes') then         
        if doPlayerRemoveItem(cid, 7636, 100) or doPlayerRemoveItem(cid, 7635, 100) or doPlayerRemoveItem(cid, 7634, 100) or doPlayerRemoveItem(cid, 2006, 100) or doPlayerRemoveItem(cid, 11396, 100) then
            selfSay('Take this ticket, if you win come back to me and ask about {prize}', cid)
            doPlayerAddItem(cid, 5957, 1)
        else
            selfSay('Sorry you need 100 empty vials to you from the lottery ticket', cid)
        end
        talkState[talkUser] = 0

    elseif doMessageCheck(msg, 'bonus') then
        if getSandraStor == 1 then
            selfSay('Would you like to leave our bonus system?', cid)
            talkState[talkUser] = 4
        else
            selfSay('Would you like to join the bonus system now?', cid)
            talkState[talkUser] = 2
        end
    elseif talkState[talkUser] == 4 and doMessageCheck(msg, 'yes') then
        selfSay('Alright. I removed your name from our list. If you want to join again and get the chance to win a potion belt addon, just ask me for the {bonus}.', cid)
        doCreatureSetStorage(cid, sandraStor, -1)
        talkState[talkUser] = 0  
-- prize
    elseif doMessageCheck(msg, 'prize') and getSandraStor == 1 then
        selfSay('Are you here to claim a prize?', cid)
        talkState[talkUser] = 3
    elseif talkState[talkUser] == 3 and doMessageCheck(msg, 'yes') then
        if isPremium(cid) then
            if doPlayerRemoveItem(cid, 5958, 1) then
                if getPlayerSex(cid) == 0 and(not canPlayerWearOutfit(cid, 138, 1)) then
                    selfSay('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
                    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
                    doPlayerAddOutfit(cid, 138, 1)
                elseif getPlayerSex(cid) == 1 and(not canPlayerWearOutfit(cid, 133, 1)) then
                    selfSay('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
                    doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
                    doPlayerAddOutfit(cid, 133, 1)
                else
                    selfSay('It seems you already have this addon, don\'t you try to mock me son!', cid)
                end
            else
                selfSay('You do not have required items.')
            end
        else
            selfSay('You have no premium acount!', cid)
        end
        talkState[talkUser] = 0

-- no
    elseif(doMessageCheck(msg, 'no') and isInArray({1,2,3,4,5,6,11}, talkState[talkUser])) then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Sandra gives a normal scroll -itemid = 5957
Than you need that in data/actions/actions.xml
HTML:
<action itemid="5957" event="script" value="lotto.lua"/>     <!-- wining lottery ticket -->
and in data/actions/scripts/lotto.lua
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rand = math.random(1,100)
    if item.itemid == 5957 and rand <= 20 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "WINNER, Congratulations you draw a winner lottery ticket!")
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE)
        doTransformItem(item.uid, 5958)
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Try again later, you draw blank.")
        doTransformItem(item.uid, 5956)
    end

    return true
end

rand <= 20 - player have 20% chance

is that for you now ok? :)
 
Last edited:
/data/NPC/script/lotery.lua
code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function onPlayerEndTrade(cid) npcHandler:eek:nPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:eek:nPlayerCloseChannel(cid) 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

--[[ MAGE START 1 addon, female
<outfit id="3">
<list gender="0" lookType="138" name="Mage"/>
<list gender="1" lookType="130" name="Mage"/>
]]
local sandraStor = 8022
local getSandraStor = getCreatureStorage(cid, sandraStor)
local raymond_mission2 = 8043
local getStorage1 = getCreatureStorage(cid, raymond_mission2)

if doMessageCheck(msg, 'vial') then
if getSandraStor == 1 then
selfSay('Would you like to get a lottery ticket instead of the deposit for your vials.', cid)
talkState[talkUser] = 11
else
selfSay('We have a special offer right now for depositing vials. Are you interested in hearing it?', cid)
talkState[talkUser] = 1
end
elseif talkState[talkUser] == 1 and doMessageCheck(msg, 'yes') then
npcHandler:say('The Premy Island academy has introduced a bonus system. Each time you deposit 100 vials without claiming the money for it, you will receive a lottery ticket. ...', cid)
npcHandler:say('Some of these lottery tickets will grant you a special potion belt accessory, if you bring the ticket to me. ...', cid, 4000)
npcHandler:say('If you join the bonus system now, I will ask you each time you are bringing back 100 or more vials to me whether you claim your deposit or rather want a lottery ticket. ...', cid, 8000)
npcHandler:say('Of course, you can leave or join the bonus system at any time by just asking me for the \'bonus\'. ...', cid, 12000)
npcHandler:say('Would you like to join the bonus system now?', cid, 16000)
talkState[talkUser] = 2
elseif talkState[talkUser] == 2 and doMessageCheck(msg, 'yes') then
selfSay('Great! I\'ve signed you up for our bonus for lottery {vial}. From now on, you will have the chance to win the potion belt addon!', cid)
doCreatureSetStorage(cid, sandraStor, 1)
talkState[talkUser] = 0

elseif talkState[talkUser] == 11 and doMessageCheck(msg, 'yes') then
if doPlayerRemoveItem(cid, 7636, 100) or doPlayerRemoveItem(cid, 7635, 100) or doPlayerRemoveItem(cid, 7634, 100) or doPlayerRemoveItem(cid, 2006, 100) or doPlayerRemoveItem(cid, 11396, 100) then
selfSay('Take this ticket, if you win come back to me and ask about {prize}', cid)
doPlayerAddItem(cid, 5957, 1)
else
selfSay('Sorry you need 100 empty vials to you from the lottery ticket', cid)
end
talkState[talkUser] = 0

elseif doMessageCheck(msg, 'bonus') then
if getSandraStor == 1 then
selfSay('Would you like to leave our bonus system?', cid)
talkState[talkUser] = 4
else
selfSay('Would you like to join the bonus system now?', cid)
talkState[talkUser] = 2
end
elseif talkState[talkUser] == 4 and doMessageCheck(msg, 'yes') then
selfSay('Alright. I removed your name from our list. If you want to join again and get the chance to win a potion belt addon, just ask me for the {bonus}.', cid)
doCreatureSetStorage(cid, sandraStor, -1)
talkState[talkUser] = 0
-- prize
elseif doMessageCheck(msg, 'prize') and getSandraStor == 1 then
selfSay('Are you here to claim a prize?', cid)
talkState[talkUser] = 3
elseif talkState[talkUser] == 3 and doMessageCheck(msg, 'yes') then
if isPremium(cid) then
if doPlayerRemoveItem(cid, 5958, 1) then
if getPlayerSex(cid) == 0 and(not canPlayerWearOutfit(cid, 138, 1)) then
selfSay('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
doPlayerAddOutfit(cid, 138, 1)
elseif getPlayerSex(cid) == 1 and(not canPlayerWearOutfit(cid, 133, 1)) then
selfSay('Congratulations! Here, from now on you can wear our lovely potion belt as accessory.', cid)
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_RED)
doPlayerAddOutfit(cid, 133, 1)
else
selfSay('It seems you already have this addon, don\'t you try to mock me son!', cid)
end
else
selfSay('You do not have required items.')
end
else
selfSay('You have no premium acount!', cid)
end
talkState[talkUser] = 0

-- no
elseif(doMessageCheck(msg, 'no') and isInArray({1,2,3,4,5,6,11}, talkState[talkUser])) then
talkState[talkUser] = 0
selfSay('Ok then.', cid)
end
return true
end

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

Where copy this?
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rand = math.random(1,100)
if item.itemid == 5957 and rand <= 20 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "WINNER, Congratulations you draw a winner lottery ticket!")
doSendMagicEffect(fromPosition, CONST_ME_MAGIC_BLUE)
doTransformItem(item.uid, 5958)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Try again later, you draw blank.")
doTransformItem(item.uid, 5956)
end

return true
end
 
Back
Top