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

blessing book

Gregor

New Member
Joined
Feb 29, 2008
Messages
770
Reaction score
3
Location
UK/POLAND
HELLO!
I want add to this script getPlayerBlessing np. if you want use this book and you have all blessings you cant use it.

Code:
function onUse(cid, item, frompos, item2, topos)
 
if doPlayerRemoveItem(cid,2160,6) == 1 then
doPlayerAddBlessing(cid, 1)
doPlayerAddBlessing(cid, 2)
doPlayerAddBlessing(cid, 3)
doPlayerAddBlessing(cid, 4)
doPlayerAddBlessing(cid, 5)
doCreatureSay(cid, "The Magic book has blessed you.", TALKTYPE_ORANGE_1)
doSendMagicEffect(topos,12)
else
doPlayerSendCancel(cid, "You need 6 crystal coin to use The Magic Bless Book.")
end
 
return 1
end

Thanks a lot!
 
Just use a storageValue? ;P

Code:
function onUse(cid, item, frompos, item2, topos)
 
 local STORAGEVALUE = [COLOR=Red][B]CHANGE[/B][/COLOR]
 
    if getPlayerStorageValue(STORAGEVALUE) == 1 then    
        if doPlayerRemoveItem(cid,2160,6) == 1 then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doCreatureSay(cid, "The Magic book has blessed you.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(topos,12)
            setPlayerStorageValue(cid,STORAGEVALUE,1)
        else
            doPlayerSendCancel(cid, "You need 6 crystal coin to use The Magic Bless Book.")
        end
    else
        doPlayerSendCancel(cid,'You have already been blessed by the book')
    end    
return 1
end
And then add this to your playerdeath.lua, just above the last "end"

Code:
   if getPlayerStorageValue([B][COLOR=Red]CHANGE[/COLOR][/B]) == 1 then
        setPlayerStorageValue(cid,[B][COLOR=Red]CHANGE[/COLOR][/B],1)
   end
Change CHANGEs to whatever value you want to use. But remember, it has to be the same value in both scripts. ;)
 
Code:
[26/08/2008  19:31:01] Lua Script Error: [CreatureScript Interface] 
[26/08/2008  19:31:01] data/creaturescripts/scripts/playerdeath.lua:onDeath

and

Code:
[26/08/2008  19:28:53] Lua Script Error: [Action Interface] 
[26/08/2008  19:28:53] data/actions/scripts/bless.lua:onUse

[26/08/2008  19:28:53] luaGetPlayerStorageValue(). Player not found

playerdeath.lua

Code:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
	if deathListEnabled == "yes" then
		if sqlType == "mysql" then
			env = assert(luasql.mysql())
			con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
		else -- sqlite
			env = assert(luasql.sqlite3())
			con = assert(env:connect(sqliteDatabase))
		end
		local byPlayer = FALSE
		if killer == FALSE then
			killerName = "field item"
		else
			if isPlayer(killer) == TRUE then
				byPlayer = TRUE
			end
			killerName = getCreatureName(killer)
		end
		assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
		local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
		local deathRecords = numRows(cursor)
		if sqlType == "mysql" then
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
				deathRecords = deathRecords - 1
			end
		else
			while deathRecords > maxDeathRecords do
				delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
				deathRecords = deathRecords - 1
			end
		end			
		con:close()
		env:close()

   if getPlayerStorageValue(6666) == 1 then
        setPlayerStorageValue(cid,6666,1)
   end

	end
end

I have this correct?
 
No, that last one isn't correct. you've got to paste it underneath the end under where you just posted it. Like this:
Code:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
    if deathListEnabled == "yes" then
        if sqlType == "mysql" then
            env = assert(luasql.mysql())
            con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
        else -- sqlite
            env = assert(luasql.sqlite3())
            con = assert(env:connect(sqliteDatabase))
        end
        local byPlayer = FALSE
        if killer == FALSE then
            killerName = "field item"
        else
            if isPlayer(killer) == TRUE then
                byPlayer = TRUE
            end
            killerName = getCreatureName(killer)
        end
        assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
        local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
        local deathRecords = numRows(cursor)
        if sqlType == "mysql" then
            while deathRecords > maxDeathRecords do
                delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
                deathRecords = deathRecords - 1
            end
        else
            while deathRecords > maxDeathRecords do
                delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
                deathRecords = deathRecords - 1
            end
        end            
        con:close()
        env:close()



    end
   if getPlayerStorageValue(cid,6666) == 1 then
        setPlayerStorageValue(cid,6666,1)
   end
end
And change the first script for this, sorry for that... xD

Code:
function onUse(cid, item, frompos, item2, topos)
 
 local STORAGEVALUE = CHANGE
 
    if getPlayerStorageValue(cid,STORAGEVALUE) == 1 then    
        if doPlayerRemoveItem(cid,2160,6) == 1 then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doCreatureSay(cid, "The Magic book has blessed you.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(topos,12)
            setPlayerStorageValue(cid,STORAGEVALUE,1)
        else
            doPlayerSendCancel(cid, "You need 6 crystal coin to use The Magic Bless Book.")
        end
    else
        doPlayerSendCancel(cid,'You have already been blessed by the book')
    end    
return 1
end
 
Do i have the scripts right edited? Becuase i still get this error:

Code:
[26/08/2008  19:42:11] Lua Script Error: [CreatureScript Interface] 
[26/08/2008  19:42:11] data/creaturescripts/scripts/playerdeath.lua:onDeath

[26/08/2008  19:42:11] luaGetPlayerStorageValue(). Player not found

There is a scripts the value is 6666

Code:
function onUse(cid, item, frompos, item2, topos)
 
 local STORAGEVALUE = 6666
 
    if getPlayerStorageValue(cid,STORAGEVALUE) == 1 then    
        if doPlayerRemoveItem(cid,2160,6) == 1 then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doCreatureSay(cid, "The Magic book has blessed you.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(topos,12)
            setPlayerStorageValue(cid,STORAGEVALUE,1)
        else
            doPlayerSendCancel(cid, "You need 6 crystal coin to use The Magic Bless Book.")
        end
    else
        doPlayerSendCancel(cid,'You have already been blessed by the book')
    end    
return 1
end

Code:
dofile("./config.lua")

function onDeath(cid, corpse, killer)
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are dead.")
    if deathListEnabled == "yes" then
        if sqlType == "mysql" then
            env = assert(luasql.mysql())
            con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
        else -- sqlite
            env = assert(luasql.sqlite3())
            con = assert(env:connect(sqliteDatabase))
        end
        local byPlayer = FALSE
        if killer == FALSE then
            killerName = "field item"
        else
            if isPlayer(killer) == TRUE then
                byPlayer = TRUE
            end
            killerName = getCreatureName(killer)
        end
        assert(con:execute("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `is_player`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", '" .. escapeString(killerName) .. "', " .. byPlayer .. ");"))
        local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";"))
        local deathRecords = numRows(cursor)
        if sqlType == "mysql" then
            while deathRecords > maxDeathRecords do
                delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1;"))
                deathRecords = deathRecords - 1
            end
        else
            while deathRecords > maxDeathRecords do
                delete = assert(con:execute("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);"))
                deathRecords = deathRecords - 1
            end
        end            
        con:close()
        env:close()



    end
   if getPlayerStorageValue(6666) == 1 then
        setPlayerStorageValue(cid,6666,1)
   end
end

;/

But mebey old players when they die get this error?
 
Ah, just recopy the script again, you managed to copy it before I edited my misstake.. xD

Code:
function onUse(cid, item, frompos, item2, topos)
 
 local STORAGEVALUE = CHANGE
 
    if getPlayerStorageValue(cid,STORAGEVALUE) == 1 then    
        if doPlayerRemoveItem(cid,2160,6) == 1 then
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doCreatureSay(cid, "The Magic book has blessed you.", TALKTYPE_ORANGE_1)
            doSendMagicEffect(topos,12)
            setPlayerStorageValue(cid,STORAGEVALUE,1)
        else
            doPlayerSendCancel(cid, "You need 6 crystal coin to use The Magic Bless Book.")
        end
    else
        doPlayerSendCancel(cid,'You have already been blessed by the book')
    end
 
Back
Top