Lottery system (help) !

Discussion in 'Support' started by Glidarn, Jan 22, 2012.

  1. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    check post 8
     

    Attached Files:

    Last edited: Jan 23, 2012
  2. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
  3. Cykotitan

    Cykotitan Experienced G'

    Joined:
    Nov 4, 2008
    Messages:
    16,897
    Likes Received:
    797
    Best Answers:
    1
    /thread
     
  4. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    ye i don't understand, i changed it as should be.
     
  5. Cykotitan

    Cykotitan Experienced G'

    Joined:
    Nov 4, 2008
    Messages:
    16,897
    Likes Received:
    797
    Best Answers:
    1
    itemid:12608 itemcount: 1?
     
  6. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    yes, i did something but now he only getting this
     
  7. Cykotitan

    Cykotitan Experienced G'

    Joined:
    Nov 4, 2008
    Messages:
    16,897
    Likes Received:
    797
    Best Answers:
    1
    since you won't post the script, i'll have to guess that your libs (primarily 000-constant.lua) are outdated
     
  8. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    troll, anyway i removed he's char he made a new char i guess it will work now but i'm trying to add a lottery system wich has some errors and i'm kinda stuck on the npc error lotternpc.jpg

    Code (Lua):
    1. -- Credits for inspiration and ideas to Azi, <a href="http://forum.otsmedia.eu/archive/index.php/thread-876.html" target="_blank">http://forum.otsmedia.eu/archive/ind...hread-876.html</a>
    2. local keywordHandler = KeywordHandler:new()
    3. local npcHandler = NpcHandler:new(keywordHandler)
    4. NpcSystem.parseParameters(npcHandler)
    5. local talkState = {}
    6. function onCreatureAppear(cid)
    7.     npcHandler:onCreatureAppear(cid)
    8. end
    9. function onCreatureDisappear(cid)
    10.     npcHandler:onCreatureDisappear(cid)
    11. end
    12. function onCreatureSay(cid, type, msg)
    13.     npcHandler:onCreatureSay(cid, type, msg)
    14. end
    15. function onThink()
    16.     npcHandler:onThink()
    17. end
    18. function creatureSayCallback(cid, type, msg)
    19.     if(not(npcHandler:isFocused(cid))) then
    20.         return false
    21.     end
    22.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    23.     if(msgcontains(msg, "lottery")) then
    24.         npcHandler:say("Welcome to our {lottery}. The lottery is a chance to get rich really quick! All you need to do is to {buy} a {ticket}, state four numbers from 1 to " .. lotteryConfig.maxNumber .. " and wait for the draw.", cid)
    25.     elseif(msgcontains(msg, "buy") or msgcontains(msg, "ticket")) then
    26.         npcHandler:say("Do you want to buy a ticket for a lottery?", cid)
    27.         talkState[talkUser] = 1
    28.     elseif(msgcontains(msg, "yes")) then
    29.         if(talkState[talkUser] == 1) then
    30.             if(db.getResult("SELECT * FROM `lottery` WHERE `player_id` = " .. getPlayerGUID(cid) .. ""):getID() < 1) then
    31.                 npcHandler:say("Please state four numbers from 1 to " .. lotteryConfig.maxNumber .. ". You can always state random numbers saying 'random'. Remember you cannot state two exact numbers.", cid)
    32.                 talkState[talkUser] = 2
    33.             else
    34.                 npcHandler:say("You've already bought a ticket for this lottery.", cid)
    35.                 talkState[talkUser] = 0
    36.             end
    37.         end
    38.     elseif(msgcontains(msg, "no")) then
    39.         if(talkState[talkUser] > 0) then
    40.             npcHandler:say("Then no.", cid)
    41.             talkState[talkUser] = 0
    42.         end
    43.     elseif(talkState[talkUser] == 2) then
    44.         local numbers = {}
    45.         if(string.lower(msg) == "random") then
    46.             repeat
    47.                 randomNumber = math.random(1, lotteryConfig.maxNumber)
    48.                 if(not(isInArray(numbers, randomNumber))) then
    49.                     table.insert(numbers, randomNumber)
    50.                 end
    51.             until table.maxn(numbers) == lotteryConfig.numbersCount
    52.         else
    53.             if(string.explode(msg, ", ")) then
    54.                 if(table.maxn(string.explode(msg, ", ")) == lotteryConfig.numbersCount) then
    55.                     for i = 1, lotteryConfig.numbersCount do
    56.                         if(tonumber(string.explode(msg, ", ")[i]) < 1 or tonumber(string.explode(msg, ", ")[i]) > lotteryConfig.maxNumber or isInArray(numbers, string.explode(msg, ", ")[i])) then
    57.                             npcHandler:say("The combination of numbers is wrong.", cid)
    58.                             talkState[talkUser] = 0
    59.                             return true
    60.                         end
    61.                         table.insert(numbers, string.explode(msg, ", ")[i])
    62.                     end
    63.                 else
    64.                     npcHandler:say("You must state atleast " .. lotteryConfig.numbersCount .. " numbers.", cid)
    65.                     return true
    66.                 end
    67.             else
    68.                 npcHandler:say("You can state numbers only.", cid)
    69.                 return true
    70.             end
    71.         end
    72.         local output = ""
    73.         for i = 1, lotteryConfig.numbersCount do
    74.             if(i ~= lotteryConfig.numbersCount) then
    75.                 output = output .. numbers[i] .. ", "
    76.             else
    77.                 output = output .. numbers[i]
    78.             end
    79.         end
    80.         if(getPlayerMoney(cid) < lotteryConfig.ticketPrice) then
    81.             npcHandler:say("You don't have enought money.", cid)
    82.             talkState[talkUser] = 0
    83.         else
    84.             db.executeQuery("INSERT INTO `lottery` (`player_id`, `numbers`) VALUES (" .. getPlayerGUID(cid) .. ", '" .. tostring(output) .. "')")
    85.             npcHandler:say("Your numbers are " .. output .. ". I wish you good luck and big winnings!", cid)
    86.             talkState[talkUser] = 0
    87.             doPlayerRemoveMoney(cid, lotteryConfig.ticketPrice)
    88.         end
    89.     end
    90.     return true
    91. end
    92. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    93. npcHandler:addModule(FocusModule:new())

    http://otland.net/f82/teckmans-lottery-system-139287/
     
    Last edited: Jan 23, 2012
  9. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    i would really need help with it since wanted to update this with tomorrows server save
     
  10. Evan

    Evan A splendid one to behold Premium User

    Joined:
    May 6, 2009
    Messages:
    7,013
    Likes Received:
    913
    Best Answers:
    0
  11. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
  12. Evan

    Evan A splendid one to behold Premium User

    Joined:
    May 6, 2009
    Messages:
    7,013
    Likes Received:
    913
    Best Answers:
    0
    Well, the error you have is saying that lotteryConfig does not exist.
    So, from the link I show, you need to add that table.
     
  13. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
  14. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    i added the queries but
    then the error is coming up -.-
     
  15. Evan

    Evan A splendid one to behold Premium User

    Joined:
    May 6, 2009
    Messages:
    7,013
    Likes Received:
    913
    Best Answers:
    0
    What error?
     
  16. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    the on the pictures wich i attached on previous post
     
  17. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
    please, i really need this and the zombie thing since i'm updating the map tomorrow :/

    lottery
    troll, anyway i removed he's char he made a new char i guess it will work now but i'm trying to add a lottery system wich has some errors and i'm kinda stuck on the npc error View attachment 12036

    Code (Lua):
    1. -- Credits for inspiration and ideas to Azi, <a href="http://forum.otsmedia.eu/archive/index.php/thread-876.html" target="_blank">http://forum.otsmedia.eu/archive/ind...hread-876.html</a>
    2. local keywordHandler = KeywordHandler:new()
    3. local npcHandler = NpcHandler:new(keywordHandler)
    4. NpcSystem.parseParameters(npcHandler)
    5. local talkState = {}
    6. function onCreatureAppear(cid)
    7.     npcHandler:onCreatureAppear(cid)
    8. end
    9. function onCreatureDisappear(cid)
    10.     npcHandler:onCreatureDisappear(cid)
    11. end
    12. function onCreatureSay(cid, type, msg)
    13.     npcHandler:onCreatureSay(cid, type, msg)
    14. end
    15. function onThink()
    16.     npcHandler:onThink()
    17. end
    18. function creatureSayCallback(cid, type, msg)
    19.     if(not(npcHandler:isFocused(cid))) then
    20.         return false
    21.     end
    22.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    23.     if(msgcontains(msg, "lottery")) then
    24.         npcHandler:say("Welcome to our {lottery}. The lottery is a chance to get rich really quick! All you need to do is to {buy} a {ticket}, state four numbers from 1 to " .. lotteryConfig.maxNumber .. " and wait for the draw.", cid)
    25.     elseif(msgcontains(msg, "buy") or msgcontains(msg, "ticket")) then
    26.         npcHandler:say("Do you want to buy a ticket for a lottery?", cid)
    27.         talkState[talkUser] = 1
    28.     elseif(msgcontains(msg, "yes")) then
    29.         if(talkState[talkUser] == 1) then
    30.             if(db.getResult("SELECT * FROM `lottery` WHERE `player_id` = " .. getPlayerGUID(cid) .. ""):getID() < 1) then
    31.                 npcHandler:say("Please state four numbers from 1 to " .. lotteryConfig.maxNumber .. ". You can always state random numbers saying 'random'. Remember you cannot state two exact numbers.", cid)
    32.                 talkState[talkUser] = 2
    33.             else
    34.                 npcHandler:say("You've already bought a ticket for this lottery.", cid)
    35.                 talkState[talkUser] = 0
    36.             end
    37.         end
    38.     elseif(msgcontains(msg, "no")) then
    39.         if(talkState[talkUser] > 0) then
    40.             npcHandler:say("Then no.", cid)
    41.             talkState[talkUser] = 0
    42.         end
    43.     elseif(talkState[talkUser] == 2) then
    44.         local numbers = {}
    45.         if(string.lower(msg) == "random") then
    46.             repeat
    47.                 randomNumber = math.random(1, lotteryConfig.maxNumber)
    48.                 if(not(isInArray(numbers, randomNumber))) then
    49.                     table.insert(numbers, randomNumber)
    50.                 end
    51.             until table.maxn(numbers) == lotteryConfig.numbersCount
    52.         else
    53.             if(string.explode(msg, ", ")) then
    54.                 if(table.maxn(string.explode(msg, ", ")) == lotteryConfig.numbersCount) then
    55.                     for i = 1, lotteryConfig.numbersCount do
    56.                         if(tonumber(string.explode(msg, ", ")[i]) < 1 or tonumber(string.explode(msg, ", ")[i]) > lotteryConfig.maxNumber or isInArray(numbers, string.explode(msg, ", ")[i])) then
    57.                             npcHandler:say("The combination of numbers is wrong.", cid)
    58.                             talkState[talkUser] = 0
    59.                             return true
    60.                         end
    61.                         table.insert(numbers, string.explode(msg, ", ")[i])
    62.                     end
    63.                 else
    64.                     npcHandler:say("You must state atleast " .. lotteryConfig.numbersCount .. " numbers.", cid)
    65.                     return true
    66.                 end
    67.             else
    68.                 npcHandler:say("You can state numbers only.", cid)
    69.                 return true
    70.             end
    71.         end
    72.         local output = ""
    73.         for i = 1, lotteryConfig.numbersCount do
    74.             if(i ~= lotteryConfig.numbersCount) then
    75.                 output = output .. numbers[i] .. ", "
    76.             else
    77.                 output = output .. numbers[i]
    78.             end
    79.         end
    80.         if(getPlayerMoney(cid) < lotteryConfig.ticketPrice) then
    81.             npcHandler:say("You don't have enought money.", cid)
    82.             talkState[talkUser] = 0
    83.         else
    84.             db.executeQuery("INSERT INTO `lottery` (`player_id`, `numbers`) VALUES (" .. getPlayerGUID(cid) .. ", '" .. tostring(output) .. "')")
    85.             npcHandler:say("Your numbers are " .. output .. ". I wish you good luck and big winnings!", cid)
    86.             talkState[talkUser] = 0
    87.             doPlayerRemoveMoney(cid, lotteryConfig.ticketPrice)
    88.         end
    89.     end
    90.     return true
    91. end
    92. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
    93. npcHandler:addModule(FocusModule:new())

    http://otland.net/f82/teckmans-lottery-system-139287/


    Solved the Zombie event but i really need help with the lottery system
     
    Last edited: Jan 24, 2012
  18. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
  19. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0
  20. Glidarn

    Glidarn Member

    Joined:
    May 9, 2009
    Messages:
    971
    Likes Received:
    13
    Best Answers:
    0

Share This Page

Loading...