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

CreatureEvent Bless check

Shadow Dan

Sh4dowDan
Joined
Jun 5, 2010
Messages
344
Reaction score
88
Location
Poland
Tested on TFS 0.4 - works

data/creaturescripts/scripts/blessCheck.lua
Lua:
function onLogin(cid)

	if(getPlayerBlessing(cid, 1)) then 
		first = "yes"
	else
		first = "no"
	end
	if(getPlayerBlessing(cid, 2)) then 
		second = "yes"
	else
		second = "no"
	end
	if(getPlayerBlessing(cid, 3)) then 
		third = "yes"
	else
		third = "no"
	end
	if(getPlayerBlessing(cid, 4)) then 
		fourth = "yes"
	else
		fourth = "no"
	end
	if(getPlayerBlessing(cid, 5)) then 
		fifth = "yes"
	else
		fifth = "no"
	end

	doPlayerSendTextMessage(cid,20,'Your blessings: 1='.. first ..' 2='.. second ..' 3='.. third ..' 4='.. fourth ..' 5='.. fifth ..'')

	return true
end

data/creaturescripts/creaturescripts.xml
XML:
<event type="login" name="BlessCheck" event="script" value="blessCheck.lua"/>
data/creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, "BlessCheck")



yes = have blessing
no = no bless

v1.0 by zbizu
Lua:
function onLogin(cid)

local BLESSINGS, amount, missing = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}, 0, {}

	for i = 1, 5 do
		if getPlayerBlessing(cid, i) then amount = (amount+1) else table.insert(missing, BLESSINGS[i]) end
	end
	if amount == 1 then s='' else s='s' end
	
		doPlayerSendTextMessage(cid,20,'You have '..amount..' blessing'..s..' ('.. amount*20 ..'%).\nMissing blessings: '..table.concat(missing, ", "))
	return true
end
 
Last edited:
Looks interesting, here is version based on yours:

Lua:
function onLogin(cid)
local BLESSINGS, amount, missing = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}, 0, {}
for i = 1, 5 do
if getPlayerBlessing(cid, i) then amount = (amount+1) else table.insert(missing, BLESSINGS[i]) end
end
if amount == 1 then s='' else s='s' end
doPlayerSendTextMessage(cid,20,'You have '..amount..' blessing'..s..' ('.. amount*20 ..'%).\nMissing blessings: '..table.concat(missing, ", "))
return true
end

output:
14:27 You have 2 blessings (40%).
Missing blessings: Wisdom of Solitude, Spiritual Shielding, Embrace of Tibia
 
Last edited:
Code:
--Script by Nevix
function onLogin(cid)
    if(getPlayerBlessing(cid, 1)) then 
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are NOT blessed! Type: !bless (cost 50k)")		
end
    return true
end
 
This script checking just first bless.
I fixed bug on my server, command !bless was giving just first blessing and i found that bug after adding script blesscheck.
 
Looks interesting, here is version based on yours:

Lua:
function onLogin(cid)
local BLESSINGS, amount, missing = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia"}, 0, {}
for i = 1, 5 do
if getPlayerBlessing(cid, i) then amount = (amount+1) else table.insert(missing, BLESSINGS[I]) end
end
if amount == 1 then s='' else s='s' end
doPlayerSendTextMessage(cid,20,'You have '..amount..' blessing'..s..' ('.. amount*20 ..'%).\nMissing blessings: '..table.concat(missing, ", "))
return true
end

output:[/I]

Hi I was trying to use this for TFS 1.0 so I converted some stuff. I keep getting on console:
Invalid value stack traceback:
[c]: at 0x7ff7624261c0
[c]: in function 'concat'

So if I just remove the last part of table.concat and it works, but obviously it doesn't show the missing blessings.

Here what I have so far:
Code:
function onLogin(cid)
local BLESSINGS, amount, missing = {"Wisdom of Solitude", "Spark of the Phoenix", "Fire of the Suns", "Spiritual Shielding", "Embrace of Tibia", "Twist of Fate"}, 0, {}
local bless = {1, 2, 3, 4, 5, 6}
local player = Player(cid)

for i = 1, 6 do
if player:hasBlessing(bless[i]) then amount = (amount+1) else table.insert(missing, BLESSINGS) end
end

if amount == 1 then s='' else s='s' end
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have "..amount.." blessing"..s.." (".. amount*16.6 .."%).\nMissing blessings: "..table.concat(missing, ", "))
return true
end

Thanks in advance
 
Back
Top