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

Problem z funkcją LUA

ximmy

Member
Joined
Oct 31, 2009
Messages
374
Reaction score
6
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:
nie pomagajcie mu, dima kupił konto ximmiego i teraz spamuje

wydało się dimsonik

- - - Updated - - -

ej, a wprowadziłeś zmienną:

local lowerValue = value:lower()

której potem wgl nie używasz
 
twój interpreter lua nie ogarnia funkcji wbudowanej type
używasz może lua JIT?
niektóre fajne rzeczy z oryginalnej biblioteki nie działają w JIT
 
Dziwna sprawa. Wczoraj wywaliłem skrypt od banowania gdzie jest zmienna globalna "type" i rush event zadziałał. Dzisiaj rano zmieniłem nazwe "type" na "typer" tak żeby banowanie i rush event działał no i oczywiście rush event przestał działać i teraz w żaden sposób nie umiem go naprawić :(

- - - Updated - - -

Jeszcze dziwniejsza sprawa bo nagle zaczął działać :)
 
Back
Top