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

Lua add money checker

Kawaki69

Member
Joined
Mar 4, 2022
Messages
72
Reaction score
8
Hey, I need to add money check if you have enough money to rebirth for example an 200 from this id 6536 or gold coin to rebirth may some 1 help :)
ty
Lua:
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)
    local reblevel = 700000  -- reborn level
    if(msgcontains(msg, 'rebirth')) then
        selfSay('Are you ready to be reborn and to start a new life?', cid)
    elseif(msgcontains(msg, 'yes')) then
        if player:getLevel() >= reblevel then
            player:doRebirth()
            player:remove()
        else
            selfSay('Come back when your level is '..reblevel..'.')
        end       
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Lua:
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)
    local reblevel = 700000  -- reborn level
    if(msgcontains(msg, 'rebirth')) then...
Lua:
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)
    local reblevel = 700000  -- reborn level
    if(msgcontains(msg, 'rebirth')) then
        selfSay('Are you ready to be reborn and to start a new life?', cid)
    elseif(msgcontains(msg, 'yes')) then
        if player:getLevel() >= reblevel then
if player:getTotalMoney() >= 200 then
player:removeTotalMoney(200)
            player:doRebirth()
            player:remove()
else
selfSay('Come back when you have enough money.')
        else
            selfSay('Come back when your level is '..reblevel..'.')
        end       
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Lua:
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)
    local reblevel = 700000  -- reborn level
    if(msgcontains(msg, 'rebirth')) then
        selfSay('Are you ready to be reborn and to start a new life?', cid)
    elseif(msgcontains(msg, 'yes')) then
        if player:getLevel() >= reblevel then
if player:getTotalMoney() >= 200 then
player:removeTotalMoney(200)
            player:doRebirth()
            player:remove()
else
selfSay('Come back when you have enough money.')
        else
            selfSay('Come back when your level is '..reblevel..'.')
        end      
    end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thank you buddy 😘
 
Back
Top