• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

luascript.h Problem

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Siema!

Mam taki oto LMS w modzie:

Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<mod name='Last Man Standing' version='1.0' author='Oskar' contact='[email protected]' enabled='yes'>
<config name='LMSEvent_conf'><![CDATA[
LMSRewards = {
				random = true, --czy ma losowac nagrode
				rew = {2160,50, 5785,1, 5952,1} --nagrody, wypelniamy w ten sposob {itemId1, count1, itemId2, count2 ...}
				}

LMSMaxPlayers = 15 --ilosc graczy wymaganych do rozpoczecia eventu
LMSMinPlayers = 5 --minimalna ilosc graczy
LMSAccesToIgnore = 5 --acces ktory nie jest liczony jako osoba uczestniczaca w evencie
timeOnJoinToEvent = 10 --ilosc minut ktora czeka skrypt na wymagana ilosc graczy

LMSJoinType = 'talkaction' --movement, talkaction lub oba, sposob dolaczania sie do eventu

-- POSITIONS
LMSKickPosition = {x=2816, y=2509, z=6} --gdzie wyrzuca graczy po wyrzuceniu z eventu (przegranej)
LMSEnterPosition = {x=2816, y=2523, z=7} --pozycja gdzie teleportuje graczy po rozpoczeciu eventu

LMSCenterRoomPosition = {x=2816,y=2517,z=7} --idealny srodek pomieszczenia
LMSRangeX_RangeY = {14,12} --szerokosc oraz wysokosc pomieszczenia dzielona przez dwa (liczone w najszerszych miejscach)

LMSStorageStatus = 13350 --storage uzywane do eventu
LMSCountSpawnNewMonsters = 4
LMSTimeBetweenSpawnNewMonsters = 60 --w sekundach

LMSMonsters = {
		  --['nazwa potwora'] = szansa na stworzenie,
			['maluszek'] = 25,
			['rozpierdalacz'] = 15,
			['pchly'] = 10,
			['dark draco'] = 5
			}

function chooseLMSMonster()
local monster = false
for k, v in pairs(LMSMonsters) do
	monster = monster or (math.random(100) <= v and k or false)
end
return monster or chooseLMSMonster()
end

function isWalkable(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
	pos.stackpos = i
	local tile = getTileThingByPos(pos)
		if tile.itemid ~= 0 and not isCreature(tile.uid) then
			if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
				return false
			end
		end
end
return true
end

local _f = doTeleportThing
function doTeleportThing(cid, newpos, ignoreBlocking)
	return (ignoreBlocking or isWalkable(newpos, true, true, false) or false) and _f(cid, newpos, true, true)
end
 
function getLMSEventPlayers()
	local players = {}
	for _, cid in pairs(getPlayersOnline()) do
		if getCreatureStorage(cid, LMSStorageStatus) == 1 and getPlayerAccess(cid) < LMSAccesToIgnore then
			table.insert(players, cid)
		end
	end
	return players
end

function kickPlayerFromLMSArea(cid)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	doTeleportThing(cid, LMSKickPosition, true)
	doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
	return doCreatureSetStorage(cid, LMSStorageStatus, 0) and doCreatureSetNoMove(cid, false)
end

function loseOnLMSArena(cid)
    local players, msg = getLMSEventPlayers(), ''
	doCreatureSetStorage(cid, LMSStorageStatus+1, 0)
    kickPlayerFromLMSArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Przegrales.')
    if(#getLMSEventPlayers() <= 1) then
        local winner = getLMSEventPlayers()[1] or players[1]
        if winner then
            if LMSRewards.random then
				local i = math.random(#LMSRewards.rew/2)
				local rewardItem = doPlayerAddItem(winner, LMSRewards.rew[i*2-1], LMSRewards.rew[i*2], true)
			else
				for i = 1, #LMSRewards.rew/2 do
					doPlayerAddItem(winner, LMSRewards.rew[i*2-1], LMSRewards.rew[i*2], true)
				end
			end
			doPlayerSendTextMessage(winner, MESSAGE_INFO_DESCR, 'Wygrales Last Man Standing Event.')
            msg = getCreatureName(winner) .. ' wygral Last Man Standing Event.'
            kickPlayerFromLMSArea(winner)
			if getSpectators(LMSCenterRoomPosition, LMSRangeX_RangeY[1], LMSRangeX_RangeY[2]) then
				for _, v in ipairs(getSpectators(LMSCenterRoomPosition, LMSRangeX_RangeY[1], LMSRangeX_RangeY[2])) do
					if isMonster(v) then
						doRemoveThing(v)
					elseif isPlayer(v) then
						kickPlayerFromLMSArea(v)
					end
				end
			end
        else
            msg = 'Last Man Standing zakonczony! Nikt nie wygral.'
        end
		doSetStorage(LMSStorageStatus, 0)
    end
return (msg ~= '' and doBroadcastMessage(msg) or true)
end
 
function addPlayerToLMSArea(cid, block)
doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, LMSEnterPosition, true)
doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
return doCreatureSetStorage(cid, LMSStorageStatus, 1) and doCreatureSetNoMove(cid, block)
end
 
function spawnNewLMSMonster(n)
local n, pos = n or 0, {x = LMSCenterRoomPosition.x + math.random(-LMSRangeX_RangeY[1],LMSRangeX_RangeY[1]), y = LMSCenterRoomPosition.y + math.random(-LMSRangeX_RangeY[2],LMSRangeX_RangeY[2]), z = LMSCenterRoomPosition.z}
if isWalkable(pos, true, true, true) then 
	local monster = chooseLMSMonster()
    local cid = monster and doCreateMonster(monster, pos, false, false, false) or 0
	doSendMagicEffect(pos, CONST_ME_TELEPORT)
	for i = 1, LMSCountSpawnNewMonsters do
		addEvent(spawnNewLMSMonster, LMSTimeBetweenSpawnNewMonsters * 1000)
	end
	return doSendMagicEffect(pos, CONST_ME_TELEPORT)
end
return (n < 200 and spawnNewLMSMonster(n+1) or true)
end

function setLMSEventStart()
if getStorage(LMSStorageStatus) < 1 then 
	doSetStorage(LMSStorageStatus, 1)
	doBroadcastMessage('Last Man Standing Event startuje. Chcesz dolaczyc? Wpisz: !lms join. Czekamy na '..LMSMaxPlayers..' graczy. Event wystartuje za 10 minut.')
	if getSpectators(LMSCenterRoomPosition, LMSRangeX_RangeY[1], LMSRangeX_RangeY[2]) then
		for _, cid in pairs(getSpectators(LMSCenterRoomPosition, LMSRangeX_RangeY[1], LMSRangeX_RangeY[2])) do
			if isMonster(cid) then doRemoveThing(cid) end
		end
	end
end
return true
end
]]></config>

<event type='statschange' name='LMSEventStatsChange' event='script'><![CDATA[
domodlib('LMSEvent_conf')
function onStatsChange(cid, attacker, type, combat, value)
if isMonster(attacker) and isPlayer(cid) and LMSMonsters[getCreatureName(attacker):lower()] and type == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(cid) then
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
	return loseOnLMSArena(cid) and false
end
return true
end
]]></event>

<globalevent name='LMSStart' type='start' event='script'><![CDATA[
domodlib('LMSEvent_conf')
function onStartup()
	return doSetStorage(LMSStorageStatus, 0)
end
]]></globalevent>

<moveevent type='stepIn' uniqueid='3005' event='script'><![CDATA[
domodlib('LMSEvent_conf')
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
if LMSJoinType == 'talkaction' then
	return doTeleportThing(cid, fromPosition, true)
end
if isPlayer(cid) then
	if getCreatureCondition(cid, CONDITION_INFIGHT) and getPlayerAccess(cid) < LMSAccesToIgnore then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Musisz byc w PZ bez mieczykow.')
	end
	if getPlayerAccess(cid) >= LMSAccesToIgnore then
		setLMSEventStart()
		return doTeleportThing(cid, LMSEnterPosition, true)
	elseif #getLMSEventPlayers() < LMSMaxPlayers and getStorage(LMSStorageStatus) == 1 then
		local msg = ''
		addPlayerToLMSArea(cid, true)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Jestes graczem numer '..#getLMSEventPlayers()..', ktory przylaczyl sie do eventu.')
		if #getLMSEventPlayers() == LMSMaxPlayers then
			doSetStorage(LMSStorageStatus, 2)
			for i = 1, LMSCountSpawnNewMonsters do
				spawnNewLMSMonster()
			end
			for _, v in pairs(getLMSEventPlayers()) do
				addPlayerToLMSArea(v, false)
			end
			msg = 'Last Man Standing Event rozpoczety. Mamy ' .. LMSMaxPlayers .. ' graczy, ktorzy dolaczyli do eventu! Dobrej zabawy!'
		else
			msg = getCreatureName(cid) .. ' wszedl do Last Man Standing Arena. Nadal potrzebujemy ' .. LMSMaxPlayers - #getLMSEventPlayers() .. ' graczy.'
		end
		return (msg ~= '' and doBroadcastMessage(msg) or true)
	else
		return doTeleportThing(cid, fromPosition, true) and doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Arena jest pelna.')
	end
end
return true
end
]]></moveevent>

<talkaction words='!lms' event='script'><![CDATA[
domodlib('LMSEvent_conf')
function onSay(cid, words, param, channel)
if LMSJoinType == 'movement' then
	return false 
end
if isInArray({'join','add','go','joined'}, param:lower()) then
	if getCreatureCondition(cid, CONDITION_INFIGHT) and getPlayerAccess(cid) <= LMSAccesToIgnore then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Musisz byc w PZ bez mieczykow.')
	end
	if getPlayerAccess(cid) >= LMSAccesToIgnore then
		setLMSEventStart()
		return doTeleportThing(cid, LMSEnterPosition, true)
	elseif #getLMSEventPlayers() < LMSMaxPlayers and getStorage(LMSStorageStatus) == 1 then
		local msg = ''
		addPlayerToLMSArea(cid, true)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Jestes graczem numer '..#getLMSEventPlayers()..', ktory przylaczyl sie do eventu.')
		if #getLMSEventPlayers() == LMSMaxPlayers then
			doSetStorage(LMSStorageStatus, 2)
			for i = 1, LMSCountSpawnNewMonsters do
				spawnNewLMSMonster()
			end
			for _, v in pairs(getLMSEventPlayers()) do
				addPlayerToLMSArea(v, false)
			end
			msg = 'Last Man Standing Event rozpoczety. Mamy ' .. LMSMaxPlayers .. ' graczy, ktorzy dolaczyli do eventu! Dobrej zabawy!'		else
			msg = getCreatureName(cid) .. ' wszedl do Last Man Standing Arena. Nadal potrzebujemy ' .. LMSMaxPlayers - #getLMSEventPlayers() .. ' graczy.'
		end
		return (msg ~= '' and doBroadcastMessage(msg) or true)
	else
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, (getStorage(LMSStorageStatus) == -1 and 'Event sie nie rozpoczal.' lub 'Arena jest pelna.'))
	end
elseif isInArray({'leave','abort','delete'}, param:lower()) then
	if getStorage(LMSStorageStatus) < 2 then
		doCreatureSetStorage(cid, LMSStorageStatus, 0)
		doCreatureSetNoMove(cid, false)
		return doTeleportThing(cid, getCreatureLastPosition(cid), true)
	end
	return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Nie mozesz wyjsc, event juz sie rozpoczal.')
end
return true
end
]]></talkaction>

<globalevent name="LMSTime" time="18:00" event="script"><![CDATA[
domodlib("LMSEvent_conf")
function onTime(time)
	addEvent(function()
						if getStorage(LMSStorageStatus) == 2 then 
							return true 
						end
						if getStorage(LMSStorageStatus) == 1 and #getLMSEventPlayers() >= LMSMinPlayers then
							doSetStorage(LMSStorageStatus, 2)
							for i = 1, LMSCountSpawnNewMonsters do
								spawnNewLMSMonster()
							end
							for _, v in ipairs(getLMSEventPlayers()) do
								addPlayerToLMSArea(v, false)
							end
							return doBroadcastMessage('LMS Event rozpoczety! Mamy '..#getLMSEventPlayers()..' graczy na arenie')
						end
						for _, v in ipairs(getLMSEventPlayers()) do
							kickPlayerFromLMSArea(v)
						end
						return doBroadcastMessage('LMS Event zatrzymany. Nie udalo nam sie zgromadzic graczy.')
						end,
						timeOnJoinToEvent * 1000 * 60)
						
	return setLMSEventStart()
end
]]></globalevent>

<event type="login" name="LMSEventLogin" event="script"><![CDATA[
function onLogin(cid)
	doCreatureSetStorage(cid, LMSStorageStatus, 0)
	return registerCreatureEvent(cid, 'LMSEventStatsChange')
end
]]></event>
</mod>
Przy starcie serwa wywala błąd:
Code:
theforgottenserver: luascript.h:266: static ScriptEnviroment* LuaInterface::getEnv(): Assertion `m_scriptEnvIndex >= 0 && m_scriptEnvIndex < 21' failed.

W czym tkwić może problem?
 
heheh skrypt oskara, jak już widzę, że on autorem, to już wiem, że szkoda życia na zrozumienie tego

chociaż to akurat przejrzyste jest

btw. nie lubię modów więc nie pomogę
 
to nie mój OTS.

Podałem linka właśnie do tej strony, ze względu na to, że zależy mi by skrypt działał na takiej samej zasadzie jak tam.
 
Back
Top