• 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!

how i can make rolling with dice

You can find this in any TFS datapack.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if(fromPosition.x ~= CONTAINER_POSITION) then
     doSendMagicEffect(fromPosition, CONST_ME_CRAPS)
   end

   local value = math.random(5792, 5797)
   doTransformItem(item.uid, value)
   doCreatureSay(cid, getCreatureName(cid) .. ' rolled a ' .. value - 5791 .. '.', TALKTYPE_ORANGE_1)
   return true
end
 
i loled and wondered at the same time, why it is
Code:
math.random(5792, 5797)
and
Code:
' .. value - 5791 .. '
haha

why not
Code:
math.random(1, 6)
and
Code:
' .. value .. '
 
i loled and wondered at the same time, why it is
Code:
math.random(5792, 5797)
and
Code:
' .. value - 5791 .. '
haha

why not
Code:
math.random(1, 6)
and
Code:
' .. value .. '
You have to edit the transformitem code too, otherwise the dice look wouldn't change.


And this is how it is coded in TFS 1.0
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   local dice = Item(item.uid)
   local dicePosition = dice:getPosition()
   local value = math.random(1, 6)
   local isInGhostMode = player:isInGhostMode()

   dicePosition:sendMagicEffect(CONST_ME_CRAPS, isInGhostMode and player)

   local spectators = Game.getSpectators(dicePosition, false, true, 3, 3)
   for _, pid in ipairs(spectators) do
     player:say(player:getName() .. " rolled a " .. value .. ".", TALKTYPE_MONSTER_SAY, isInGhostMode, pid, dicePosition)
   end

   dice:transform(5791 + value)
   return true
end
 
You have to edit the transformitem code too, otherwise the dice look wouldn't change.


And this is how it is coded in TFS 1.0
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   local player = Player(cid)
   local dice = Item(item.uid)
   local dicePosition = dice:getPosition()
   local value = math.random(1, 6)
   local isInGhostMode = player:isInGhostMode()

   dicePosition:sendMagicEffect(CONST_ME_CRAPS, isInGhostMode and player)

   local spectators = Game.getSpectators(dicePosition, false, true, 3, 3)
   for _, pid in ipairs(spectators) do
     player:say(player:getName() .. " rolled a " .. value .. ".", TALKTYPE_MONSTER_SAY, isInGhostMode, pid, dicePosition)
   end

   dice:transform(5791 + value)
   return true
end
ok, now i got it :) and it explains all
 
Back
Top Bottom