Otfan125
Well-Known Member
TFS VERSION: 1.3
Hey guys,
I'm trying to create an onLogin script that reads the 'players' database and sets a special condition/effect/attribute to a player until s/he logs out.
However, I want these attributes to be unique... for example: if a player has the value for column 'blade' in his 'players' database, the onLogin script should set a condition/effect/attribute (e.g., "CONDITION_BLADE") on the player that can be read by other lua scripts as 'if player:hasCondition(CONDITION_BLADE)'
I've tried to register a new condition called "CONDITION_BLADE" in enums.h and registred it in luascript.cpp.
Here is my current onLogin code:
The idea is that it reads the player database for player=Angel and sees if the column "blademaster" is set to 1.
If yes, it should set the condition "CONDTIION_BLADEMASTER" and have it tick for "-1", meaning it forever.
Though, CONDITION_BLADEMASTER returns the following:
This doesn't happen if I test with CONDITION_INVISIBLE.
Any pointers in creating new conditions and/or a better way of setting specific attributes/effects to a player until logout is greatly appreciated!
Thanks
Hey guys,
I'm trying to create an onLogin script that reads the 'players' database and sets a special condition/effect/attribute to a player until s/he logs out.
However, I want these attributes to be unique... for example: if a player has the value for column 'blade' in his 'players' database, the onLogin script should set a condition/effect/attribute (e.g., "CONDITION_BLADE") on the player that can be read by other lua scripts as 'if player:hasCondition(CONDITION_BLADE)'
I've tried to register a new condition called "CONDITION_BLADE" in enums.h and registred it in luascript.cpp.
Here is my current onLogin code:
Lua:
function onLogin(player)
local res = db.storeQuery("SELECT `blademaster` FROM `players` WHERE `name` = \"Angel\";")
if res == 1 then
local condition = Condition(CONDITION_BLADEMASTER)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
player:addCondition(condition)
end
return true
end
The idea is that it reads the player database for player=Angel and sees if the column "blademaster" is set to 1.
If yes, it should set the condition "CONDTIION_BLADEMASTER" and have it tick for "-1", meaning it forever.
Though, CONDITION_BLADEMASTER returns the following:
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/blademaster.lua:onLogin
data/creaturescripts/scripts/blademaster.lua:8: attempt to index local 'condition' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/blademaster.lua:8: in function <data/creaturescripts/scripts/blademaster.lua:2>
This doesn't happen if I test with CONDITION_INVISIBLE.
Any pointers in creating new conditions and/or a better way of setting specific attributes/effects to a player until logout is greatly appreciated!
Thanks