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

Scripter Casino npc / Trainer Stamina Regen 0.4

tatee

New Member
Joined
Mar 21, 2009
Messages
12
Reaction score
1
I'm looking for a scripter. Im using OTX, so 0.4

1. I want a decent blackjack system, high/low, even/odd. It could be one npc or several npcs, I don't mind.

2. Regain Stamina while online, same rate as when you are offline. Only while at trainers though. It could be either while attacking a training monk or while stepping on a tile, what ever is more simple.

TFS 1.2 Trainer stamina regen.

Something like this ^

If you are a reputable member // have a scripting service or some one vouching for you I'll pay first.

Thanks,
M~
 
qKzpDEU.png

Code:
<npc name="Cassino" script="data/npc/scripts/cassino_dice.lua" walkinterval="0" floorchange="0" skull="black" shield="5">
<health now="100" max="100"/>
<look type="132" head="17" body="54" legs="114" feet="0" addons="3"/>
</npc>
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

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) <= 1000000 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, "Voce Ganhou!", 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, "Voce Ganhou!", 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, "Mais sorte na proxima vez.", 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, "A aposta minima e5K e a maxima 1000K.", 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 = 77, y = 26, z = 7}
    local table_middle_pos = {x = 78, y = 26, 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)

for the stamina one, you can simply sawp the functions to tfs 0.4 functions
 
Code:
    <movevent type="StepIn" actionid="25000" event="script" value="staminatile.lua"/>
    <movevent type="StepOut" actionid="25000" event="script" value="staminatile.lua"/>

Lua:
STAMINA_MESSAGE = "You won 5 minutes of stamina."
STAMINA_TIME = 60 * 1000
STAMINA_EFFECT = 12
STAMINA_ADD = 5

function event(cid)
    if isPlayer(cid) then
        doPlayerAddStamina(cid, STAMINA_ADD)       
        doPlayerSendTextMessage(cid, 27, STAMINA_MESSAGE)
        eventCheck = addEvent(event, STAMINA_TIME, cid)
    end
end

function onStepIn(cid, item, position, fromPosition, pos)
    if isPlayer(cid) then
    doPlayerSendTextMessage(cid, 27, "Every 1 minute of training you gain 5 minutes of stamina.")
    eventCheck = addEvent(event, STAMINA_TIME, cid)
    end
    return true
end

function onStepOut(cid, item, position, fromPosition)
    if isPlayer(cid) then
        doPlayerSendTextMessage(cid, 27, "You left the training area.")
        stopEvent(eventCheck)
    end
    return true
end
 
Thank you both for your help, I really appreciate it. I'm still looking for that blackjack NPC, if someone is still looking for the job.
 
How do you decide where he will spawn? Or will you spawn him in manually? Can't find a POS x/y/z in the code?
 
Thank you both for your help, I really appreciate it. I'm still looking for that blackjack NPC, if someone is still looking for the job.

nothing happens
Lua:
16:58 Every 1 minute of training you gain 5 minutes of stamina.
16:58 You won 5 minutes of stamina.

but no add stamina
 
Back
Top