sharinn
Active Member
- Joined
- Aug 27, 2011
- Messages
- 157
- Solutions
- 8
- Reaction score
- 43
- GitHub
- ArturKnopik
- Twitch
- krecikondexin
Hello, at the beginning I want to apologize to you for my English, I helped translator..
I need help to detect problem of random server crash, i adding 2 new spells and one weapon
probably one or all of them is a problem.. all of them use addEvent()
storageReseter.lua - used to reset storage when player die and addevent from other scripts try remove storage from unexisting player
on start i give onLogin function(register on player)
doubleCast.lua - rune to set storage... all spell check storage and set cooldown based on current storage (1991)
utanaAni.lua - spell incresing atack speed if storage 1999 >-1
TwinAxe.lua - custom weapon script
I need help to detect problem of random server crash, i adding 2 new spells and one weapon
probably one or all of them is a problem.. all of them use addEvent()
storageReseter.lua - used to reset storage when player die and addevent from other scripts try remove storage from unexisting player
on start i give onLogin function(register on player)
Code:
function onLogin(player)
player:setStorageValue(1999, -1)
player:setStorageValue(1991, -1)
return true
end
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setCondition(condition)
local player
local function resetStorage()
if player:getStorageValue(1999) > -1 then
player:setStorageValue(1999, getPlayerStorageValue(player, 1999)-1)
end
end
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
local exhaustHealGroup = Condition(CONDITION_SPELLGROUPCOOLDOWN)
exhaustHealGroup:setParameter(CONDITION_PARAM_SUBID, 3)
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
combat:setCondition(exhaust)
function onCastSpell(creature, var)
player = Player(creature)
if creature:getStorageValue(1999) > -1 then
exhaustHealGroup:setParameter(CONDITION_PARAM_TICKS, 500)
combat1:setCondition(exhaustHealGroup)
else
exhaustHealGroup:setParameter(CONDITION_PARAM_TICKS, 1000)
combat1:setCondition(exhaustHealGroup)
end
player:addCondition(exhaustHealGroup)
player = Player(creature)
if creature:getStorageValue(1999) > -1 then
exhaust:setParameter(CONDITION_PARAM_TICKS, 500)
else
exhaust:setParameter(CONDITION_PARAM_TICKS, 1000)
end
player:addCondition(exhaust)
creature:say("Double Cast Speed!", TALKTYPE_MONSTER_SAY)
setPlayerStorageValue(creature, 1999, getPlayerStorageValue(player, 1999)+1)
addEvent(resetStorage, 20000)
return combat:execute(creature, var)
end
utanaAni.lua - spell incresing atack speed if storage 1999 >-1
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
local condition = Condition(CONDITION_HASTE)
condition:setParameter(CONDITION_PARAM_TICKS, 100)
condition:setFormula(0, 0, 0, 0)
combat:setCondition(condition)
local player
local function resetStorage()
if player:getStorageValue(1991) > -1 then
player:setStorageValue(1991, getPlayerStorageValue(player, 1991)-1)
if player:getStorageValue(1991) == -1 then
player:setAttackSpeed(player:getAttackSpeed()*2)
end
end
end
local exhaust = Condition(CONDITION_SPELLCOOLDOWN)
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
local exhaustHealGroup = Condition(CONDITION_SPELLGROUPCOOLDOWN)
exhaustHealGroup:setParameter(CONDITION_PARAM_SUBID, 1)
local exhaust = Condition(CONDITION_EXHAUST_COMBAT)
combat:setCondition(exhaust)
function onCastSpell(creature, var)
player = Player(creature)
if creature:getStorageValue(1991) > -1 then
exhaustHealGroup:setParameter(CONDITION_PARAM_TICKS, 1000)
combat1:setCondition(exhaustHealGroup)
else
exhaustHealGroup:setParameter(CONDITION_PARAM_TICKS, 2000)
combat1:setCondition(exhaustHealGroup)
end
player:addCondition(exhaustHealGroup)
creature:say("Speed!", TALKTYPE_MONSTER_SAY)
if getPlayerStorageValue(player, 1991) == -1 then
player:setAttackSpeed(player:getAttackSpeed()/2)
end
setPlayerStorageValue(creature, 1991, getPlayerStorageValue(player, 1991)+1)
addEvent(resetStorage, 20000, var)
combat:execute(creature, var)
return true
end
TwinAxe.lua - custom weapon script
Code:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(player, skill, attack, factor)
local skillTotal = (skill*4) * (attack/2)
local levelTotal = player:getLevel()
return -(((skillTotal * 0.04) + 7) + (levelTotal/5)), -(((skillTotal * 0.07) + 11) + (levelTotal/5))
end
combat1:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
local player
local function resetStorage(var)
if player then
doCombat(player, combat1, var)
end
end
function onUseWeapon(cid, var)
player = Player(cid)
addEvent(resetStorage, player:getAttackSpeed()/2, var)
return doCombat(player, combat1, var)
end