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

TP Item. Help! :)

Teddy

SweStream.se
Joined
Oct 2, 2008
Messages
3,797
Reaction score
10
Location
Sweden 172
Hello :)
can someone make so you cant use this in a zone (Like zombie event)
X , Y , Z TO X , Y , Z
PHP:
local removee = false -- to remove item set to true
 
local cooldown = 60 -- colldown to use it again
 
local storage = 1339 -- empty storage
 
function onUse(cid, item, frompos, item2, topos)
 
local temple = getTownTemplePosition(getPlayerTown(cid))
 
if(getPlayerStorageValue(cid, storage) > os.time()) then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, storage) - os.time()) == 1 and "" or "s") .. " to teleport.")
else    
 
		if not hasCondition(cid,CONDITION_INFIGHT) then
                                 doTeleportThing(cid,temple,false)
                                 doSendMagicEffect(temple,10)
                                 doPlayerSendTextMessage(cid,25,"Teleported to temple safely.")
				 setPlayerStorageValue(cid, storage, os.time() + cooldown)
 
                                               if removee == true then
	                                                     doRemoveItem(item.uid)
                                               end
 
                else
                                 doPlayerSendCancel(cid,"You can't teleport to temple during fight")
                end
end	 
 
return TRUE
end

Rep+
 
Last edited:
Lua:
local removee = false -- to remove item set to true
 
local cooldown = 60 -- colldown to use it again
 
local storage = 1339 -- empty storage
 
function onUse(cid, item, frompos, item2, topos)
 
local temple = {x=1000, y=1000, z=7}
 
if(getPlayerStorageValue(cid, storage) > os.time()) then
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, storage) - os.time()) == 1 and "" or "s") .. " to teleport.")
else    
 
		if not hasCondition(cid,CONDITION_INFIGHT) then
                                 doTeleportThing(cid,temple,false)
                                 doSendMagicEffect(temple,10)
                                 doPlayerSendTextMessage(cid,25,"Teleported to temple safely.")
				 setPlayerStorageValue(cid, storage, os.time() + cooldown)
 
                                               if removee == true then
	                                                     doRemoveItem(item.uid)
                                               end
 
                else
                                 doPlayerSendCancel(cid,"You can't teleport to temple during fight")
                end
end	 
 
return TRUE
end
 
no, just add that:
Lua:
if getPlayerStorageValue(cid, zombiestorage) == 1 then return true end
 
Can you atleast post the zombie script so i can see which storages get used.
 
Try:
Lua:
local removee = false -- to remove item set to true 
  
local cooldown = 60 -- colldown to use it again 
  
local storage = 1339 -- empty storage 
  
function onUse(cid, item, frompos, item2, topos) 
  
local temple = getTownTemplePosition(getPlayerTown(cid)) 

local zombiestorage = 34370

if getPlayerStorageValue(cid, zombiestorage) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Zombie Event") 
	return true 
end
  
if(getPlayerStorageValue(cid, storage) > os.time()) then 
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, storage) - os.time()) == 1 and "" or "s") .. " to teleport.") 
else     
  
        if not hasCondition(cid,CONDITION_INFIGHT) then 
                                 doTeleportThing(cid,temple,false) 
                                 doSendMagicEffect(temple,10) 
                                 doPlayerSendTextMessage(cid,25,"Teleported to temple safely.") 
                 setPlayerStorageValue(cid, storage, os.time() + cooldown) 
  
                                               if removee == true then 
                                                         doRemoveItem(item.uid) 
                                               end 
  
                else 
                                 doPlayerSendCancel(cid,"You can't teleport to temple during fight") 
                end 
end      
  
return TRUE 
end
 
Last edited:
[30/11/2012 14:57:48] [Error - LuaScriptInterface::loadFile] data/actions/scripts/hs.lua:13: unexpected symbol near 'if'
[30/11/2012 14:57:48] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/hs.lua)
[30/11/2012 14:57:48] data/actions/scripts/hs.lua:13: unexpected symbol near 'if'
error
 
How can i make so you cant use this tp item in team war

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team Event" version="2.0" author="iFATE" contact="otland.net/member/iFATE" enabled="yes">
 <description>
Credits goes to iFATE from OtLand, this version is for TFS 0.3.6:
 
		1- I currently rescripted this event from scratch again.
 
		2- This version is much more better than the one before, it is more cleaner, clearer and with more options.
 
		3- This version dislike the previous one , was tested on 0.3.6PL1 and works just fine.
 
		4- Removed the npc part it is now based on tp creation.
 
		5- More silent boradcasting for in event progress and no spam, I hope!
 
		6- you now get the options to show event stats on cancel msg area and (to / not to) show left players with names each x interval.
 
		8- Team balancer have been added to only balance count in both teams.
 
		9- Added a countdown option before fight starts.
 
		10- Now starts on a defined time every day
 
   </description>
 
<config name="teamSetting"><![CDATA[
--[[Local Config]]--
 
--//storages
 
inBlue = 9900 
inRed = 9901
joiner = 9907
 
blueKills = 9902
redKills = 9903
 
eventRecruiting = 9904
eventStarted = 9905
eventTime = 9906
 
itemToGet = 9908
countItemToGet = 9909
 
nextExecute = 9910
 
blueCount = 9911
redCount = 9912
 
--// Positions
 
teleporterPosition = {x = 994, y = 996, z = 7} 
 
waitRoomPlace = {x = 982, y = 895, z = 7} 
 
waitRoomDimensions = { 
							startPos = {x = 978, y = 891, z = 7}, 
							endPos = {x = 986, y = 898, z = 7}
							}
 
 
eventPlaceDimensions = { 
							startPos = {x = 810, y = 1266, z = 7}, 
							endPos = {x = 859, y = 1319, z = 7}
							}
blueTeamPos = {x = 849, y = 1314, z = 7}
redTeamPos = {x = 817, y = 1274, z = 7}
 
 
--// General settings
 
recruitTime = 1 
 
minimumPlayersJoins = 2 
 
balanceTeams = true 
 
 
removeTeleportOnEventEnd = false 
 
eventMaxTime = 5 
 
showEventSats = true 

 
sendLeftPlayers = true 			
intervalToSendLeftPlayers = 11 
 
 
countDownOnStart = true 

 
countDownFrom = 10  			
 
minJoinLevel = 50 
 
rewards = { 
 
					[65] = { {2476,1} , {"gold coin",500} },
					[25] = { {"golden armor",1} , {2152,90} },
					[10] = { {"dragon scale mail",1} , {"crystal coin",10} }
				}
 ]]></config>
 <lib name="teamFunctions"><![CDATA[
domodlib('teamSetting')
 
--[[Conditions don't touch]]--
local bmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bmale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bmale, {lookType = math.random(128,134), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
 
local bfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bfemale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bfemale, {lookType = math.random(136,142), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
 
local rmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rmale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(rmale, {lookType = math.random(128,134), lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
 
local rfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rfemale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(rfemale, {lookType = math.random(136,142),lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
 
local infight = createConditionObject(CONDITION_INFIGHT,-1)
--[[Local Config]]--
 
--[[Functions]]--
 
-- General info
function isFightOn()
	return getStorage(eventStarted) > 0
end
function isRecruitOn()
	return getStorage(eventRecruiting) > 0
end
function getMinJoinLevel()
	return minJoinLevel
end
function getJoiners()
	joiners = {}
	for _,cid in ipairs(getPlayersOnline()) do
		if isJoiner(cid) then
			if isInRecruitArea(cid) or isInFightArea(cid) then 
				table.insert(joiners,cid)
			end
		end
	end
	return joiners
end
 
function getLeftMembersNames(team)
	str = "Oponents left("..#team..") :"
	left = ""
	for k,cid in ipairs(team) do left  = (left ..""..(k == 1 and "" or ", ")..""..getCreatureName(cid).."["..getPlayerLevel(cid).."]" ) end
	str = str .." " .. (left == "" and "none" or left).. "."
	return str
end
function disPlayEventStats()
	if not showEventSats then return false end
	if getStorage(eventTime) - os.time() <= 0 then return false end
 
	left = os.date("%M:%S",(getStorage(eventTime) - os.time()))
	for _,cid in ipairs(getJoiners()) do 
		oponentsLeft = isBlue(cid) and #getRedMembers() or #getBlueMembers()
		teamMatesLeft = isBlue(cid) and math.max(0,#getBlueMembers()-1) or math.max(0,#getRedMembers()-1)
		doPlayerSendCancel(cid,"Time left: ".. left.."   ||   Oponents left: "..oponentsLeft.."/"..oponentCount(cid).."   ||   Team-mates left: "..teamMatesLeft.."/".. math.max(0,matesCount(cid)-1))
	end
 
end
 
function doSendLeftPlayers()
	if not sendLeftPlayers then return false end
	if intervalToSendLeftPlayers <= 10 then return false end
	for _,cid in ipairs(getJoiners()) do
		doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],getLeftMembersNames(isRed(cid) and getBlueMembers() or getRedMembers()))
	end
end
 
function getBlueMembers()
	members = {}
	for _,cid in ipairs(getPlayersOnline()) do 
		if isBlue(cid) then
			table.insert(members,cid)
		end
	end
	return members
end
function getRedMembers()
	members = {}
	for _,cid in ipairs(getPlayersOnline()) do 
		if isRed(cid) then
			table.insert(members,cid)
		end
	end
	return members
end
 
 
-- starting fight
 
function startRecruiting()
	doSetStorage(eventRecruiting,1)
end
function startEvent()
	doSetStorage(eventRecruiting,-1)
 
	if removeTeleportOnEventEnd then
		tp = getTileItemById(teleporterPosition,1387).uid
		if tp > 0 then doRemoveItem(tp) end
	end
 
	if not balanceTeams() then
		resetEvent()
		return false
	end
	for _,cid in ipairs(getBlueMembers()) do
		doTeleportThing(cid,blueTeamPos,false)
		doSendMagicEffect(getThingPos(cid),10)
	end
	setBlueCount(#getBlueMembers())
	for _,cid in ipairs(getRedMembers()) do
		doTeleportThing(cid,redTeamPos,false)
		doSendMagicEffect(getThingPos(cid),10)
	end
	setRedCount(#getRedMembers())
	startCountDown()
	return true
end
 
function setBlueCount(count)
	doSetStorage(blueCount,-1)
	doSetStorage(blueCount,count)
end
function oponentCount(cid)
	return isBlue(cid) and getStorage(redCount) or getStorage(blueCount)
end
function matesCount(cid)
	return isBlue(cid) and getStorage(blueCount) or getStorage(redCount)
end
 
function setRedCount(count)
	doSetStorage(redCount,-1)
	doSetStorage(redCount,count)
end
function balanceTeams()
	members = getJoiners()
	if #members < minimumPlayersJoins then
		doBroadcastMessage("Team-Battle event was cancelled as only ".. #members .. " players joined.")
		return false
	end
	if (math.mod(#members,2) ~= 0) then
		kicked = members[#members]
		clearTeamEventStorages(kicked)
		doPlayerSendTextMessage(kicked,MESSAGE_TYPES["info"],"Sorry, you have been kicked out of event for balancing both teams.")
	end
	count = 1
	for _,cid in ipairs(getJoiners()) do
		if (math.mod(count,2) ~= 0) then
			addToBlue(cid)
		else
			addToRed(cid)
		end
		count = count + 1
	end
	return true
end
function startCountDown()
	if(countDownOnStart) then
		for _,cid in ipairs(getJoiners()) do
			doCreatureSetNoMove(cid,true)
			for i = 0,countDownFrom do
				addEvent(doPlayerSendTextMessage,i*1000, cid, MESSAGE_TYPES["info"], (i == 0 and countDownFrom or countDownFrom-i) )
			end
		end
		addEvent(startFight,(countDownFrom+1)*1000)
	else
		startFight()
	end
end
function startFight()
	doSetStorage(eventStarted,1)
	for _,cid in ipairs(getJoiners()) do
		doCreatureSetNoMove(cid,false)
		doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],"Fight Starts!")
	end
	addEvent(endTeamEvent,eventMaxTime*60*1000,"maxTime")
	doSetStorage(eventTime,os.time()+eventMaxTime*60)
end
 
function teleportToWaitRoom(cid)
	doTeleportThing(cid,waitRoomPlace)
	doSendMagicEffect(waitRoomPlace,10)
	if getPlayerGroupId(cid) < 4 then
		addToJoiners(cid)
	end
	doPlayerSendTextMessage(cid,MESSAGE_TYPES["blue"],"Please be patient till the event starts and don't logout.")
	return true
end
 
 
 
-- Modifing teams & checking member states
function isBlue(cid)
	return (getPlayerStorageValue(cid,inBlue) > 0)
end
function isRed(cid)
	return (getPlayerStorageValue(cid,inRed) > 0)
end
function isJoiner(cid)
	return (getPlayerStorageValue(cid,joiner) > 0)
end
function addToBlue(cid)
	setPlayerStorageValue(cid,inBlue,1)
	doAddCondition(cid, (getPlayerSex(cid) == 1) and bmale or bfemale)
	doAddCondition(cid,infight)
end
function addToRed(cid)
	setPlayerStorageValue(cid,inRed,1)
	doAddCondition(cid, (getPlayerSex(cid) == 1) and rmale or rfemale)
	doAddCondition(cid,infight)
end
function addToJoiners(cid)
	setPlayerStorageValue(cid,joiner,1)
end
function removeFromBlue(cid)
	setPlayerStorageValue(cid,inBlue,-1)
end
function removeFromRed(cid)
	setPlayerStorageValue(cid,inRed,-1)
end
function removeFromjoiners(cid)
	setPlayerStorageValue(cid,joiner,-1)
end
function isInRecruitArea(cid)
	return isInRange(getThingPos(cid),waitRoomDimensions.startPos,waitRoomDimensions.endPos)
end
function isInFightArea(cid)
	return isInRange(getThingPos(cid),eventPlaceDimensions.startPos,eventPlaceDimensions.endPos)
end
function clearTeamEventStorages(cid)
	if isInRecruitArea(cid) or isInFightArea(cid) then
		doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
		doSendMagicEffect(getThingPos(cid),10)
	end
 
	if isFightOn() then
		if isJoiner(cid) then
			if isBlue(cid) then
				addRedKills()
			elseif isRed(cid) then
				addBlueKills()
			end
			doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"You have died in Team-Battle Event.")
		end
	end
 
	removeFromjoiners(cid)
	removeFromBlue(cid)
	removeFromRed(cid)
	doRemoveConditions(cid, false)
 
end
function haveUnrecivedReward(cid)
	return getPlayerStorageValue(cid,itemToGet) > 0 and getPlayerStorageValue(cid,countItemToGet) > 0 
end
function recieveLateReward(cid)
	if haveUnrecivedReward(cid) then
		if not doPlayerAddItem(cid,getPlayerStorageValue(cid,itemToGet),getPlayerStorageValue(cid,countItemToGet),false) then
			msg = "You need to free some space then relog to take your reward."
			doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],msg)
		else
			setPlayerStorageValue(cid,itemToGet,-1) 
			setPlayerStorageValue(cid,countItemToGet,-1)
			doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],"You have recieved your reward.")
		end
	end
end
 
-- Win or lose
function thereIsAWinner()
	if redWon() or blueWon() then
		return true
	end
	return false
end
function blueWon()
	return( (#getBlueMembers() > 0 ) and ( #getRedMembers() == 0) )
end
function redWon()
	return( (#getRedMembers() > 0) and (#getBlueMembers() == 0) )
end
function isDraw()
	return #getBlueMembers() == #getRedMembers()
end
function getWinner()
	if #getBlueMembers() > #getRedMembers() then
		return {getBlueMembers(),getRedMembers(),"Blue team won."}
	elseif #getRedMembers() > #getBlueMembers() then
		return {getRedMembers(),getBlueMembers(),"Red team won."}
	else
		return { {},{},"it was a draw."}
	end
end
 
 
-- Adding kills
function addBlueKills()
	doSetStorage(blueKills, math.max(1,getStorage(blueKills)+1))
end
function addRedKills()
	doSetStorage(redKills, math.max(1,getStorage(redKills)+1))
end
 
-- Ending event
 
function endTeamEvent(type)
	if isFightOn() then
		doSetStorage(eventStarted,-1)
		doBroadcastMessage("Team-Battle event ended and "..getWinner()[3])
		if not isDraw() then
			win(getWinner()[1],type)
			lose(getWinner()[2],type)
		else
			draw()
		end
	end
	addEvent(resetEvent,2 * 1000) --- tp player to home remove all storages and reset event global storages
end
 
function getPercent()
	rand= math.random(1,100)
	prev = 0
	chosenItem = 0
	for k, v in pairs(rewards) do 
		if rand > prev and rand <= k+prev then
			chosenItem = k
			break
		else
			prev =  k+prev
		end
	end
	return chosenItem
end
 
function generateReward(cid)
	percent = getPercent()
	if percent == 0 then
		print("Error in the reward item. Please inform iFATE.")
		return true
	end
 
	randomizer = rewards[percent][math.random(1,#rewards[percent])]
	item = not tonumber(randomizer[1]) and getItemIdByName(randomizer[1]) or randomizer[1]
	count = isItemStackable(item) and math.min(randomizer[2],100) or 1
	if item == nil or item == 0 then
		print("Error in the  item format. Please inform Doggynub.")
		return true
	end
 
	msg = "You have won ".. (count == 1 and "a" or count) .." " .. getItemNameById(item) .. "" .. (count == 1 and "" or "s").."."
 
	if not doPlayerAddItem(cid,item,count,false) then
		msg = msg.. "You need to free some space then relog to take your reward."
		setPlayerStorageValue(cid,itemToGet,item)
		setPlayerStorageValue(cid,countItemToGet,count)
	end
 
	doPlayerSendTextMessage(cid,MESSAGE_TYPES["white"],msg)
 
end
 
 
 
function generateStatsMessage(cid, type, stats)
	msg = {
					["KO"] = { ["win"] = "Event has been ended. Your team have won by killing all oponent's team members. You will recieve your reward shortly, check incoming messages.",
								["lose"] = "Event ended. Your team have lost as the Oponent team killed all your team's members."
							},
					["maxTime"] = {
									["win"] = "Event max-time finished and your team have won. You will recieve your reward shortly, check incoming messages.",
									["lose"] = "Event max-time finished and your team have lost.",
									["draw"] = "Event max-time finished and it is a draw.(no team won)"
								}
				}
	doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],msg[type][stats])
 
end
function win(winners,type)
	for _,cid in ipairs(winners) do
		generateStatsMessage(cid, type, "win")
		generateReward(cid)
	end
end
function lose(losers,type)
	for _,cid in ipairs(losers) do
		generateStatsMessage(cid, type, "lose")
	end
end
function draw()
	for _,cid in ipairs(getJoiners()) do
		generateStatsMessage(cid, "maxTime", "draw")
	end
end
 
function resetEvent()
	doSetStorage(eventRecruiting,-1)
	doSetStorage(nextExecute,-1)
	doSetStorage(eventStarted,-1)
	doSetStorage(eventTime,-1)
	doSetStorage(blueKills,-1)
	doSetStorage(redKills,-1)
	for _,cid in ipairs(getPlayersOnline()) do 
		if isBlue(cid) or isRed(cid) or isJoiner(cid) then
			clearTeamEventStorages(cid)
		end
	end
end
 
 
]]></lib>
 <event type="login" name="teambattleLogin" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onLogin(cid)
	clearTeamEventStorages(cid)
	recieveLateReward(cid)
 
	registerCreatureEvent(cid, "teamEventStats")
	registerCreatureEvent(cid, "teambattleLogout")
	registerCreatureEvent(cid, "teambattleCombat")
	return true
end
]]></event>
<event type="combat" name="teambattleCombat" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onCombat(cid, target)
	if isFightOn() then
		if isBlue(cid) and isBlue(target) then
			return false
		end
		if isRed(cid) and isRed(target) then
			return false
		end
	end
	return true
end
 
]]></event>
 <event type="logout" name="teambattleLogout" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onLogout(cid)
	clearTeamEventStorages(cid)
	if thereIsAWinner() then
		endTeamEvent("KO")
	end
	return true
end
 
]]></event>
<event type="statschange" name="teamEventStats" event="script"><![CDATA[
domodlib('teamFunctions')
 
corpse_ids = {
        [0] = 3065, -- female
        [1] = 3058 -- male
}
function onStatsChange(cid, attacker, type, combat, value)
	if combat == COMBAT_HEALING then
		return true
	end
	if getCreatureHealth(cid) > value then
		return true
	end
 
	if isInFightArea(cid) and isFightOn() then
		if isBlue(cid) or isRed(cid) then
			corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid))
			doCreateItem(2016, 2, getThingPos(cid))
			clearTeamEventStorages(cid)
			doItemSetAttribute(corpse, "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".n[Team-Event kill]") 
			doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
			if thereIsAWinner() then
				endTeamEvent("KO")
			end
 
			return false
 
		end
 
	end
 
	return true
end 
]]></event>
 
<globalevent name = "teamBattleStart" time="19:00" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onTimer()
	resetEvent()
	if getTileItemById(teleporterPosition,1387).uid < 1 then
		tp = doCreateItem(1387,1,teleporterPosition)
		doItemSetAttribute(tp, "aid", 9990)
	end
 
	startRecruiting()
	for i = 0, recruitTime-1 do
		addEvent(doBroadcastMessage, i * 60* 1000,"Team-Battle event is recruting players by entering event tp. Fight begins in "..(i == 0 and recruitTime or recruitTime-i).." minutes.",MESSAGE_TYPES["warning"])
	end
 
	addEvent(startEvent, recruitTime * 60 * 1000)
 
	return true
end
 
 
 ]]></globalevent>
 
<globalevent name = "teamBattletime" interval="1" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onThink()
	if isFightOn() then
		disPlayEventStats()
 
		if getStorage(nextExecute) == -1 or getStorage(nextExecute) <= os.time() then
			doSendLeftPlayers()
			doSetStorage(nextExecute,os.time()+intervalToSendLeftPlayers)
		end
	end
	return true
end
 
 ]]></globalevent>
<movevent type="StepIn" actionid="9990" event="script"><![CDATA[
domodlib('teamFunctions')
 
function onStepIn(cid, item, position, fromPosition)
	if not isRecruitOn() then
		doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Event isn't currently opened.")
		doTeleportThing(cid,fromPosition)
		doSendMagicEffect(fromPosition,2)
		return true
	end
	if getPlayerLevel(cid) < getMinJoinLevel() then
		doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Only players of level ".. getMinJoinLevel().. "+ can join this event.")
		doTeleportThing(cid,fromPosition)
		return true
	end
	teleportToWaitRoom(cid)
	return true
end
 
 
]]> </movevent>
</mod>
 
Enjoy!
Lua:
local removee = false -- to remove item set to true 
 
local cooldown = 60 -- colldown to use it again 
 
local storage = 1339 -- empty storage 
 
function onUse(cid, item, frompos, item2, topos) 
 
local temple = getTownTemplePosition(getPlayerTown(cid)) 
 
local zombiestorage = 34370

local teambattle = 9905
 
if getPlayerStorageValue(cid, zombiestorage) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Zombie Event") 
	return true 
end

if getPlayerStorageValue(cid, teambattle) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Team Battle Event") 
	return true 
end
 
if(getPlayerStorageValue(cid, storage) > os.time()) then 
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, storage) - os.time()) == 1 and "" or "s") .. " to teleport.") 
else     
 
        if not hasCondition(cid,CONDITION_INFIGHT) then 
                                 doTeleportThing(cid,temple,false) 
                                 doSendMagicEffect(temple,10) 
                                 doPlayerSendTextMessage(cid,25,"Teleported to temple safely.") 
                 setPlayerStorageValue(cid, storage, os.time() + cooldown) 
 
                                               if removee == true then 
                                                         doRemoveItem(item.uid) 
                                               end 
 
                else 
                                 doPlayerSendCancel(cid,"You can't teleport to temple during fight") 
                end 
end      
 
return TRUE 
end
 
And if i have fire well event
Code:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Fire_Lava_Event" version="1.0" author="iFate" contact="otland.net/members/iFate/" enabled="yes">

	<config name="lms_config">
		<![CDATA[
			configFire = {
				storage = 18998, -- set free storage
				eventStorage = 16254, -- set free storage
				joinEventStorage = 15535, -- set free storage
				countPlayerStorage = 17373, -- set free storage
				exhaustStorage = 18387,

				maxPlayers = 50, -- max players in event
				teleportPos = {x=916 ,y=43,z=7}, -- position to which player is teleporting
				rewardID = {2160,6132,9693},  -- reward id which player can win (reward is random)
				minLevel = 1, -- minimum of level with which player can join to event
				days = {
					['Monday'] = {'20:00:00'},
					['Tuesday'] = {'20:00:00'}, 
					['Wednesday'] = {'20:00:00'},
					['Thursday'] = {'20:00:00'}, 
					['Friday'] = {'20:00:00'},
					['Saturday'] = {'20:00:00'},
					['Sunday'] = {'20:00:00'}
				},
				minPlayers = 2,

				delayTime = 3.0, -- time in which players who joined to event are teleporting to teleport position
				timeToStartEvent = 30 -- time from teleport to start event
			}

			arena = {fromPos = {x=717,y=1060,z=7}, -- left top corner of event room
					toPos = {x=767,y=1095,z=7} -- right bottom corner of event room
			}
			
			y, x = 1, 1
		]]>
	</config>
	
	<lib name="lms_fire_lib">
		<![CDATA[
			function doStartEvent()
				doSetStorage(configFire.joinEventStorage, -1)
				
				if configFire.minPlayers <= getStorage(configFire.countPlayerStorage) + 1 then		
					for _, cid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(cid, configFire.storage) == 1 then
							addEvent(doSetStorage, configFire.timeToStartEvent * 1000, configFire.eventStorage, 1)
							doCreatureSetStorage(cid, configFire.storage, -1)
							doCreatureSetNoMove(cid, false)
							doRemoveCondition(cid, CONDITION_INFIGHT)

							doTeleportThing(cid, configFire.teleportPos)

							doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Get ready. Event start in ' .. configFire.timeToStartEvent .. ' sec.')
						end
					end
				else
					for _, cid in ipairs(getPlayersOnline()) do
						if getCreatureStorage(cid, configFire.storage) == 1 then
							doCreatureSetNoMove(cid, false)
							doRemoveCondition(cid, CONDITION_INFIGHT)
						end
					end
					doBroadcastMessage('Fire Storm have started beacuse there were enough players.', MESSAGE_EVENT_ADVANCE)
				end
				
				doSetStorage(configFire.countPlayerStorage, 0)
			end
		]]>
	</lib>

	<talkaction words="!event" event="script">
		<![CDATA[
			domodlib("lms_config")

			function onSay(cid, words, param)
				local storage, playerJoined, counter = getCreatureStorage(cid, configFire.storage), {}, getStorage(configFire.countPlayerStorage)

				if getStorage(configFire.joinEventStorage) == 1 then
					if(param == '') then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Command param required (say: "!event join" or "!event leave").')
					end
					
					if configFire.minLevel ~= nil then
						if getPlayerLevel(cid) < configFire.minLevel then
							return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join to event if you do not have a require level. [' .. configFire.minLevel .. ']')
						end
					end
					
					if getTileInfo(getThingPos(cid)).protection ~= true then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join to event if are not in protection zone.')
					end
					
					if exhaustion.check(cid, configFire.exhaustStorage) ~= false then
						return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must to wait a ' .. exhaustion.get(cid, configFire.exhaustStorage) .. ' sec.')
					end

					if param == 'join' then
						if storage <= 0 then
							if counter ~= configFire.maxPlayers - 1 then
								doSetStorage(configFire.countPlayerStorage, 0)
								for _, pid in ipairs(getPlayersOnline()) do
									if getCreatureStorage(pid, configFire.storage) > 0 then
										table.insert(playerJoined, pid)
										doSetStorage(configFire.countPlayerStorage, #playerJoined)
									end
								end
								local count = getStorage(configFire.countPlayerStorage)
								doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, count == 0 and 'You are first in event.' or count == 1 and 'There is 1 player in event.' or count > 1 and 'There are '.. count ..' players in event.')
								doCreatureSetStorage(cid, configFire.storage, 1)
								
								doCreatureSetNoMove(cid, true)
								local condition = createConditionObject(CONDITION_INFIGHT,-1)
								
								doAddCondition(cid, condition)
								doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have joined to event. You can not move until event do not start. Wait patiently for event start.')
							else
								doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Max players in event have been reached.')
							end
						else
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You arleady joined to event. Wait patiently for start.')
						end
					elseif param == 'leave' then
						if storage > 0 then
							doCreatureSetNoMove(cid, false)
							doRemoveCondition(cid, CONDITION_INFIGHT)
							doCreatureSetStorage(cid, configFire.storage, -1)
							doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You leave from event. And you can moving now.')
						else
							doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not leave from event.')
						end
					end
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join/leave to event yet.')
				end
				
				exhaustion.set(cid, configFire.exhaustStorage, 5)
				
				return true
			end
		]]>
	</talkaction>
	
	<talkaction words="!startfire" access="5" event="script">
		<![CDATA[
			domodlib("lms_config")
			domodlib("lms_fire_lib")

			function onSay(cid, words, param)
				doBroadcastMessage('Fire Storm Event will start in ' .. configFire.delayTime .. ' min. You can join to event by say "!event join".', MESSAGE_EVENT_ADVANCE)

				for _, pid in ipairs(getPlayersOnline()) do
					if getCreatureStorage(pid, configFire.storage) == 1 then
						doCreatureSetStorage(pid, configFire.storage, -1)
						doSetStorage(configFire.countPlayerStorage, 0)
						doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
					end
				end

				doSetStorage(configFire.joinEventStorage, 1)		
				addEvent(doStartEvent, configFire.delayTime * 60 * 1000)
				return true
			end
		]]>
	</talkaction>

	<event type="think" name="LMS_Event_Start" event="script">
		<![CDATA[
			domodlib("lms_config")
			domodlib("lms_fire_lib")

			local daysOpen = {}
			
			for k, v in pairs(configFire.days) do
				table.insert(daysOpen, k)
			end
			
			function onThink(cid, interval)
				if isInArray(daysOpen, os.date('%A')) then
					if isInArray(configFire.days[os.date('%A')], os.date('%X', os.time())) then
						if getStorage(configFire.joinEventStorage) ~= 1 then
							doBroadcastMessage('Fire Storm Event will start in '.. configFire.delayTime ..' min. You can join to event by say "!event join".', MESSAGE_EVENT_ADVANCE)

							for _, pid in ipairs(getPlayersOnline()) do
								if getCreatureStorage(pid, configFire.storage) == 1 then
									doCreatureSetStorage(pid, configFire.storage, -1)
									doSetStorage(configFire.countPlayerStorage, 0)
									doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
								end
							end

							doSetStorage(configFire.joinEventStorage, 1)		
							addEvent(doStartEvent, configFire.delayTime * 60 * 1000)
						end
					end
				end
				return true
			end
		]]>
	</event>
	
	<globalevent name="LMS_Event" interval="1000" event="script">
		<![CDATA[
			domodlib("lms_config")

			function onThink(interval, lastExecution)
				if getStorage(configFire.eventStorage) == 1 then
					local xTable, yTable, playerTable = {}, {}, {}

					for x = arena.fromPos.x, arena.toPos.x do
						for y = arena.fromPos.y, arena.toPos.y do
							table.insert(xTable, x)
							table.insert(yTable, y)

							local n, i = getTileInfo({x=x, y=y, z=7}).creatures, 1
							if n ~= 0 then
								local v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
								while v ~= 0 do
									if isPlayer(v) then
										table.insert(playerTable, v)
										if n == #playerTable then
											break
										end
									end
									i = i + 1
									v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
								end
							end
						end
					end

					if #playerTable == 1 then
						local prize = math.random(#configFire.rewardID)

						doTeleportThing(playerTable[1], getTownTemplePosition(getPlayerTown(playerTable[1])), true)
						doPlayerAddItem(playerTable[1], configFire.rewardID[prize], 1)
						doPlayerSendTextMessage(playerTable[1], MESSAGE_EVENT_ADVANCE, 'You win. Your reward is ' .. getItemNameById(configFire.rewardID[prize]) .. '.')
						doBroadcastMessage('Fire Storm Event have finished. The winner is ' .. getCreatureName(playerTable[1]) .. '. Congratulations.', MESSAGE_EVENT_ADVANCE)
						doSetStorage(configFire.eventStorage, -1)
						
						x, y = 1, 1
					elseif #playerTable > 1 then
						for a = 1, y do
							local pos = {x=xTable[math.random(#xTable)], y=yTable[math.random(#yTable)], z=7}

							for _, player in ipairs(playerTable) do
								local pPos = getThingPos(player)
								if pPos.x == pos.x and pPos.y == pos.y and pPos.z == pos.z then
									doCreatureAddHealth(player, - getCreatureMaxHealth(player))
								end
							end
							doSendDistanceShoot({x = pos.x - math.random(4, 6), y = pos.y - 5, z = pos.z}, pos, CONST_ANI_FIRE)
							
							addEvent(doSendMagicEffect, 150, pos, CONST_ME_HITBYFIRE)
							addEvent(doSendMagicEffect, 150, pos, CONST_ME_FIREAREA)
						end
						if x == 5 * y then
							y = y + 1
						end
						
						x = x + 1
					else
						doBroadcastMessage('No one win in Fire Storm Event.', MESSAGE_EVENT_ADVANCE)
						doSetStorage(configFire.eventStorage, -1)
						x, y = 1, 1
					end
				end			
				return true
			end
		]]>
	</globalevent>

	<event type="login" name="LMS_Fire_login" event="script">
		<![CDATA[
			function onLogin(cid)
				if getCreatureStorage(cid, configFire.storage) == 1 then
					doCreatureSetStorage(cid, configFire.storage, -1)
					doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
					doCreatureSetNoMove(cid, false)
					doRemoveCondition(cid, CONDITION_INFIGHT)
				end

				registerCreatureEvent(cid, "LMS_fire_dead")
				registerCreatureEvent(cid, "LMS_Event_Start")
				return true
			end
		]]>
	</event>

	<event type="statschange" name="LMS_fire_dead" event="script">
		<![CDATA[
			domodlib("lms_config")

			function onStatsChange(cid, attacker, type, combat, value)
				if type == 1 and getCreatureHealth(cid) <= value then
					if isInRange(getThingPos(cid), arena.fromPos, arena.toPos) then
						doCreatureAddHealth(cid, - getCreatureHealth(cid) + 1)
						doCreatureAddMana(cid, - getCreatureMana(cid))
						doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
						doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You loss.')
						return false
					end
				end
				return true
			end
		]]>
	</event>
</mod>
I guess i just do like this ?
Code:
local removee = false -- to remove item set to true 
 
local cooldown = 60 -- colldown to use it again 
 
local storage = 1339 -- empty storage 
 
function onUse(cid, item, frompos, item2, topos) 
 
local temple = getTownTemplePosition(getPlayerTown(cid))
 
local zombiestorage = 34370
 
local teambattle = 9905

local firew = 18998
 
if getPlayerStorageValue(cid, zombiestorage) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Zombie Event") 
	return true 
end
 
if getPlayerStorageValue(cid, teambattle) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Team Battle Event") 
	return true 
end

if getPlayerStorageValue(cid, firew) >= 1 then 
	doPlayerSendCancel(cid,"You can't teleport to temple during Fire Well Event") 
	return true 
end
 
if(getPlayerStorageValue(cid, storage) > os.time()) then 
   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You must wait another " .. getPlayerStorageValue(cid, storage) - os.time() .. ' second' .. ((getPlayerStorageValue(cid, storage) - os.time()) == 1 and "" or "s") .. " to teleport.") 
else     
 
        if not hasCondition(cid,CONDITION_INFIGHT) then 
                                 doTeleportThing(cid,temple,false) 
                                 doSendMagicEffect(temple,10) 
                                 doPlayerSendTextMessage(cid,25,"Teleported to temple safely.") 
                 setPlayerStorageValue(cid, storage, os.time() + cooldown) 
 
                                               if removee == true then 
                                                         doRemoveItem(item.uid) 
                                               end 
 
                else 
                                 doPlayerSendCancel(cid,"You can't teleport to temple during fight") 
                end 
end      
 
return TRUE 
end
 
Back
Top