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

Lua 2 Questions !

raell5

Premium User
Joined
Aug 23, 2010
Messages
82
Reaction score
9
Location
Deaths Of Tentacles Planet
2 questions!

1 = how can I put that when a player does not log in "X" days he loses his house *

2 = How to put a rune on this end I want to edit?

214ill.jpg


 
Last edited:
1- Use this mod:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cleanhouses" version="1.03" author="nsanee" contact="otland.net" enabled="yes">
<description>
v.1.03 - Added 'onlyNonPremium' configurable.
Removed modlib, since the script is run once anyway we don't need it loaded at all times.
It shouldn't now stop execution when a house is nameless.

v.1.02 - now uses only one sql query, removed multiworld configurable since it's not needed anymore
v.1.01 - small fixes, optimized query + multiworld support.


This mod will clean houses of inactive players and move their items to the depot.

config explained:

days - If the player hasn't logged in for this number of days his house will be freed.
log - true/false, whether to enable logging of which houses have been cleaned.
file - path to the log file, where logs will be stored. Ignored if 'log' set to false
onlyNonPremium - if set to 'true', the script will clean only the houses of players who don't have any pacc days left.

other notes:
DO NOT remove doSaveServer() at the end, otherwise if your server happens to crash before the nearest server save you will regret it =)
</description>

<globalevent name="cleanhouses" type="start" event="buffer"><![CDATA[


local config = {
days = 3,
log = true,
file = getDataDir() .. "/logs/cleanhouses.txt",
onlyNonPremium = false
}



local ns_query =[[ SELECT houses.owner, houses.id as hid, houses.name as house_name ,players.name FROM houses
LEFT JOIN players ON players.id=houses.owner
LEFT JOIN accounts ON players.account_id=accounts.id
WHERE players.lastlogin < (UNIX_TIMESTAMP() - ]] ..config.days.. [[*24*60*60)
]] ..(config.onlyNonPremium and ' AND accounts.premdays=0 ' or '')..[[
AND players.world_id =]] .. getConfigValue("worldId")

local house = db.getResult(ns_query)
local logs = " :: Houses cleaned:\n\n"
if house:getID() ~= -1 then
repeat
logs = logs .. house:getDataString('house_name') ..", owned by " .. house:getDataString('name') .. "\n"
setHouseOwner(house:getDataInt('hid'), 0)
until not house:next()
house:free()
else
logs = logs .. "There were no houses to clean."
end
if config.log then
doWriteLogFile(config.file, logs)
end
addEvent(doSaveServer, 1000)

]]></globalevent>
</mod>

2- Do you want to send effect or remove the rune?
Code:
doRemoveItem(uid, ...)
doSendMagicEffect(pos, magicEffect, ...)
 
Distance Effect:
Code:
doSendDistanceShoot(fromPos, toPos, distanceEffect, ...)

Effect:
Code:
doSendMagicEffect(pos, magicEffect, ...)
 
Look try to fix me
local config = {
removeOnUse = "no",
usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
splashable = "no",
realAnimation = "no", -- make text effect visible only for players in range 1x1
healthMultiplier = 1.0,
manaMultiplier = 1.0
}

config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)

local POTIONS = {
[8704] = {empty = 7636, splash = 2, health = {50, 100}}, -- small health potion
[7618] = {empty = 7636, splash = 2, health = {100, 200}}, -- health potion
[7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion
[7591] = {empty = 7635, splash = 2, health = {700, 900}, level = 8, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
[8473] = {empty = 7635, splash = 2, health = {1200, 1600}, level = 8, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
[7620] = {empty = 7636, splash = 7, mana = {500, 570}}, -- mana potion
[7589] = {empty = 7634, splash = 7, mana = {110, 190}, level = 8, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
[7590] = {empty = 7635, splash = 7, mana = {1200, 1300}, level = 8, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
[8472] = {empty = 7635, splash = 3, health = {1500, 1600}, mana = {600, 1300}, level = 8, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion
}

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTIONS[item.itemid]
if(not potion) then
return false
end
if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
if(not config.splashable) then
return false
end
if(toPosition.x == CONTAINER_POSITION) then
toPosition = getThingPos(item.uid)
end
doDecayItem(doCreateItem(2016, potion.splash, toPosition))
doTransformItem(item.uid, potion.empty)
return TRUE
end
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
end
if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
then
doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
return TRUE
end
local health = potion.health
if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
return false
end
local mana = potion.mana
if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
return false
end
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_FIREATTACK)
if(not realAnimation) then
doCreatureSay(itemEx.uid, "CURSE...", TALKTYPE_ORANGE_1)
else
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
if(isPlayer(tid)) then
doCreatureSay(itemEx.uid, "REGENERATION...", TALKTYPE_ORANGE_1, false, tid)
end
end
end
doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
doRemoveItem(item.uid, 1)
return TRUE
end
doRemoveItem(item.uid, 0)
doPlayerAddItem(cid, potion.empty, 0)
doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty))
return TRUE
end
 
What is your problem with potions?

EDITED:

I reccomend to use this:
Code:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = createCombatObject()
setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)

local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.

function onUse(cid, item, fromPosition, itemEx, toPosition)
if itemEx.itemid ~= 1 or itemEx.type ~= THING_TYPE_PLAYER then
return true
end

if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
end

if(item.itemid == antidotePot) then
if(doCombat(cid, antidote, numberToVariant(cid)) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, emptyPot, 1)
elseif(item.itemid == smallHealthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 60, 85, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, emptyPot, 1)
elseif(item.itemid == healthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 125, 175, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, emptyPot, 1)
elseif(item.itemid == manaPot) then
if(doTargetCombatMana(0, cid, 75, 125, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, emptyPot, 1)
elseif(item.itemid == strongHealthPot) then
if(not(isKnight(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, strongEmptyPot, 1)
elseif(item.itemid == strongManaPot) then
if(not(isSorcerer(cid) or isDruid(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatMana(0, cid, 115, 185, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, strongEmptyPot, 1)
elseif(item.itemid == greatSpiritPot) then
if(not(isPaladin(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 250, 350, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, cid, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, greatEmptyPot, 1)
elseif(item.itemid == greatHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 425, 575, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, greatEmptyPot, 1)
elseif(item.itemid == greatManaPot) then
if(not(isSorcerer(cid) or isDruid(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatMana(0, cid, 150, 250, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, greatEmptyPot, 1)
elseif(item.itemid == ultimateHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 130)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_MONSTER_SAY)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 650, 850, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER_SAY)
doRemoveItem(item.uid, 1)
doPlayerAddItem(cid, greatEmptyPot, 1)
end
return TRUE
end
 
Back
Top