Ir para conteúdo
  • Cadastre-se

(Resolvido)Pedido NPC Cassino


Ir para solução Resolvido por Pandawan.,

Posts Recomendados

  • Solução

Olá amigo, teste esse script, se apresentar algum erro me avise!

Na pasta NPC você cria o arquivo: Cassino (ou nome do NPC a sua escolha)
 

Citar

<npc name="Cassino" script="data/npc/scripts/cassino_dice.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="494" head="38" body="87" legs="46" feet="46" addons="3"/>
</npc>

A outfit pode ser alterada ao seu gosto

Na pasta NPC>Scripts você cria: cassino_dice.lua (ou nome do script a sua escolha)
Aqui lembre de mudar o LOCAL TABLE !!!
 

Citar

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
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()
 
	-- Participating player userdata instance
	local position = {x = getNpcPos().x+2, y = getNpcPos().y, z = getNpcPos().z}
	position.stackpos = STACKPOS_TOP_CREATURE
	local player_uid = getThingfromPos(position).uid
 
	-- Game table position userdata instances
	local table_left_pos = {x = 120, y = 50, z = 7}
	local table_middle_pos = {x = 121, y = 50, z = 7}
 
	-- 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
 
	if (player_uid ~= 0) then
		if ((msgcontains(string.lower(msg), 'high') or msgcontains(string.lower(msg), 'h')) and (isPlayer(player_uid) and player_uid == cid)) then
			ROLL = HIGH
		elseif ((msgcontains(string.lower(msg), 'low') or msgcontains(string.lower(msg), 'l')) and (isPlayer(player_uid) and player_uid == cid)) 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)

 

Editado por Pandawan. (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
Em 16/02/2016 18:11:50, Pandawan. disse:

Olá amigo, teste esse script, se apresentar algum erro me avise!

Na pasta NPC você cria o arquivo: Cassino (ou nome do NPC a sua escolha)
 

A outfit pode ser alterada ao seu gosto

Na pasta NPC>Scripts você cria: cassino_dice.lua (ou nome do script a sua escolha)
Aqui lembre de mudar o LOCAL TABLE !!!
 

 

 

 

 

Amigo o npc aparece certinho, porem ele não funciona, quando se fala high ou low ele apenas repete a mensagem de no min 5k max 300k, e não pega o dinheiro, e aparece esse erro na distro

 

Sem título.png

Link para o post
Compartilhar em outros sites
5 horas atrás, 77mateus77 disse:
Spoiler

 

Amigo o npc aparece certinho, porem ele não funciona, quando se fala high ou low ele apenas repete a mensagem de no min 5k max 300k, e não pega o dinheiro, e aparece esse erro na distro

 

Sem título.png

 

 


Você tem que alterar os valores do 00121 / 00050 / 007 no script, como eu disse anteriormente, pra o sqm que você quer que ele pegue/dê o dinheiro.

 

 
Spoiler

 


-- Game table position userdata instances
	local table_left_pos = {x = 120, y = 50, z = 7}
	local table_middle_pos = {x = 121, y = 50, z = 7}


Se no seu OT o DP do NPC fica, por exemplo, em 32500 12850 7 faça as alterações ficando:
Table Left Pos = posição do DP do NPC
Table Right Pos = tábua do meio do DP

 


-- Game table position userdata instances
	local table_left_pos = {x = 32500, y = 12850, z = 7}
	local table_middle_pos = {x = 32501, y = 12850, z = 7}

 

 

 

Editado por Pandawan. (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
13 horas atrás, vankk disse:

Qual TFS você está usando?

1.2

9 horas atrás, Pandawan. disse:


Você tem que alterar os valores do 00121 / 00050 / 007 no script, como eu disse anteriormente, pra o sqm que você quer que ele pegue/dê o dinheiro.

 



 
  Ocultar conteúdo

 



-- Game table position userdata instances
	local table_left_pos = {x = 120, y = 50, z = 7}
	local table_middle_pos = {x = 121, y = 50, z = 7}


Se no seu OT o DP do NPC fica, por exemplo, em 32500 12850 7 faça as alterações ficando:
Table Left Pos = posição do DP do NPC
Table Right Pos = tábua do meio do DP

 



-- Game table position userdata instances
	local table_left_pos = {x = 32500, y = 12850, z = 7}
	local table_middle_pos = {x = 32501, y = 12850, z = 7}

 

 

Vou testar e edito se der certo -- perfeito funcionou certinho, obrigado rep+

 

 

 

 

Editado por 77mateus77 (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Tente utilizar isso, um script feito para 1.2

 

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 * 100
        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({"high", "low"}, 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, "low") then
        rollType = 1
    elseif msgcontains(msg, "high") 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 por vankk (veja o histórico de edições)

discord.pngDiscord: vankk #7765

Precisando de ajuda? Entre em contato comigo via Discord.

 

Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.

Link para o post
Compartilhar em outros sites
3 horas atrás, vankk disse:

Tente utilizar isso, um script feito para 1.2

 


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 * 100
        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({"high", "low"}, 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, "low") then
        rollType = 1
    elseif msgcontains(msg, "high") 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)

Obrigado vankk mas aquele que ele passou ja funcionou, so faltava alterar os valores coomo ele disse

 

 

 

 

Link para o post
Compartilhar em outros sites

Eu sei, mas eu gosto de utilizar scripts com funções atualizadas, e não com funções antigas, hahah.. mas whatever.

discord.pngDiscord: vankk #7765

Precisando de ajuda? Entre em contato comigo via Discord.

 

Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.

Link para o post
Compartilhar em outros sites
2 minutos atrás, vankk disse:

Eu sei, mas eu gosto de utilizar scripts com funções atualizadas, e não com funções antigas, hahah.. mas whatever.

entendo, você entende sobre chatchannels tbm nessa tfs 1.2? eu preocurei preocurei mas não consigo encontra a solução pra um problema, acabei de criar um post, da uma olhada la e ve se você entende sobre isso pra poder me ajudar http://www.tibiaking.com/forum/topic/67766-ajuda-com-canal-help/#comment-388757 Valeu! 

Link para o post
Compartilhar em outros sites

 

16 horas atrás, vankk disse:

Eu sei, mas eu gosto de utilizar scripts com funções atualizadas, e não com funções antigas, hahah.. mas whatever.

 

 

Bom Dia @vankk teria algum atualizado para o tfs 0.4 do @Fir3element ?

Aproveitando a deicha alguma arena svargrong atualizada tbm? a minha só nao aparece o tp o resto aparentemente ta ok era do tfs 0.3.7 tentei migrar mais o bixo nao abre o tp qndo morre

Link para o post
Compartilhar em outros sites
  • 4 weeks later...
Em 16/02/2016 at 18:11, Pandawan. disse:

Olá amigo, teste esse script, se apresentar algum erro me avise!

Na pasta NPC você cria o arquivo: Cassino (ou nome do NPC a sua escolha)
 

A outfit pode ser alterada ao seu gosto

Na pasta NPC>Scripts você cria: cassino_dice.lua (ou nome do script a sua escolha)
Aqui lembre de mudar o LOCAL TABLE !!!
 

 

 

 

 

aee blz tentei usar no meu serv o npc não aparece

Link para o post
Compartilhar em outros sites
  • 2 years later...

@Pandawan. entao, o meu ta dando erro, tipo, o npc aparece normalmente mais ele nao fala comigo e nao pega a grana, eu ja configurei a posiçao 3 vezes ta tudo certo. eu jogo o dinheiro e falo l L low Low LOW h H high HIGH mais ele nao faz nada e nao da nenhum erro na distro, meu servidor é 8.6 distro 2.6

 

The OTX Server Version: (2.6) - Codename: (SCARETALE)
Compiled with GNU C++ version 3.4.5 (mingw special) for arch 32 Bits at Nov 21 2016 17:47:43

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Bagon
      Bom, hoje venho trazer á vocês um sistema de Pet System DIFERENCIADO de alguns presentes no fórum. Este sistema tem diversos comandos diferenciados, como: 
       
      !pet nomedopet este comando irá sumonar o pet. 
      !remove irá remover o pet.
      !fale eu sou lindo o pet falará "eu sou lindo"
      !conversar o pet irá conversar com vc. 
       
      Então sem mais delongas vamos ao script.
       
      OBS: SCRIPT TESTADO SOMENTE EM TFS 0.4/0.3, e este script foi feito com a intenção de ser vendido no site do ot ou em poderá usar como quest usando o item selecionado como premio. fique ao seu critério.
       
      Primeiro vá até a pasta talkaction/script e crie um arquivo chamado petsystem.lua, depois coloque o seguinte script:
       
       
      Agora em talkactions/talkactions.xml adicione a seguinte tag:
       
      <talkaction words="!pet;!remove;!fale;!conversar" event="script" value="petsystem.lua" />  
      EXPLICAÇÂO:
      As partes em Negrito, são os pets. Você pode alterar ou criar monstros para fazer eles como pets. (Recomendo criar um monstro para que seja somente pet.)
       
      Exemplo: ["dog"]= {stor=78552},      
       
       
      Lembrando que é necessário mudar esta parte no script do monstro colocado a cima.
       
      <flag attackable="1" /> para :
       
      <flag attackable="0" />  
      agora vá em action/script e crie um arquivo chamado pet com o seguinte script:
       
       
      e vá em action.xml e adiciona a seguinte tag:
       
      <action itemid="10063" script="pet.lua"/> Explicação: Na tag da action o itemid é o item que deverá ser usado para ganhar a storage 78552, e assim podera sumonar o monstro com esta storage.
       
                                              
                                                         CRIE UMA ACTION COM A TAG A CIMA PARA CADA MONSTRO COLOCADO NA TALKACTION,
                                                         BASTA VC ALTERAR A STORAGE DO SCRIPT DA ACTION
                                                         EXEMPLO: em action altere as storage que estão em vermelho, como mostra abaixo
       
                                                              if getPlayerStorageValue(cid, 78552) < 1 then
                                                              setPlayerStorageValue(cid, 78552, 1)
       
                                                         aonde tem 78552 altere para 78553 que no caso é a storage do cyclops escolhido lá no script da talkaction
                                                         e assim susecivelmente.
       
       
       
      CREDITOS:
      Mulizeu
      Smartbox
      Bagon 
       
    • Por ambrozii0
      Gostaria de fazer um pedido de um NPC de Task progressiva,

      Ele iniciaria dando missões para level 8 para caçar Troll, Rotworm e Ghoul.
       
      No level 30 liberaria: Cyclops, Dragon e Wyrm... e assim em diante se puder deixar comentado eu faço as criaturas na sequencia dos leveis seguintes.
       
      O jogador pode fazer as tasks dos leveis anteriores mesmo que já tenha ultrapassado o level do próximo nível de task.
       
      E o jogador ao terminar a missão poderia escolher a recompensa em gold ou experiência. As tasks podem se repetir sem problema, mas apenas pode pegar uma de cada vez.
       
      Ao finalizar todas as tasks o jogador ganha uma montaria.
       
      Minha versão de cliente é 12.91
      Versão da Canary 2.6.1
      Não sei qual o TFS do meu servidor.
    • Por Imperius
      Olá, pessoal! Acabei encontrando um script que tinha feito a um tempo atrás. Estou compartilhando aqui para quem quiser usar ou melhorar.
       
      É bem parecido com os outros sistemas de roleta, igual deste tópico: https://tibiaking.com/forums/topic/101557-action-cassino-roleta-de-items/
       
      Como funciona?
       
      O "Treasure Chest" é um item custom, onde o jogador têm a possibilidade de ganhar itens raros ou bem meia boca. Tudo dependerá da sorte.
       
      O jogador precisa tacar o treasure chest na bancada e acionar a alavanca. O treasure chest irá se transformar em vários itens de forma randômica no qual o jogador poderá ou não ganhar. No final, apenas um item é entregue ao jogador.
       
      Para entender melhor o seu funcionamento, segue o GIF abaixo:
       

       
       
      em data > actions > actions.xml
       
       
      em data > actions > scripts > crie um arquivo chamado leverTreasureChest.lua
       
       
      no banco de dados do servidor, adicione o seguinte código em "SQL":
       
       
       

      Também estou disponibilizando uma página PHP, para quem quiser usar no site do servidor. Na página tem informações sobre o funcionamento, quais são os possíveis prêmios e a lista de jogadores que ganharam os itens raros.
       

       
       
      Espero ter ajudado de alguma forma! : )
       
      treasure_chest.php
    • Por Garou
      QUIZ







      Fala, grande reino! Tudo beleza?

      Eu estava aqui a deriva, sem nada para fazer, quando um colega me chamou no msn e pediu para eu revisar um código que ele havia feito para um NPC. A função era bem simples, o tal NPC iria fazer perguntas ao jogador que devia responder-las corretamente, caso errasse, duas criaturas configuráveis iriam aparecer.

      Quando eu dei uma olhada no código, tomei um grande susto, era algo caótico, tudo embaralhado. Se você quer dar uma olhada, tenha certeza de ter um coração forte.



      --[[ NPC de Perguntas e Respostas Criado por Bruno Lopes / Lpz &#169; 2011 TibiaKing ]]-- local focuses = {} local talk_start = 0 local topic = {} local var = 0 local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } function onCreatureSay(cid, type, msg) local msg = msg:lower() or "" if getNpcDistanceTo(cid) > 3 then return false end if doMessageCheck(msg, {"hi", "hello"}) and not(isFocused(cid, focuses)) then selfSay("Hello, ".. getCreatureName(cid) ..". Can you answer my questions? heh...", cid) addFocus(cid, focuses) selfFocus(cid) topic[cid] = 100 talk_start = os.clock() elseif doMessageCheck(msg, {"hi", "hello"}) and #focuses ~= 0 then selfSay("Sorry, ".. getCreatureName(cid) ..". I am talking with another person, wait!", cid) end if doMessageCheck(msg, {"bye", "farewell", "goodbye"}) and isFocused(cid, focuses) then selfSay("Bye-bye, hehe!", cid) removeFocus(cid, focuses) end if topic[cid] == 100 then if doMessageCheck(msg, "yes") then selfSay("To start my challenge, just say {ready}. I will ask you some questions.", cid) topic[cid] = 1 elseif doMessageCheck(msg, "no") then selfSay("Huh? Why are you here then?", cid) removeFocus(cid, focuses) topic[cid] = 0 end elseif topic[cid] == 1 then if var == 0 then if doMessageCheck(msg, "ready") then var = 1 selfSay(quiz[var][1], cid) end elseif var >= 1 then if var <= #quiz then if doMessageCheck(msg, quiz[var][2]) then selfSay("CORRECT!", cid) doPlayerAddMoney(cid, prize.question) var = var+1 if var > #quiz then selfSay("CONGRATULATIONS! YOU HAVE FINISHED ALL QUESTIONS!", cid) doPlayerAddMoney(cid, prize.all) else selfSay(quiz[var][1], cid) end else selfSay("YOU HAVE WRONG MY QUESTION! GUARDS, COME HERE!", cid) var = 0 topic[cid] = 0 removeFocus(cid, focuses) for i = 1, monster[2] do doCreateMonster(monster[1], getNpcPos()) end end end end end return true end function onThink() for _, cid in ipairs(focuses) do if isPlayer(cid) and isFocused(cid, focuses) then if os.clock() > (talk_start + 180) then talk_start = 0 selfSay("Hmph!") closeShopWindow(cid) removeFocus(cid, focuses) elseif getNpcDistanceTo(cid) > 3 then talk_start = 0 selfSay("How Rude!") closeShopWindow(cid) removeFocus(cid, focuses) end end end lookAtFocus(focuses) end Bom, eu fiz o arquivo .lua que você iria associar a algum npc de seu servidor, deixo o arquivo .xml por sua conta. Como é um NPC que faz perguntas, você pode configurar o seu NPC do jeito que você quiser, com as perguntas que você quiser. Veja abaixo como proceder: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"} } Para adicionar novas perguntas, basta você colocar uma vírgula na última linha e criar uma nova linha conforme o modelo: local quiz = { [1] = {"What is the ring of mana?", "energy ring"}, [2] = {"Who sells addons?", "raphael"}, [3] = {"PERGUNTA", "RESPOSTA"}, [4] = {"PERGUNTA", "RESPOSTA"} } Há também algumas outras configurações básicas para você fazer, as criaturas que irão aparecer caso o jogador erre a pergunta e a quantidade. Também você pode configurar a quantidade de dinheiro que o jogador ganha quando acerta uma pergunta e a quantidade de dinheiro do prêmio final. local monster = {"Orc", 2} local prize = { question = 100, all = 10000 } OBSERVAÇÕES Para evitar quaisquer erros no script, substitua o conteúdo de npc.lua em data/npc/lib por este que estou passando abaixo:



      É isso aê, galerinha do tibiaKing!

      Até o próximo tópico.
    • Por Codex NG
      Sorry I don't speak spanish so you will have to bare with me.
       
      This is a new way for people to create npc's which use different types of currency, rather than a coming up with different items to trade with the npc or trying to edit the npc modules this method simplifies everything by providing the npc with a npc currency id.
       
      All this npc currency id is, is a storage value.. pretty simple eh?
      If the npc doesn't have a currency id then it will use the normal currency e.g. gold, plat, cc etc..
       
      I originally posted this on otland, but fuck them xD
       
      Using Lailene here you can see she has a currency attribute with id of 123456
      <?xml version="1.0" encoding="UTF-8"?> <npc name="Lailene" currency="123456" script="lailene.lua" walkinterval="2000" floorchange="0" speechbubble="2"> <health now="100" max="100"/> <look type="279" head="114" body="94" legs="113" feet="114" addons="0"/> </npc>  
      Now any player who has a storage value of 123456 can purchase things from her shop provided they have enough value stored within the storage, similar to having money in the bank.
      The money or in this case the storage value is added and removed from the player in real time.
       
      Lets get to the code
       
      game.cpp
      Find this
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this.
      bool Game::removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (cylinder == nullptr) { return false; } if (money == 0) { return true; } uint32_t currencyId = 0; Player* player; if (Creature* creature = cylinder->getCreature()) { if (Player* p = creature->getPlayer()) { currencyId = p->getNpcCurrencyId(); player = p; } } if (!currencyId) { std::vector<Container*> containers; std::multimap<uint32_t, Item*> moneyMap; uint64_t moneyCount = 0; for (size_t i = cylinder->getFirstIndex(), j = cylinder->getLastIndex(); i < j; ++i) { Thing* thing = cylinder->getThing(i); if (!thing) { continue; } Item* item = thing->getItem(); if (!item) { continue; } Container* container = item->getContainer(); if (container) { containers.push_back(container); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } size_t i = 0; while (i < containers.size()) { Container* container = containers[i++]; for (Item* item : container->getItemList()) { Container* tmpContainer = item->getContainer(); if (tmpContainer) { containers.push_back(tmpContainer); } else { const uint32_t worth = item->getWorth(); if (worth != 0) { moneyCount += worth; moneyMap.emplace(worth, item); } } } } if (moneyCount < money) { return false; } for (const auto& moneyEntry : moneyMap) { Item* item = moneyEntry.second; if (moneyEntry.first < money) { internalRemoveItem(item); money -= moneyEntry.first; } else if (moneyEntry.first > money) { const uint32_t worth = moneyEntry.first / item->getItemCount(); const uint32_t removeCount = (money / worth) + 1; addMoney(cylinder, (worth * removeCount) - money, flags); internalRemoveItem(item, removeCount); break; } else { internalRemoveItem(item); break; } } } else { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { return false; } player->addStorageValue(currencyId, value - money); } return true; } Next find this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) Replace the whole function with this
      void Game::addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags /*= 0*/) { if (money == 0) { return; } if (Creature* creature = cylinder->getCreature()) { if (Player* player = creature->getPlayer()) { if(uint32_t currencyId = player->getNpcCurrencyId()){ int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); return; } } } uint32_t crystalCoins = money / 10000; money -= crystalCoins * 10000; while (crystalCoins > 0) { const uint16_t count = std::min<uint32_t>(100, crystalCoins); Item* remaindItem = Item::CreateItem(ITEM_CRYSTAL_COIN, count); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } crystalCoins -= count; } uint16_t platinumCoins = money / 100; if (platinumCoins != 0) { Item* remaindItem = Item::CreateItem(ITEM_PLATINUM_COIN, platinumCoins); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } money -= platinumCoins * 100; } if (money != 0) { Item* remaindItem = Item::CreateItem(ITEM_GOLD_COIN, money); ReturnValue ret = internalAddItem(cylinder, remaindItem, INDEX_WHEREEVER, flags); if (ret != RETURNVALUE_NOERROR) { internalAddItem(cylinder->getTile(), remaindItem, INDEX_WHEREEVER, FLAG_NOLIMIT); } } }  
      npc.cpp
      Look for this
      pugi::xml_attribute attr; if ((attr = npcNode.attribute("speed"))) { baseSpeed = pugi::cast<uint32_t>(attr.value()); } else { baseSpeed = 100; } Right underneath that you are going to place this.
      if ((attr = npcNode.attribute("currency"))) { currency = pugi::cast<uint32_t>(attr.value()); }  
      npc.h
      Look for this
      bool isPushable() const final { return walkTicks > 0; } Place this right underneath
      uint32_t getCurrencyId() const { return currency; } Look for this
      uint32_t walkTicks; Place this right underneath
      uint32_t currency;  
      player.cpp
      Find this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) Replace that function with this
      void Player::openShopWindow(Npc* npc, const std::list<ShopInfo>& shop) { shopItemList = shop; sendShop(npc); sendSaleItemList(npc); } Next find this
      bool Player::updateSaleShopList(const Item* item) Replace that function with this
      bool Player::updateSaleShopList(const Item* item) { uint16_t itemId = item->getID(); if (itemId != ITEM_GOLD_COIN && itemId != ITEM_PLATINUM_COIN && itemId != ITEM_CRYSTAL_COIN) { auto it = std::find_if(shopItemList.begin(), shopItemList.end(), [itemId](const ShopInfo& shopInfo) { return shopInfo.itemId == itemId && shopInfo.sellPrice != 0; }); if (it == shopItemList.end()) { const Container* container = item->getContainer(); if (!container) { return false; } const auto& items = container->getItemList(); return std::any_of(items.begin(), items.end(), [this](const Item* containerItem) { return updateSaleShopList(containerItem); }); } } if (client) { client->sendSaleItemList(shopOwner, shopItemList); } return true; } Next you are going to look for
      uint64_t Player::getMoney() const Now right underneath that function you are going to place these.
      uint64_t Player::getMoney(Npc* npc) const { uint64_t cash; setNpcCurrencyId(npc); uint32_t currencyId = getNpcCurrencyId(); if (currencyId) { int32_t value; getStorageValue(currencyId, value); cash = (uint64_t)value; } else { cash = getMoney(); } return cash; } void Player::setNpcCurrencyId(Npc* npc) const{ currencyId = npc->getCurrencyId(); } uint32_t Player::getNpcCurrencyId() const { return currencyId; }  
      player.h
      Look for this
      uint64_t getMoney() const; Place this right underneath
      uint64_t getMoney(Npc*) const; void setNpcCurrencyId(Npc*) const; uint32_t getNpcCurrencyId() const; Find this
      void sendShop(Npc* npc) const { if (client) { client->sendShop(npc, shopItemList); } } Place this right underneath
      void sendSaleItemList(Npc* npc) const { if (client) { client->sendSaleItemList(npc, shopItemList); } } Find this
      uint32_t manaMax; Place this right underneath
      mutable uint32_t currencyId;  
      protocolgame.cpp
      Now find this function
      void ProtocolGame::sendSaleItemList(const std::list<ShopInfo>& shop) Place this right underneath
      void ProtocolGame::sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop) { NetworkMessage msg; msg.addByte(0x7B); msg.add<uint64_t>(player->getMoney(npc)); std::map<uint16_t, uint32_t> saleMap; if (shop.size() <= 5) { // For very small shops it's not worth it to create the complete map for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } uint32_t count = player->getItemTypeCount(shopInfo.itemId, subtype); if (count > 0) { saleMap[shopInfo.itemId] = count; } } } else { // Large shop, it's better to get a cached map of all item counts and use it // We need a temporary map since the finished map should only contain items // available in the shop std::map<uint32_t, uint32_t> tempSaleMap; player->getAllItemTypeCount(tempSaleMap); // We must still check manually for the special items that require subtype matches // (That is, fluids such as potions etc., actually these items are very few since // health potions now use their own ID) for (const ShopInfo& shopInfo : shop) { if (shopInfo.sellPrice == 0) { continue; } int8_t subtype = -1; const ItemType& itemType = Item::items[shopInfo.itemId]; if (itemType.hasSubType() && !itemType.stackable) { subtype = (shopInfo.subType == 0 ? -1 : shopInfo.subType); } if (subtype != -1) { uint32_t count; if (!itemType.isFluidContainer() && !itemType.isSplash()) { count = player->getItemTypeCount(shopInfo.itemId, subtype); // This shop item requires extra checks } else { count = subtype; } if (count > 0) { saleMap[shopInfo.itemId] = count; } } else { std::map<uint32_t, uint32_t>::const_iterator findIt = tempSaleMap.find(shopInfo.itemId); if (findIt != tempSaleMap.end() && findIt->second > 0) { saleMap[shopInfo.itemId] = findIt->second; } } } } uint8_t itemsToSend = std::min<size_t>(saleMap.size(), std::numeric_limits<uint8_t>::max()); msg.addByte(itemsToSend); uint8_t i = 0; for (std::map<uint16_t, uint32_t>::const_iterator it = saleMap.begin(); i < itemsToSend; ++it, ++i) { msg.addItemId(it->first); msg.addByte(std::min<uint32_t>(it->second, std::numeric_limits<uint8_t>::max())); } writeToOutputBuffer(msg); }  
      protocolgame.h
      Find this
      void sendSaleItemList(const std::list<ShopInfo>& shop); Place this right underneath
      void sendSaleItemList(Npc* npc, const std::list<ShopInfo>& shop);  
      luascript.cpp
      Find
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerAddMoney(lua_State* L) { // player:addMoney(money[, currencyId]) uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); Player* player = getUserdata<Player>(L, 1); if (player) { if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); player->addStorageValue(currencyId, value + money); } else { g_game.addMoney(player, money); } pushBoolean(L, true); } else { lua_pushnil(L); } return 1; } Next find this function which should be right below it.
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) Replace that whole function with this
      int LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) { // player:removeMoney(money[, currencyId]) Player* player = getUserdata<Player>(L, 1); if (player) { uint64_t money = getNumber<uint64_t>(L, 2); uint32_t currencyId = getNumber<uint32_t>(L, 3); if (currencyId) { int32_t value; player->getStorageValue(currencyId, value); if (value < money) { pushBoolean(L, false); return 1; } player->addStorageValue(currencyId, value - money); pushBoolean(L, true); } else { pushBoolean(L, g_game.removeMoney(player, money)); } } else { lua_pushnil(L); } return 1; }  
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo