• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Help with Bless

bobmateus

New Member
Joined
Aug 7, 2012
Messages
15
Reaction score
0
When the players relogs with bless, this disappears, and the player need to buy again.

Dropbless.lua:
DropBless.lua

function onDeath(cid, corpse, deathList)
function HaveBless(cid)
for i = 1,5 do
if getPlayerBlessing(cid, i) then
return true
end
end
return false
end
if isPlayer(cid) and HaveBless(cid) and getPlayerSkullType(cid) < SKULL_RED then
doCreatureSetDropLoot(cid, false)
end
return true
end

creaturescript.xml:
<event type="death" name="BlessDrop" event="script" value="DropBless.lua"/>


creaturescript/script/login.lua
registerCreatureEvent(cid, "BlessDrop")

Help me please !
 
Here is it:

local bless = {1, 2, 3, 4, 5}
local cost = 80000
function onSay(cid, words, param)
for i = 1, table.maxn(bless) do
if(getPlayerBlessing(cid, bless)) then
doPlayerSendCancel(cid, "Voce ja tem todas as bless.")
return TRUE
end
end

if(doPlayerRemoveMoney(cid, cost) == TRUE) then
for i = 1, table.maxn(bless) do
doPlayerAddBlessing(cid, bless)
end
doCreatureSay(cid, "You are now blessed by the [GOD] Bryaan!" ,19)
doSendMagicEffect(getPlayerPosition(cid), 49)
else
doPlayerSendCancel(cid, "Voce precisa de 80k para a bless.")
end
return TRUE
end
 
Still not the best with LUA, but im pretty sure you cant create a function inside a function
Code:
function onDeath(cid, corpse, deathList)
function HaveBless(cid)

try it like this
LUA:
function onDeath(cid, corpse, deathList)
for i = 1,5 do
if getPlayerBlessing(cid, i) then
return true
end
end
return false
end
function HaveBless(cid)
if isPlayer(cid) and HaveBless(cid) and getPlayerSkullType(cid) < SKULL_RED then
doCreatureSetDropLoot(cid, false)
end
return true
end
 
@UpInSmoke
not so pretty
lua-users wiki: Scope Tutorial
2xdown UpInSmoke:
Code:
local function f()
  local v = 0
  local function get() -- here is second function without 'end' of the first fucn
    return v
  end
  local function set(new_v)
    v = new_v
  end
  return {get=get, set=set}
end
 
Last edited:
Still not the best with LUA, but im pretty sure you cant create a function inside a function
Code:
function onDeath(cid, corpse, deathList)
function HaveBless(cid)

try it like this
LUA:
function onDeath(cid, corpse, deathList)
for i = 1,5 do
if getPlayerBlessing(cid, i) then
return true
end
end
return false
end
function HaveBless(cid)
if isPlayer(cid) and HaveBless(cid) and getPlayerSkullType(cid) < SKULL_RED then
doCreatureSetDropLoot(cid, false)
end
return true
end

doesn't work, when players die, all levels are lost oO
 
Back
Top