Ir para conteúdo
  • 0

NPC Cassino


brendoonh

Pergunta

6 respostass a esta questão

Posts Recomendados

  • 0

Cara eu tenho esse não sei se é do seu gosto.

Spoiler
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {} function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)          npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                                              npcHandler:onThink() end local function delayMoneyRemoval(item, pos)        doRemoveItem(getTileItemById(pos, item).uid)        return trueend 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 trueend function creatureSayCallback(cid, type, msg)        -- NPC userdata instance        local npc = getNpcCid()         -- Game table position userdata instances        local table_left_pos = {x = 32237, y = 32190, z = 15} -- Pos da frente do Npc onde gira o dado        local table_middle_pos = {x = 32237, y = 32191, z = 15} -- 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=32236, y=32192, z=15} -- 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 trueend npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

 

Link para o comentário
Compartilhar em outros sites

  • 0
2 horas atrás, danihcv disse:

Já deu uma pesquisada pra ver se encontrava?

Sim, achei um, porém ele parece tá bugado, as vezes não da o dinheiro certo...

 

1 hora atrás, Sirarcken disse:

Cara eu tenho esse não sei se é do seu gosto.

  Mostrar conteúdo oculto
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {} function onCreatureAppear(cid)                          npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)                       npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)          npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                                              npcHandler:onThink() end local function delayMoneyRemoval(item, pos)        doRemoveItem(getTileItemById(pos, item).uid)        return trueend 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 trueend function creatureSayCallback(cid, type, msg)        -- NPC userdata instance        local npc = getNpcCid()         -- Game table position userdata instances        local table_left_pos = {x = 32237, y = 32190, z = 15} -- Pos da frente do Npc onde gira o dado        local table_middle_pos = {x = 32237, y = 32191, z = 15} -- 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=32236, y=32192, z=15} -- 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 trueend npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())

 

 

Vou testar..

Link para o comentário
Compartilhar em outros sites

  • 0
3 horas atrás, Sirarcken disse:

Qualquer erro avisa, só que meu tfs 1.2

Aqui, estou com 1 aqui, ta funfando tfs 0.4 , porem ele tem 1 bug... Quando eu aposto 180k e ganho, ele devolve 4k em vez de 400k.. Sabe arrumar isso???

 

Queria tambem mudar o valor da aposta minima e maxima.. Sabe fazer isso??

 

Script...

Spoiler

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, "Acertou mizeravi!", 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, "Errou mizeravi!", 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 = 147, y = 57, z = 7} -- Pos da frente do Npc onde gira o dado

        local table_middle_pos = {x = 148, y = 57, z = 7} -- 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=149, y=56, z=7} -- 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())

 

Link para o comentário
Compartilhar em outros sites

  • 0

Então cara, estou no cel, e essa semana não vou para minha casa, e esses errinhos que eu arrumo e meio que tipo na cagada kkkk,nao entendo quase nada de script, so oque eu deduzo, se vc não conseguir resolver até sexta eu do meu jeito é te ajudo blz.

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...