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

Aol forever

Zonet

Web Developer
Joined
Sep 1, 2008
Messages
4,393
Reaction score
52
Location
Tibia VS RL-life, guess whos back?
Hello there..

I want to do the broken amulet like amulet of loss but never lose the broken amulet always have it.!


can anyone make a script if there's script i know that aol is compiled but if there's script i would be very thanksful for the guy who script it to me:p


Thank you.
 
I use TFS 0.3 Beta 3, When a player don't wear it and dies, the death is registered in the database, but if a player wear it and dies, the death is not registered in the database..
 
PHP:
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
SQL_COMUNICATION_INTERVAL = SQL_interval * 1000
function onLogin(cid)
    if(InitShopComunication == 0) then 
        local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {}) 
        local historyPage = addEvent(historyPage, 60000, {}) 
        InitShopComunication = eventServ 
    end  
	registerCreatureEvent(cid, "PlayerDeath")
	registerCreatureEvent(cid, "Inquisition")
	registerCreatureEvent(cid, "playerLook")
	registerCreatureEvent(cid, "PlayerDeathPrepare")
	return TRUE
end

function historyPage(parameters) 
    local historyPage = addEvent(historyPage, 60000, {}) 
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then 
        setGlobalStorageValue(23456, (tonumber(os.date("%d")))) 
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;") 
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;") 
    end 
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;") 
end  

function sql_communication(parameters)
	local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
	if(result_plr:getID() ~= -1) then
		while(true) do
			id = tonumber(result_plr:getDataInt("id"))
            action = tostring(result_plr:getDataString("action"))
			delete = tonumber(result_plr:getDataInt("delete_it"))
			cid = getPlayerByName(tostring(result_plr:getDataString("name")))
			if isPlayer(cid) == TRUE then
				local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
				local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
				local container_id = tonumber(result_plr:getDataInt("param3"))
				local container_count = tonumber(result_plr:getDataInt("param4"))
				local add_item_type = tostring(result_plr:getDataString("param5"))
				local add_item_name = tostring(result_plr:getDataString("param6"))
	            local received_item = 0
	            local full_weight = 0
	            if add_item_type == 'container' then
	                container_weight = getItemWeightById(container_id, 1)
					if isItemRune(itemtogive_id) == TRUE then
						items_weight = container_count * getItemWeightById(itemtogive_id, 1)
					else
						items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
					end
	                full_weight = items_weight + container_weight
	            else
	                full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
					if isItemRune(itemtogive_id) == TRUE then
						full_weight = getItemWeightById(itemtogive_id, 1)
					else
						full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
					end
	            end
	            local free_cap = getPlayerFreeCap(cid)
	            if full_weight <= free_cap then
	                if add_item_type == 'container' then
	                    local new_container = doCreateItemEx(container_id, 1)
	                    local iter = 0
	                    while iter ~= container_count do
	                        doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
	                        iter = iter + 1
	                    end
	                    received_item = doPlayerAddItemEx(cid, new_container)
	                else
	                    local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
	                    received_item = doPlayerAddItemEx(cid, new_item)
	                end
	                if received_item == RETURNVALUE_NOERROR then
	                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from Fragged OTs shop.')
	                    db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
						db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
	                else
	                    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from Fragged OTs shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
	                end
	            else
	                doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from Fragged OTs shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
	            end
	        end
			if not(result_plr:next()) then
				break
			end
		end
		result_plr:free()
    end
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
end


and PlayerPrepareDeath.lua
PHP:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
if getCreatureSkullType(cid) ~= 4 then
    local checkAol = getPlayerSlotItem(cid, 2)
    if checkAol.itemid == 2196 then
        doTransformItem(checkAol.uid,2196)
    end
end
return TRUE
end

Removed doPlayerAddItem(cid,8889,1) because it just gave me a new skullcracker armor.

and Creaturescripts.xml
PHP:
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="preparedeath" name="PlayerDeathPrepare" script="playerpreparedeath.lua"/>

Aff, I think I just should add in items.xml on the Broken Amulet like it is on the AoL and then use this script? Then it should work, when I die I lose the broken amulet(like the aol) but this script give me new.

Is this what you meant from the beginning? :p
 
Try one thing
change
PHP:
doTransformItem(checkAol.uid,2196)
to
PHP:
doTransformItem(checkAol.uid,2173)
Yeah, u got the point.
PHP:
        doPlayerAddItem(cid,8889,1)
it's an example.
just change to
PHP:
doPlayerAddItem(cid,2196,1)
have only 1 problem. The new amulet goes to backpack
u can use a storage if u want.
like in login.lua
PHP:
if getPlayerStorageValue(cid,storage) == 1 then
doPlayerAddItem(cid,2196,1)
setPlayerStorageValue(cid,storage,0)
end
and
in PlayerPrepareDeath.lua
PHP:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
if getCreatureSkullType(cid) ~= 4 then
    local checkAol = getPlayerSlotItem(cid, 2)
    if checkAol.itemid == 2196 then
        doTransformItem(checkAol.uid,2173)
        setPlayerStorageValue(cid,storage,1)
end
end
return TRUE
end
Hope u understand.
 
Because..
It's onPrepareDeath.
when u are going to dead.
if you have a broken amulet equiped.
it transforms in an aol and you die.
after this .. you will need a new broken amulet.

PS:Srry about the really sux english. I'm learning.
 
If you don't want edit sources...
in data/creaturescripts/scripts/login.lua under:
PHP:
function onLogin(cid)
add:
PHP:
registerCreatureEvent(cid, "PlayerDeathPrepare")
in data/creaturescripts/scripts/ make file playerpreparedeath.lua and in this file:
PHP:
function onPrepareDeath(cid, killer)
	if getPlayerItemCount(cid, 8889) >= 1 then
		doSetCreatureDropLoot(cid, 0)
	end
end
getPlayerItemCount(cid, 8889) - with item 8889 (skullcracker armor) players dont lose eq - tested (player can wear this item in backpack, not only armor slot!)
in file data/creaturescripts/creaturescripts.xml under:
PHP:
<creaturescripts>
add:
PHP:
<event type="preparedeath" name="PlayerDeathPrepare" script="playerpreparedeath.lua"/>



Its working verry nice but it dont droop when i have red skull so can you tell me how fix it ??
I wanna droop this item and all me items when i have red skull
 
2 year ressurection, cool :D
*takes picture*

Ontopic:
Use this code on your creaturescript
Code:
function onPrepareDeath(cid, killer) 
    if getPlayerItemCount(cid, 8889) >= 1 and getCreatureSkullType(cid) >= SKULL_RED then 
        doSetCreatureDropLoot(cid, 0) 
    end 
end
I used >= so it also includes black skulls

if you have red skull or higher, it'll ignore this code and use the server's default, which is what you want i think :)
 
#up when i change me
function onPrepareDeath(cid, killer)
if getPlayerItemCount(cid, 8889) >= 1 then
doSetCreatureDropLoot(cid, 0)
end
end

for

function onPrepareDeath(cid, killer)
if getPlayerItemCount(cid, 8889) >= 1 and getCreatureSkullType(cid) >= SKULL_RED then
doSetCreatureDropLoot(cid, 0)
end
end

i have this error in consol when players death with this items and lost all items if have rs and lost bp when dont have rs

[25/07/2011 04:36:31] Lua Script Error: [CreatureScript Interface]
[25/07/2011 04:36:31] data/creaturescripts/scripts/playerpreparedeath.lua:eek:nPrepareDeath

[25/07/2011 04:36:31] data/creaturescripts/scripts/playerpreparedeath.lua:2: attempt to call global 'getCreatureSkullType' (a nil value)
[25/07/2011 04:36:31] stack traceback:
[25/07/2011 04:36:31] data/creaturescripts/scripts/playerpreparedeath.lua:2: in function <data/creaturescripts/scripts/playerpreparedeath.lua:1>

i use tfs v0.2.3
 
Last edited:
you don't have the function I used to get the skull from the player, just check your available functions, one of them should return the skullType of the player
 
Back
Top