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

[Help] Weird error..

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
I made a script for my Team battle event~
And I get this error when I reload Globalevents or Restart the server:
[Error - GlobalEvent Interface]
dara/globalevents/scripts/Battle_Check.lua
Description:
(internalGetPlayerInfo) Player not found when requesting player info #7

And here's my script,
LUA:
-- Script 
-- by
-- Slaktaren/Gatupojk

	local cfg = {
			signedUp1 == 100000,
			signedUp2 == 100001,
			maxPlayerEachTeam = 10,
			team1Storage = 100002,
			team2Storage = 100003,
			team1Name = "Punishers",
			team2Name = "Tha Artards",
			team1Pos = { x = 32316, y = 31942, z = 7 },
			team2Pos = { x = 32318, y = 31934, z = 7 },
			townPos = getTownTemplePosition(getPlayerTown(cid))
			}

function stopBattle()

local players3 = getOnlinePlayers()
	for c,playerName3 in ipairs(players3) do
		local player3 = getPlayerByName(playerName3)

		if getPlayerStorageValue(player3, cfg.signedUp1) == 1 or getPlayerStorageValue(player3, cfg.signedUp2) == 1 then
			doTeleportThing(player3[c], cfg.townPos, FALSE)
			doSendMagicEffect(cfg.team2Pos, CONST_ME_TELEPORT) 
			doSendMagicEffect(getCreaturePosition(player2[b]), CONST_ME_POFF) 
			setPlayerStorageValue(player3, cfg.signedUp1, -1)
			setPlayerStorageValue(player3, cfg.signedUp2, -1)
			setGlobalStorageValue(cfg.team1Storage, -1)
			setGlobalStorageValue(cfg.team2Storage, -1)
			setGlobalStorageValue(cfg.team1Storage, 0)
			setGlobalStorageValue(cfg.team2Storage, 0)
			doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " is over.", TALKTYPE_BROADCAST)
		end
	end
end


function onThink(interval, lastExecution)

	if getGlobalStorageValue(cfg.team1Storage) == cfg.maxPlayerEachTeam and getGlobalStorageValue(cfg.team2Storage) == cfg.maxPlayerEachTeam then
		
		doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " has started! They will battle " .. cfg.maxPlayerEachTeam .. " vs " .. cfg.maxPlayerEachTeam .. "!", TALKTYPE_BROADCAST)
		addEvent(stopBattle, 25 * 60 * 1000)
							
		local players1 = getOnlinePlayers() 
		for a,playerName1 in ipairs(players1) do 
			local player1 = getPlayerByName(playerName1); 
			
			if getPlayerStorageValue(player1, cfg.signedUp1) == 1 then
				doTeleportThing(player1[a], cfg.team1Pos, FALSE) 
				doSendMagicEffect(cfg.team1Pos, CONST_ME_TELEPORT) 
				doSendMagicEffect(getCreaturePosition(player1[a]), CONST_ME_POFF) 
			
			
				local players2 = getOnlinePlayers() 
				for b,playerName2 in ipairs(players2) do 
					local player2 = getPlayerByName(playerName2); 

					if getPlayerStorageValue(player2, signedUp2) == 1 then
						doTeleportThing(player2[b], cfg.team2Pos, FALSE) 
						doSendMagicEffect(cfg.team2Pos, CONST_ME_TELEPORT) 
						doSendMagicEffect(getCreaturePosition(player2[b]), CONST_ME_POFF) 
					end
				end
			end
		end
	end
	return TRUE
end
 
LUA:
local cfg =
    {
        signedUp1 == 100000,
        signedUp2 == 100001,
        maxPlayerEachTeam = 10,
        team1Storage = 100002,
        team2Storage = 100003,
        team1Name = "Punishers",
        team2Name = "Tha Artards",
        team1Pos = { x = 32316, y = 31942, z = 7 },
        team2Pos = { x = 32318, y = 31934, z = 7 },
        -- this is nil
        -- townPos = getTownTemplePosition(getPlayerTown(cid))
        -- this is nil
    }

function stopBattle()
    for _, cid in ipairs(getPlayersOnline()) do
        if getPlayerStorageValue(cid, cfg.signedUp1) == 1 or getPlayerStorageValue(cid, cfg.signedUp2) == 1 then
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
            doSendMagicEffect(cfg.team2Pos, CONST_ME_TELEPORT)
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            setPlayerStorageValue(cid, cfg.signedUp1, -1)
            setPlayerStorageValue(cid, cfg.signedUp2, -1)
        end
    end
    setGlobalStorageValue(cfg.team1Storage, -1)
    setGlobalStorageValue(cfg.team2Storage, -1)
    setGlobalStorageValue(cfg.team1Storage, 0)
    setGlobalStorageValue(cfg.team2Storage, 0)
    doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " is over.", TALKTYPE_BROADCAST)
end


function onThink(interval, lastExecution)
    if getGlobalStorageValue(cfg.team1Storage) == cfg.maxPlayerEachTeam and getGlobalStorageValue(cfg.team2Storage) == cfg.maxPlayerEachTeam then
        doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " has started! They will battle " .. cfg.maxPlayerEachTeam .. " vs " .. cfg.maxPlayerEachTeam .. "!", TALKTYPE_BROADCAST)
        addEvent(stopBattle, 25 * 60 * 1000)
        for _, cid in ipairs(getPlayersOnline()) do
            if getPlayerStorageValue(cid, cfg.signedUp1) == 1 then
                doTeleportThing(cid, cfg.team1Pos, FALSE)
                doSendMagicEffect(cfg.team1Pos, CONST_ME_TELEPORT)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            elseif getPlayerStorageValue(cid, signedUp2) == 1 then
                doTeleportThing(cid, cfg.team2Pos, FALSE)
                doSendMagicEffect(cfg.team2Pos, CONST_ME_TELEPORT)
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
            end
        end
    end
    return true
end
 
Last edited:
Thank you! I hope it works :) Can't test it 100% yet because my other script ain't finished!

EDIT; It works! When all the slots are taken it teleports me to the right position. :)
If not all spots taken, but at least 1 is then these errors show up:
[Error - Npc interface ]
dara/npc/scripts/events/BattleNPC.lua:onCreatureSay
Description:
(luaDoCreatureSetStorage) Creature not found
[Warning - Player::setStorage ] Unkown reserved key: 10000099 for player: God Gatupojk


[Error - Npc interface ]
dara/npc/scripts/events/BattleNPC.lua:onCreatureSay
Description:
(luaDoCreatureSetStorage) Creature not found

and here's my NPC script:
LUA:
 -- Script 
-- by
-- Slaktaren/Gatupojk

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end


function creatureSayCallback(cid, type, msg)

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	local cfg = {
			signedUp1 = 100000,
			signedUp2 = 100001,
			maxPlayerEachTeam = 10,
			team1Storage = 100002,
			team2Storage = 100003,
			team1Name = "Punishers",
			team2Name = "Tha Artards",
			joinMsg = "have joined the battle between",
			leaveMsg = "have left the battle between"
			}
	
	-- START --
	if getGlobalStorageValue(cfg.team1Storage) == -1 then
		setGlobalStorageValue(cfg.team1Storage, 0)
	end
	
	if getGlobalStorageValue(cfg.team2Storage) == -1 then
		setGlobalStorageValue(cfg.team2Storage, 0)
	end
	
	
	if msgcontains(msg, 'battle') then
		npcHandler:say("Do you wish to join the battle? There is currently " .. getGlobalStorageValue(cfg.team1Storage) .. "/" .. cfg.maxPlayerEachTeam .. " players in {" .. cfg.team1Name .. "} team and " .. getGlobalStorageValue(cfg.team2Storage) .. "/" .. cfg.maxPlayerEachTeam .. " players in {" .. cfg.team2Name .. "} team.", cid)
		talkState[talkUser] = 1

		elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
			if getPlayerStorageValue(cid, cfg.signedUp1) ~= 1 then
				if getPlayerStorageValue(cid, cfg.signedUp2) ~= 1 then
					npcHandler:say("Do you wish to join {" .. cfg.team1Name .. "} or {" .. cfg.team2Name .. "}?", cid)
					talkState[talkUser] = 2
				else
					npcHandler:say("You are already signed up!", cid)
					talkState[talkUser] = 0
				end
			else
				npcHandler:say("You are already signed up!", cid)
			end
			
				elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
				npcHandler:say("Okay than.", cid)
				talkState[talkUser] = 0
			
							-- JOINING BATTLE --
					elseif msgcontains(msg, cfg.team1Name) and talkState[talkUser] == 2 then
						if getGlobalStorageValue(cfg.team1Storage) ~= 10 then
							setPlayerStorageValue(cid, cfg.signedUp1, 1)
							setGlobalStorageValue(cfg.team1Storage, (getGlobalStorageValue(cfg.team1Storage)+1))
							npcHandler:say("You have joined " .. cfg.team1Name .. "! When both teams have " .. cfg.maxPlayerEachTeam .. " players you will be teleported to the battle arena.", cid)
							doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " " .. cfg.joinMsg .. " " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
							talkState[talkUser] = 0
						else
							npcHandler:say("{" .. cfg.team1Name .. "} is currently full, join {" .. cfg.team2Name .. "} or wait for someone to leave {" .. cfg.team1Name .. "}.", cid)
						end
		
							elseif msgcontains(msg, cfg.team2Name) and talkState[talkUser] == 2 then
								if getGlobalStorageValue(cfg.team2Storage) ~= 10 then
									setPlayerStorageValue(cfg.signedUp2, 1)
									setGlobalStorageValue(cfg.team2Storage, (getGlobalStorageValue(cfg.team2Storage)+1))
									npcHandler:say("You have joined " .. cfg.team2Name .. "! When both teams have " .. cfg.maxPlayerEachTeam .. " players you will be teleported to the battle arena.", cid)
									doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " " .. cfg.joinMsg .. " " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
									talkState[talkUser] = 0
								else
									npcHandler:say("{" .. cfg.team2Name .. "} is currently full, join {" .. cfg.team1Name .. "} or wait for someone to leave {" .. cfg.team2Name .. "}.", cid)
								end
							-- JOINING BATTLE END --
				
										-- LEAVING BATTLE --
									elseif msgcontains(msg, 'leave') then
										npcHandler:say("Do you wish to leave the battle?", cid)
										talkState[talkUser] = 3
			
										elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
											if getPlayerStorageValue(cfg.signedUp1) == 1 then
												setPlayerStorageValue(cfg.signedUp1, -1)
												setGlobalStorageValue(cfg.team1Storage, (getGlobalStorageValue(cfg.team1Storage)-1))
												npcHandler:say("You have left the battle.", cid)
												doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " " .. cfg.leaveMsg .. " " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
												talkState[talkUser] = 0
											else
												npcHandler:say("You are not even signed up!", cid)
											end
				
											elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
												if getPlayerStorageValue(cfg.signedUp2) == 1 then
													setPlayerStorageValue(cfg.signedUp2, -1)
													setGlobalStorageValue(cfg.team2Storage, (getGlobalStorageValue(cfg.team2Storage)-1))
													npcHandler:say("You have left the battle.", cid)
													doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " " .. cfg.leaveMsg .. " " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
													alkState[talkUser] = 0
												else
													npcHandler:say("You are not even signed up!", cid)
												end			
	end													
	return true
end

    if(npcHandler.focus ~= cid) then
        return false
    end
	

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

EDIT3; If you have time and can fix, please make so everybody needs to be in a protection zone when they gonna get teleported
 
Last edited:
Back
Top