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

[CreatureScript] level protection

ninexin

insane.sytes.net
Joined
Jun 10, 2007
Messages
213
Reaction score
3
Location
Brazil
i need one creature script !!!

if player die for monster and is <= lvl 20 then
not lose exp and loot

im using tfs 0.4 rev3777

I tried to use this, but did not work!

Code:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)

-- configuração

local config = {
exp = false, -- se ao morrer o jogador irá perder exp
loot = false, -- se ao morrer o jogador irá perder o loot
level = 20 -- até que level irá proteger o player
}

if isPlayer(cid) and getPlayerLevel(cid) <= config.level then
elseif config.loot == false then 
doCreatureSetDropLoot(cid, false) 
elseif config.exp == false then 
doPlayerSetLossPercent(cid, experience, 0)
end
return TRUE
end

Code:
<event type="preparedeath" name="ProtectLevel" event="script" value="levelprotection.lua"/>

Code:
registerCreatureEvent(cid, "ProtectLevel")

not show errors in console but not work Oo
 
use this

PHP:
function onLogin(cid)
local bless = {1, 2, 3, 4, 5}
local level = 20
	if(getPlayerLevel(cid) <= level) then
		for i = 1, table.maxn(bless) do
			if(getPlayerBlessing(cid, bless[i])) then
				return TRUE
			else
				doPlayerAddBlessing(cid, bless[i])
			end
		end
   	end
return true
end

add all blesings if u login.
 
use this

PHP:
function onLogin(cid)
local bless = {1, 2, 3, 4, 5}
local level = 20
	if(getPlayerLevel(cid) <= level) then
		for i = 1, table.maxn(bless) do
			if(getPlayerBlessing(cid, bless[i])) then
				return TRUE
			else
				doPlayerAddBlessing(cid, bless[i])
			end
		end
   	end
return true
end

add all blesings if u login.

That could be exploited unless you remove all those blessings when the player reaches level 20.
Just an example on how to make it better: add a X storage to the player who logins for the first time, onLogin script: if the player's X storage > 0 then add the blessings, onAdvance script: when the player becomes level 20 remove the storage (-1) and remove the blessings.
Ofc...you'll have to make a level check in the bless NPC/Talkaction/etc so that no players below that level would be able to buy one, else the onAdvance script would delete its bought blessings.
Otherwise I'm pretty much sure that it can be done with just onPrepareDeath or onDeath.
 
Something like this should work:
Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
local LEVEL = 20
local TEMPLE_POS = {x=100,y=100,z=7} --change this to your temple position

if isPlayer(cid) and getPlayerLevel(cid) <= LEVEL then
return false, doTeleportThing(cid, TEMPLE_POS), doCreatureAddHealth(cid, getCreatureMaxHealth(cid)), doCreatureAddMana(cid, getCreatureMaxMana(cid))
end
return TRUE
end

this will automaticly tp the player to the temple back without losing anything, the player's hp and mana wil be max.
 
......
Lua:
function onPrepareDeath(cid, deathList)
    if getPlayerLevel(cid) < 20 then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
        doCreatureAddMana(cid, getCreatureMaxMana(cid))
        doRemoveConditions(cid, false)
        return false
    end
    return true
end
 
Back
Top