• 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 Rook System

StreamSide

Joseluis Gonzalez
Staff member
Support Team
Joined
Aug 31, 2007
Messages
3,608
Solutions
51
Reaction score
1,224
Location
Arica - Chile
Well the code is simple but very usefull, go to creaturescripts and create "Rook.lua" and add this:

Code:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)

    if getPlayerExperience(cid) <= 4620 and getPlayerVocation(cid) ~= 0 then
        local rookTownID = 1
        local rookedGUID = getPlayerGUID(cid)
        local deathPos = getCreaturePosition(cid)

        for i = 1, 10 do
            local slotItem = getPlayerSlotItem(cid, i)
            if slotItem.itemid > 0 then
                doRemoveItem(slotItem.uid)
            end
        end

        doPlayerAddItem(cid, 2050, 1)
        doPlayerAddItem(cid, 2382, 1)
        doPlayerAddItem(cid, 1987, 1)
	local rookedCorpseFem = doCreateItemEx(3065)
        local rookedCorpseMale = doCreateItemEx(3058)
        if getPlayerSex(cid) == 0 then
            doPlayerAddItem(cid, 2651, 1)
            local pronoun = "She"
	    doSetItemSpecialDescription(rookedCorpseFem, "You recognize " .. getCreatureName(cid) .. ". " .. pronoun .. " was killed by " .. getCreatureName(mostDamageKiller) .. ".")
            doTileAddItemEx(deathPos, rookedCorpseFem)
        else
            doPlayerAddItem(cid, 2650, 1)
            local pronoun = "He"
	    doSetItemSpecialDescription(rookedCorpseMale, "You recognize " .. getCreatureName(cid) .. ". " .. pronoun .. " was killed by " .. getCreatureName(mostDamageKiller) .. ".")
		doTileAddItemEx(deathPos, rookedCorpseMale)
        end
        doPlayerSetVocation(cid, 0)
        doPlayerSetTown(cid, rookTownID)
        doTeleportThing(cid, getTownTemplePosition(rookTownID))

        db.executeQuery("UPDATE `players` SET `level` = '1',  `experience` = '0', `health` = '150', `healthmax` = '150', `mana` = '0', `manamax` = '0', `maglevel` = '0', `manaspent` = '0' WHERE `players`.`id` = '" .. rookedGUID .. "' LIMIT 1;")
        db.executeQuery("UPDATE `player_skills` SET `value` = '10',  `count` = '0' WHERE `player_skills`.`player_id` = '" .. rookedGUID .. "' LIMIT 7;")
 		for c = 1, 2097152 do 
 		doRemoveCondition(cid, c)
 		end
		doPlayerPopupFYI(cid, "Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto the world in exchange for a small sacrifice.\n\nSimply clock 'Ok' to resume your journeys in Tibia!\nYou has been Rooked")
		doRemoveCreature(cid)
        return FALSE
    else

        return TRUE

    end

end

and in creaturescripts.xml add:
Code:
<event type="preparedeath" name="Rook" script="Rook.lua"/>

In login.lua add:
Code:
registerCreatureEvent(cid, "Rook")

With NightMare and Nahruto Help we do it :D
Rep++
 
Last edited:
Well the code is simple but very usefull, go to creaturescripts and create "Rook.lua" and add this:

Code:
function onPrepareDeath(cid, [COLOR="Red"]lastHitKiler[/COLOR], mostDamageKiller)

    if getPlayerExperience(cid) <= 4620 and getPlayerVocation(cid) ~= 0 then
        local rookTownID = 1
        local rookedGUID = getPlayerGUID(cid)
        local deathPos = getCreaturePosition(cid)

        for i = 1, 10 do
            local slotItem = getPlayerSlotItem(cid, i)
            if slotItem.itemid > 0 then
                doRemoveItem(slotItem.uid)
            end
        end

        doPlayerAddItem(cid, 2050, 1)
        doPlayerAddItem(cid, 2382, 1)
        doPlayerAddItem(cid, 1987, 1)
	local rookedCorpseFem = doCreateItemEx(3065)
        local rookedCorpseMale = doCreateItemEx(3058)
        if getPlayerSex(cid) == 0 then
            doPlayerAddItem(cid, 2651, 1)
            local pronoun = "She"
	    doSetItemSpecialDescription(rookedCorpseFem, "You recognize " .. getCreatureName(cid) .. ". " .. pronoun .. " was killed by " .. getCreatureName(mostDamageKiller) .. ".")
            doTileAddItemEx(deathPos, rookedCorpseFem)
        else
            doPlayerAddItem(cid, 2650, 1)
            local pronoun = "He"
	    doSetItemSpecialDescription(rookedCorpseMale, "You recognize " .. getCreatureName(cid) .. ". " .. pronoun .. " was killed by " .. getCreatureName(mostDamageKiller) .. ".")
		doTileAddItemEx(deathPos, rookedCorpseMale)
        end
        doPlayerSetVocation(cid, 0)
        doPlayerSetTown(cid, rookTownID)
        doTeleportThing(cid, getTownTemplePosition(rookTownID))

        db.executeQuery("UPDATE `players` SET `level` = '1',  `experience` = '0', `health` = '150', `healthmax` = '150', `mana` = '0', `manamax` = '0', `maglevel` = '0', `manaspent` = '0' WHERE `players`.`id` = '" .. rookedGUID .. "' LIMIT 1;")
        db.executeQuery("UPDATE `player_skills` SET `value` = '10',  `count` = '0' WHERE `player_skills`.`player_id` = '" .. rookedGUID .. "' LIMIT 7;")
 		for c = 1, 2097152 do 
 		doRemoveCondition(cid, c)
 		end
		doPlayerPopupFYI(cid, "Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto the world in exchange for a small sacrifice.\n\nSimply clock 'Ok' to resume your journeys in Tibia!\nYou has been Rooked")
		doRemoveCreature(cid)
        return FALSE
    else

        return TRUE

    end

end

and in creaturescripts.xml add:
Code:
<event type="preparedeath" name="Rook" script="Rook.lua"/>

In login.lua add:
Code:
registerCreatureEvent(cid, "Rook")

With NightMare and Nahruto Help we do it :D
Rep++


hi,
with red colour words is true? or kiler=killer?
 
#UP
Sorry my error :/
But it works 100% and if you want something more realistic go to the slawkens system and add the block for parcels :>
 
Just put an unknow name for the rook town on mapeditor, the players can't send parcel then :p

o_O

Mailbox.cpp, ::sendItem
Code:
	if(receiver == "" || dp == 0)
		return false;

Just add: || dp == your_rook_id and recompile :):):):):):)
 
would this be if you go below level 6 ? you go to rook? because that's how it is in rl tibia
 
lol it's wrong script. Experience for lvl 6 is 1500...
That's in global tibia.
 
for c = 1, 2097152 do
doRemoveCondition(cid, c)
end
It's too big loop, you should replace it with:
PHP:
local conditions = {CONDITION_POISON, CONDITION_FIRE, CONDITION_ENERGY, CONDITION_PHYSICAL, CONDITION_HASTE, CONDITION_PARALYZE, CONDITION_OUTFIT, CONDITION_INVISIBLE, CONDITION_LIGHT, CONDITION_MANASHIELD, CONDITION_INFIGHT, CONDITION_DRUNK, CONDITION_EXHAUST, CONDITION_FOOD, CONDITION_REGENERATION, CONDITION_SOUL, CONDITION_DROWN, CONDITION_MUTED, CONDITION_ATTRIBUTES, CONDITION_FREEZING, CONDITION_DAZZLED, CONDITION_CURSED, CONDITION_PACIFIED}
			for c = 1, #conditions do
				doRemoveCondition(cid, conditions[c])
			end
23 cycles are much better than 2097152 :}
 
Why not just use doRemoveConditions(cid)

?????????????????????????
 
:O Where do you have doRemoveConditions(cid)? I haven't this function in LUA_FUNCTIONS :/

#down: So it should be added to LUA_FUNCTIONS, I wouldn't check luascript.cpp for any function :S
 
Last edited:
:O Where do you have doRemoveConditions(cid)? I haven't this function in LUA_FUNCTIONS :/

In luascript.cpp you mofo.

Code:
int32_t LuaScriptInterface::luaDoRemoveConditions(lua_State* L)
{
	//doRemoveConditions(cid)
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();

	Creature* creature = env->getCreatureByUID(cid);
	if(!creature)
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
		return 1;
	}

	creature->removeConditions(CONDITIONEND_ABORT, false);
	lua_pushnumber(L, LUA_NO_ERROR);
	return 1;
}
 
hello

hello,have errror in use tfs 0.2


[15/02/2009 20:33:22] data/creaturescripts/scripts/Rook.lua:3: attempt to call global 'getPlayerExperience' (a nil value)
[15/02/2009 20:33:22] stack traceback:
[15/02/2009 20:33:22] data/creaturescripts/scripts/Rook.lua:3: in function <data/creaturescripts/scripts/Rook.lua:1>

[15/02/2009 20:33:22] Lua Script Error: [CreatureScript Interface]
[15/02/2009 20:33:22] data/creaturescripts/scripts/Rook.lua:eek:nPrepareDeath

thz.
 
Back
Top