Serginov
Onkonkoronkonk
Last edited:
[10/03/2010 22:54:54] [Error - GlobalEvent Interface]
[10/03/2010 22:54:54] data/globalevents/scripts/BattleCheck.luanThink
[10/03/2010 22:54:54] Description:
[10/03/2010 22:54:54] data/globalevents/scripts/BattleCheck.lua:55: attempt to perform arithmetic on global 'battleTime' (a nil value)
[10/03/2010 22:54:54] stack traceback:
[10/03/2010 22:54:54] data/globalevents/scripts/BattleCheck.lua:55: in function <data/globalevents/scripts/BattleCheck.lua:41>
[10/03/2010 22:54:54] [Error - GlobalEvents::think] Couldn't execute event: TeamBattle
[10/03/2010 22:59:14] [Error - Npc interface]
[10/03/2010 22:59:14] data/npc/scripts/BattleNPC.luanCreatureSay
[10/03/2010 22:59:14] Description:
[10/03/2010 22:59:14] (luaGetCreatureStorage) Creature not found
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
local cfg =
{
signedUp1 = 100000,
signedUp2 = 100001,
maxPlayerEachTeam = 10,
team1Storage = 100002,
team2Storage = 100003,
team1Name = "Punishers",
team2Name = "Tha Artards"
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
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 and 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
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
npcHandler:say("Okay then.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, cfg.team1Name) and talkState[talkUser] == 2 then
if getGlobalStorageValue(cfg.team1Storage) ~= cfg.maxPlayerEachTeam then --fixed
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) .. " have joined the battle between " .. 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) --fixed
talkState[talkUser] = 1
end
elseif msgcontains(msg, cfg.team2Name) and talkState[talkUser] == 2 then
if getGlobalStorageValue(cfg.team2Storage) ~= cfg.maxPlayerEachTeam then --fixed
setPlayerStorageValue(cid, cfg.signedUp2, 1) --fixed
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) .. " have joined the battle between " .. 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)
talkState[talkUser] = 1
end
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(cid, cfg.signedUp1, -1) -- fixed
setGlobalStorageValue(cfg.team1Storage, (getGlobalStorageValue(cfg.team1Storage)-1))
npcHandler:say("You have left the battle.", cid)
doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " have left the battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
else
npcHandler:say("You are not even signed up!", cid)
end
talkState[talkUser] = 0 -- moved
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
if getPlayerStorageValue(cid, cfg.signedUp2) == 1 then --fixed
setPlayerStorageValue(cid, cfg.signedUp2, -1) --fixed
setGlobalStorageValue(cfg.team2Storage, (getGlobalStorageValue(cfg.team2Storage)-1))
npcHandler:say("You have left the battle.", cid)
doBroadcastMessage("[Team Battle]: " .. getPlayerName(cid) .. " have left the battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. "!", TALKTYPE_BROADCAST)
else
npcHandler:say("You are not even signed up!", cid)
end
talkState[talkUser] = 0 --moved
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
function onCombat(cid, target)
local team1Storage = 100002
if getPlayerStorageValue(cid, team1Storage) == 1 and getPlayerStorageValue(target, team1Storage) == 1 then
doPlayerSendCancel(cid, "You cannot attack your own team.")
return FALSE
end
end
local cfg =
{ team1Wall_id = 9785,
team2Wall_id = 9784,
team1Wall_pos = { x = 31948, y = 32111, z = 7 },
team2Wall_pos = { x = 31900, y = 32045, z = 7 },
signedUp1 == 100000,
signedUp2 == 100001,
maxPlayerEachTeam = 1,
team1Storage = 100002,
team2Storage = 100003,
team1Name = "The Good",
team2Name = "The Evil",
team1Pos = { x = 31951, y = 32119, z = 7 },
team2Pos = { x = 31900, y = 32036, z = 7 },
running = 100004,
battleTime = 25 -- Minutes
}
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)
setGlobalStorageValue(cfg.running, 0)
doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " is over.", 12)
doCreateItem(cfg.team2Wall_id, 1, cfg.team1Wall_pos)
doCreateItem(cfg.team2Wall_id, 1, cfg.team2Wall_pos)
end
function onThink(interval, lastExecution)
local team1Wall = getTileItemById(cfg.team1Wall_pos, cfg.team1Wall_id).uid
local team2Wall = getTileItemById(cfg.team2Wall_pos, cfg.team2Wall_id).uid
if getGlobalStorageValue(cfg.team1Storage) == -1 then
setGlobalStorageValue(cfg.team1Storage, 0)
end
if getGlobalStorageValue(cfg.team2Storage) == -1 then
setGlobalStorageValue(cfg.team2Storage, 0)
end
if getGlobalStorageValue(cfg.team1Storage) == cfg.maxPlayerEachTeam and getGlobalStorageValue(cfg.team2Storage) == cfg.maxPlayerEachTeam then
if getGlobalStorageValue(cfg.running) ~= 1 then
doBroadcastMessage("The battle between " .. cfg.team1Name .. " and " .. cfg.team2Name .. " has started! They will battle " .. cfg.maxPlayerEachTeam .. " vs " .. cfg.maxPlayerEachTeam .. "!", 12)
setGlobalStorageValue(cfg.running, 1)
addEvent(stopBattle, cfg.battleTime * 60 * 1000)
doRemoveItem(team1Wall)
doRemoveItem(team2Wall)
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
end
return true
end
@up
then... no one above you tested it :x and tell things like nice blah blah
change
addEvent(stopBattle, battleTime * 60 * 1000)
to
addEvent(stopBattle, cfg.battleTime * 60 * 1000)
if you find another bug like that do same way 8D
NPC fix i didnt see another error
EDIT: I didnt read the script so i didnt realize the PZ abuse so the script doesnt help, But The script doesnt even work in General so .. -.-