Postado Agosto 5, 2016 8 anos Ao jogar o dinheiro entre os dois depots você deverá dizer H ou L, acontece que se você perde ele demora um segundinho pra tirar do dinheiro do meio e tem como o player pegar novamente este dinheiro... Gostaria de mudar para que assim que o player jogar ele já tirar o dinheiro do meio e caso o player ganhe dê o dobro para ele... Tem como me ajudar por favor? Rep+ SEGUE SCRIPT.LUA: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local config = { bonusPercent = 2, minimumBet = 100, maximumBet = 10000000 } local storeMoneyAmount = 0 -- Do not touch [We store the amount cash which got betted here] local ITEM_BLOCKING = 8046 local function getMoneyAmount(position) local moneyAmount = 0 for _, item in ipairs(Tile(position):getItems()) do local itemId = item:getId() if itemId == ITEM_GOLD_COIN then moneyAmount = moneyAmount + item.type elseif itemId == ITEM_PLATINUM_COIN then moneyAmount = moneyAmount + item.type * 1000 elseif itemId == ITEM_CRYSTAL_COIN then moneyAmount = moneyAmount + item.type * 10000 end end return moneyAmount end local function handleMoney(cid, position, bonus) local npc = Npc(cid) if not npc then return end -- Lets remove the cash which was betted for _, item in ipairs(Tile(position):getItems()) do if isInArray({ITEM_GOLD_COIN, ITEM_PLATINUM_COIN, ITEM_CRYSTAL_COIN, ITEM_BLOCKING}, item:getId()) then item:remove() end end -- We lost, no need to continue if bonus == 0 then npc:say("You lost!", TALKTYPE_SAY) position:sendMagicEffect(CONST_ME_POFF) return end -- Cash calculator local goldCoinAmount = storeMoneyAmount * bonus local crystalCoinAmount = math.floor(goldCoinAmount / 10000) goldCoinAmount = goldCoinAmount - crystalCoinAmount * 10000 local platinumCoinAmount = math.floor(goldCoinAmount / 100) goldCoinAmount = goldCoinAmount - platinumCoinAmount * 100 if goldCoinAmount ~= 0 then Game.createItem(ITEM_GOLD_COIN, goldCoinAmount, position) end if platinumCoinAmount ~= 0 then Game.createItem(ITEM_PLATINUM_COIN, platinumCoinAmount, position) end if crystalCoinAmount ~= 0 then Game.createItem(ITEM_CRYSTAL_COIN, crystalCoinAmount, position) end position:sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE)) npc:say("You Win!", TALKTYPE_SAY) end local function startRollDice(cid, position, number) for i = 5792, 5797 do local dice = Tile(position):getItemById(i) if dice then dice:transform(5791 + number) break end end local npc = Npc(cid) if npc then npc:say(string.format("%s rolled a %d", npc:getName(), number), TALKTYPE_MONSTER_SAY) end end local function executeEvent(cid, dicePosition, number, moneyPosition, bonus) local npc = Npc(cid) if not npc then return end if getMoneyAmount(moneyPosition) ~= storeMoneyAmount then npc:say("Where is the money?!", TALKTYPE_SAY) return end -- Roll Dice addEvent(startRollDice, 400, cid, dicePosition, number) dicePosition:sendMagicEffect(CONST_ME_CRAPS) -- Handle Money addEvent(handleMoney, 600, cid, moneyPosition, bonus) end local function creatureSayCallback(cid, type, msg) if not isInArray({"h", "l"}, msg) then -- Ignore other replies return false end -- Npc Variables local npc = Npc() local npcPosition = npc:getPosition() -- Check if player stand in position local playerPosition = Position(npcPosition.x + 2, npcPosition.y, npcPosition.z) local topCreature = Tile(playerPosition):getTopCreature() if not topCreature then npc:say("Please go stand next to me.", TALKTYPE_SAY) playerPosition:sendMagicEffect(CONST_ME_TUTORIALARROW) playerPosition:sendMagicEffect(CONST_ME_TUTORIALSQUARE) return false end -- Make sure also the player who stand there, is the one who is betting. To keep out people from disturbing if topCreature:getId() ~= cid then return false end -- High or Low numbers local rollType = 0 if msgcontains(msg, "l") then rollType = 1 elseif msgcontains(msg, "h") then rollType = 2 else return false end -- Check money Got betted local moneyPosition = Position(npcPosition.x + 1, npcPosition.y -1, npcPosition.z) storeMoneyAmount = getMoneyAmount(moneyPosition) if storeMoneyAmount < config.minimumBet or storeMoneyAmount > config.maximumBet then npc:say(string.format("You can only bet min: %d and max: %d gold coins.", config.minimumBet, config.maximumBet), TALKTYPE_SAY) return false end -- Money is betted, lets block them from getting moved // This is one way, else we can set actionid, on the betted cash. Game.createItem(ITEM_BLOCKING, 1, moneyPosition) -- Roll Number local rollNumber = math.random(6) -- Win or Lose local bonus = 0 if rollType == 1 and isInArray({1, 2, 3}, rollNumber) then bonus = config.bonusPercent elseif rollType == 2 and isInArray({4, 5, 6}, rollNumber) then bonus = config.bonusPercent end -- Money handle and roll dice addEvent(executeEvent, 100, npc:getId(), Position(npcPosition.x, npcPosition.y - 1, npcPosition.z), rollNumber, moneyPosition, bonus) return true end function onThink() -- Anti trash local npcPosition = Npc():getPosition() local moneyPosition = Position(npcPosition.x + 1, npcPosition.y - 1, npcPosition.z) for _, item in ipairs(Tile(moneyPosition):getItems()) do local itemId = item:getId() if not isInArray({ITEM_GOLD_COIN, ITEM_PLATINUM_COIN, ITEM_CRYSTAL_COIN, ITEM_BLOCKING}, itemId) and ItemType(itemId):isMovable() then item:remove() end end local dicePosition = Position(npcPosition.x, npcPosition.y - 1, npcPosition.z) for _, item in ipairs(Tile(dicePosition):getItems()) do local itemId = item:getId() if not isInArray({5792, 5793, 5794, 5795, 5796, 5797}, itemId) and ItemType(itemId):isMovable() then item:remove() end end npcHandler:onThink() end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) Editado Agosto 5, 2016 8 anos por Leo Zanin atualizando (veja o histórico de edições)
Postado Agosto 5, 2016 8 anos O Script que eu uso é diferente e não me lembro de acontecer esse erro, se quiser testar: 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 local function delayMoneyRemoval(item, pos) doRemoveItem(getTileItemById(pos, item).uid) return true end local function placeMoney(amount, table_middle_pos) local remain = amount local crystal_coins = 0 local platinum_coins = 0 if (math.floor(amount / 10000) >= 1) then crystal_coins = math.floor(amount / 10000) remain = remain - crystal_coins * 10000 end if ((remain / 100) >= 1) then platinum_coins = remain / 100 end addEvent(doCreateItem, 550, 2152, platinum_coins, table_middle_pos) addEvent(doCreateItem, 600, 2160, crystal_coins, table_middle_pos) end local function rollDice(roll, cc_count, pc_count, table_left_pos, table_middle_pos, npc) local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797} local random_rollval = math.random(1,6) local total_g = (10000 * cc_count) + (100 * pc_count) local prize_percent = 0.8 -- 80% if ((total_g) <= 300000 and (total_g) >= 5000) then doSendMagicEffect(table_left_pos, CONST_ME_CRAPS) for _, itemId in pairs(dice_ids) do if(getTileItemById(table_left_pos, itemId).uid > 0) then doTransformItem(getTileItemById(table_left_pos, itemId).uid, dice_ids[random_rollval]) end end if (roll == 1 and random_rollval <= 3) then placeMoney(total_g + (total_g * prize_percent), table_middle_pos) addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN) addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN) addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0) elseif (roll == 2 and random_rollval >= 4) then placeMoney(total_g + (total_g * prize_percent), table_middle_pos) addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN) addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN) addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0) else addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_BLOCKHIT) addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_BLOCKHIT) addEvent(doCreatureSay, 500, npc, "Better luck next time.", TALKTYPE_SAY, false, 0) end doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, table_left_pos) else addEvent(doCreateItem, 100, 2160, cc_count, table_middle_pos) addEvent(doCreateItem, 150, 2152, pc_count, table_middle_pos) doCreatureSay(npc, "The minimum wager is 5K and the maximum wager is 300K.", TALKTYPE_SAY, false, 0) end return true end function creatureSayCallback(cid, type, msg) -- NPC userdata instance local npc = getNpcCid() -- Game table position userdata instances local table_left_pos = {x = 32260, y = 32274, z = 12} -- Pos da frente do Npc onde gira o dado local table_middle_pos = {x = 32261, y = 32274, z = 12} -- Pos do meio onde vai o dinheiro -- Search for coins on the left and middle tables and create item userdata instances local table_middle_cc = getTileItemById(table_middle_pos, 2160) local table_middle_pc = getTileItemById(table_middle_pos, 2152) -- Other variables local cc_count = 0 local pc_count = 0 local ROLL, LOW, HIGH = 0, 1, 2 posplayer = {x=32262, y=32275, z=12} -- Pos onde o player precisa estar local ppos = getPlayerPosition(cid) if ppos.x == posplayer.x and ppos.y == posplayer.y then if isInArray({"H", "HIGH", "high", "h"}, msg) then ROLL = HIGH elseif isInArray({"L", "LOW", "l", "low"}, msg) then ROLL = LOW else return false end if (table_middle_cc.uid ~= 0) then cc_count = table_middle_cc.type doTeleportThing(table_middle_cc.uid, table_left_pos) addEvent(delayMoneyRemoval, 300, 2160, table_left_pos) end if (table_middle_pc.uid ~= 0) then pc_count = table_middle_pc.type doTeleportThing(table_middle_pc.uid, table_left_pos) addEvent(delayMoneyRemoval, 300, 2152, table_left_pos) end addEvent(rollDice, 500, ROLL, cc_count, pc_count, table_left_pos, table_middle_pos, npc) else return false end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Ajudei? REP+ DotA Event (TFS 1.x) => Clique Aqui Skype: rike.sexy
Postado Agosto 5, 2016 8 anos Autor Agradeço mas esse ai tem vários bugs um deles é multiplicar seus kk's... Se você usa no seu servidor cuidado @CirocReturn Editado Agosto 5, 2016 8 anos por Leo Zanin atualizando (veja o histórico de edições)
Postado Agosto 10, 2016 8 anos Em 05/08/2016 ás 15:49, Leo Zanin disse: Agradeço mas esse ai tem vários bugs um deles é multiplicar seus kk's... Se você usa no seu servidor cuidado @CirocReturn Ta com bug este sistema? Me explica eu uso ele!
Postado Agosto 10, 2016 8 anos Autor 12 horas atrás, Rodrigo0lg disse: Ta com bug este sistema? Me explica eu uso ele! Eu expliquei no início do tópico amigo...
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.