• 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 The Gambling Man, the interactive dicer

RockeTBunnYz

Trainee in progress
Joined
Jan 21, 2015
Messages
137
Reaction score
7
Location
sweden
It's better to test and see if it works. Then if it does not work, politely ask if someone could help make it work and of course post the errors/bugs.

The reason I say this is because what I got out of your post was:
"Hey I am too lazy to copy and paste this script into my server to see if it works, could you do it for me and tell me if it works so I can do it myself once you confirm it is a possibility."
I do apologize if I was mistaken in that assumption however I do not feel I was alone in that thinking as in nearly 2 days the only responses you received were trolls.

i dont ask others to do it i ask maybe if other that have the same tfs tested it. i just ask and i always test it by myself anyway...
 
OP
Evan

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,020
Solutions
1
Reaction score
1,004
Location
United States
I can update this someday for the following reasons:
  • First post is a mess, need to wrap with code tags now.
  • This is almost 2 years old, TFS 1.X has changed SO MUCH over the years, I can literally slice the code in half now.
  • People have requested to have it very similar to the popular dice bot in Tibia (the one with confetti every second and ectoplasm food, etc).
 

Xarly

Member
Joined
Mar 9, 2015
Messages
360
Reaction score
20
I can update this someday for the following reasons:
  • First post is a mess, need to wrap with code tags now.
  • This is almost 2 years old, TFS 1.X has changed SO MUCH over the years, I can literally slice the code in half now.
  • People have requested to have it very similar to the popular dice bot in Tibia (the one with confetti every second and ectoplasm food, etc).
nice nice! lets go an dupdate it haha it will be th ebest
 

tarantonio

Old School Player
Joined
Jun 21, 2009
Messages
823
Solutions
1
Reaction score
224
I can update this someday for the following reasons:
  • First post is a mess, need to wrap with code tags now.
  • This is almost 2 years old, TFS 1.X has changed SO MUCH over the years, I can literally slice the code in half now.
  • People have requested to have it very similar to the popular dice bot in Tibia (the one with confetti every second and ectoplasm food, etc).
Pls use code tag!
 

xx Kami xx

Retired.
Joined
Dec 29, 2012
Messages
509
Reaction score
20
I can update this someday for the following reasons:
  • First post is a mess, need to wrap with code tags now.
  • This is almost 2 years old, TFS 1.X has changed SO MUCH over the years, I can literally slice the code in half now.
  • People have requested to have it very similar to the popular dice bot in Tibia (the one with confetti every second and ectoplasm food, etc).
works fine for me, players behind me cant say h/l to fuck it up! also im using TFS 1.0
 

Jknot

Member
Joined
Feb 18, 2008
Messages
145
Reaction score
13
Location
South Carolina
Anyone have this running one tfs 1.1 im using tfs 1.1 and cannot get the npc to load or spawn even though he shows up in map editor i get this console error
on start up anyone have an ideas how i can fix this?



Q8Ql2N.png
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,675
Solutions
182
Reaction score
3,466
Anyone have this running one tfs 1.1 im using tfs 1.1 and cannot get the npc to load or spawn even though he shows up in map editor i get this console error
on start up anyone have an ideas how i can fix this?



Q8Ql2N.png
change the :eek: emoticon to :0nThink

@Evan what about an update to at least the topic? xD
 

Blaggo

New Member
Joined
Oct 23, 2014
Messages
10
Reaction score
1
@Jknot
In dice_gamble.lua... If you replace:
Code:
 local npc = getNpcCid()
with:
Code:
 local npc = Npc(getNpcCid())
And replace:
Code:
 local position = {x = getNpcPos().x+2, y = getNpcPos().y, z = getNpcPos().z}
with:
Code:
 local position = npc:getPosition() + {x = 2, y = 0, z = 0}

I got these errors to stop showing up in TFS 1.1, but the NPC still does not work. He doesn't respond to anything, but at least there's no errors.
 

Jknot

Member
Joined
Feb 18, 2008
Messages
145
Reaction score
13
Location
South Carolina
@Jknot
In dice_gamble.lua... If you replace:
Code:
 local npc = getNpcCid()
with:
Code:
 local npc = Npc(getNpcCid())
And replace:
Code:
 local position = {x = getNpcPos().x+2, y = getNpcPos().y, z = getNpcPos().z}
with:
Code:
 local position = npc:getPosition() + {x = 2, y = 0, z = 0}

I got these errors to stop showing up in TFS 1.1, but the NPC still does not work. He doesn't respond to anything, but at least there's no errors.
dang wish we could figure this out i loved skynet dicer on r/t Someone has to know how we can fix this anybody? @Limos maybe?
 

raf

Active Member
Joined
Jan 10, 2011
Messages
260
Reaction score
37
Location
Warsaw, PL
Does anyone know how to merge anti-trash into npc lua file? So it's dynamic, and not hard-coded in movements?
 

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,531
Solutions
1
Reaction score
83
Location
Portugal
I managed to fix all the console errors but the NPC doesnt react at all...

I can't find any issue in the script...
But in my guess the lines broke are 94 and 96?
Cuz if player was getting msg that player says something would happen...

Code:
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
function onPlayerEndTrade(cid)                 npcHandler: OnPlayerEndTrade(cid)             end
function onPlayerCloseChannel(cid)             npcHandler: OnPlayerCloseChannel(cid)         end

local function delayMoneyRemoval(delayRemovedItem)
delayRemovedItem:remove(delayRemovedItem:getCount())
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
table_left_pos:sendMagicEffect(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(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
elseif (roll == 2 and random_rollval >= 4) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
else
addEvent(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_BLOCKHIT)
end
npc:say(string.format("%s rolled a %d.", npc:getName(), random_rollval), TALKTYPE_ORANGE_1, false, 0, npc:getPosition())
else
addEvent(doCreateItem, 100, 2160, cc_count, table_middle_pos)
addEvent(doCreateItem, 150, 2152, pc_count, table_middle_pos)
npc:say("The minimum wager is 5K and the maximum wager is 300K.", TALKTYPE_SAY, false, 0, npc:getPosition())
end
return true
end

function creatureSayCallback(cid, type, msg)
-- NPC userdata instance
local npc = Npc(getNpcCid())

-- Participating player userdata instance
local position = npc:getPosition() + {x = 2, y = 0, z = 0}
position.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(position).uid

-- Game table position userdata instances
local table_left_pos = Position(1004, 986, 5)
local table_middle_pos = Position(1005, 986, 5)

-- Search for coins on the left and middle tables and create item userdata instances
local table_left_cc_uid = getTileItemById(table_left_pos, 2160).uid
local table_middle_cc_uid = getTileItemById(table_middle_pos, 2160).uid
local table_left_pc_uid = getTileItemById(table_left_pos, 2152).uid
local table_middle_pc_uid = getTileItemById(table_middle_pos, 2152).uid

-- Other variables
local cc_count = 0
local pc_count = 0
local ROLL, LOW, HIGH = 0, 1, 2

if (player_uid ~= 0) then
player = Player(player_uid)
if ((msgcontains(string.lower(msg), 'high') and (player:isPlayer() and player:getId() == cid))) then
ROLL = HIGH
elseif ((msgcontains(string.lower(msg), 'low') and (player:isPlayer() and player:getId() == cid))) then
ROLL = LOW
else
return false
end
if (table_middle_cc_uid ~= 0) then
table_middle_cc = Item(table_middle_cc_uid)
cc_count = table_middle_cc:getCount()
table_middle_cc:moveTo(table_left_pos)
addEvent(delayMoneyRemoval, 300, table_middle_cc)
end
if (table_middle_pc_uid ~= 0) then
table_middle_pc = Item(table_middle_pc_uid)
pc_count = table_middle_pc:getCount()
table_middle_pc:moveTo(table_left_pos)
addEvent(delayMoneyRemoval, 300, table_middle_pc)
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)
 
Last edited:

Tarek1337

Legendary OT User
Joined
Jun 9, 2012
Messages
3,581
Solutions
3
Reaction score
1,163
Location
Sweden
Find this
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

And replace it with:

Code:
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
function onPlayerEndTrade(cid) npcHandler: onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler: onPlayerCloseChannel(cid) end
 
Top