Code:
[13:1:50.204] Description:
[13:1:50.204] data/lib/050-function.lua:2: attempt to call global 'type' (a string value)
[13:1:50.204] stack traceback:
[13:1:50.204] data/lib/050-function.lua:2: in function 'isInArray'
[13:1:50.204] [string "LuaInterface::loadBuffer"]:28: in function <[string "LuaInterface::loadBuffer"]:3>
a tak wygląda funkcja
Code:
function isInArray(array, value, caseSensitive)
if(caseSensitive == nil or caseSensitive == false) and type(value) == "string" then
local lowerValue = value:lower()
for _, _value in ipairs(array) do
if type(_value) == "string" and lowerValue == _value:lower() then
return true
end
end
else
for _, _value in ipairs(array) do
if (value == _value) then return true end
end
end
return false
end
Chodzi o Rush Event z Materii.
Fragmenty kodu gdzie funkcja została użyta
Code:
function onThink(cid, interval)
if isInArray(daysOpen, os.date('%A')) then
if isInArray(configRushEvent.days[os.date('%A')], os.date('%X', os.time())) then
if getStorage(configRushEvent.storages.joining) ~= 1 then
doStartCountingRushEvent(0)
for _, pid in ipairs(getPlayersOnline()) do
if tostring(getCreatureStorage(pid, configRushEvent.storages.player)) ~= '' then
doCreatureSetStorage(pid, configRushEvent.storages.player, '')
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
doRemoveCondition(pid, CONDITION_OUTFIT)
end
end
doSetStorage(configRushEvent.storages.joining, 1)
addEvent(doStartRushEvent, configRushEvent.delayTime * 60 * 1000)
end
end
end
return true
end
Code:
function onStatsChange(cid, attacker, type, combat, value)
if type == 1 and getCreatureHealth(cid) <= value then
if isInRange(getThingPos(cid), configRushEvent.room.from, configRushEvent.room.to) then
if isPlayer(cid) then
local p = tostring(getCreatureStorage(cid, configRushEvent.storages.player))
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
doTeleportThing(cid, p ~= 'blue' and configRushEvent.position.red or configRushEvent.position.blue)
doCreatureSetNoMove(cid, true)
addEvent(doCreatureSetNoMove, configRushEvent.waitTime * 1000, cid, false)
if p ~= 'blue' then
doSetStorage(configRushEvent.storages.b_score, math.max(getStorage(configRushEvent.storages.b_score), 0) + 1)
if getStorage(configRushEvent.storages.b_score) == configRushEvent.fragLimit then
doStopRushEvent()
end
else
doSetStorage(configRushEvent.storages.r_score, math.max(getStorage(configRushEvent.storages.r_score), 0) + 1)
if getStorage(configRushEvent.storages.r_score) == configRushEvent.fragLimit then
doStopRushEvent()
end
end
return false
end
end
elseif isInArray({1,3}, type) and isPlayer(attacker) and isPlayer(cid) then
if isInRange(getThingPos(cid), configRushEvent.room.from, configRushEvent.room.to) then
if tostring(getCreatureStorage(cid, configRushEvent.storages.player)) == tostring(getCreatureStorage(attacker, configRushEvent.storages.player)) then
return false
end
end
end
return true
end
Wie ktoś jak temu zaradzić?
Last edited: