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

GlobalEvent Race Event

UpInSmoke

Supreme Ruler
Joined
Nov 16, 2008
Messages
303
Reaction score
21
Heres a race event that i made;
global events:

raceTP.lua -- creates a TP in event room every ~ minutes for event
Lua:
local createpos = {x = 818, y = 1205, z = 7} -- Where tp will appear
 local topos = {x = 872, y = 1204, z = 7} -- Where will the Teleport take you
 local msg = "Race TP is now closed. It will open again in 1 hour!"
 local timetoclose = 120 -- in second

 local function remove()
 local tp = getTileItemById(createpos,1387).uid
 if tp ~= 0 then
 doRemoveItem(tp)
 doBroadcastMessage(msg)
 end
 end

 function onThink(interval)

 doCreateTeleport(1387, topos, createpos)
 doBroadcastMessage("Race TP is now open!\nCatch the teleport within "..timetoclose.." seconds! Teleport is Located in Events room.")
 addEvent(remove,timetoclose*1000)
 return true
 end

race.lua -- if someone wins, will teleport everyone else out of event.. make sure event is PZ and NOlogout
Lua:
function onThink(cid, interval, lastExecution)
		for _, name in ipairs(getOnlinePlayers()) do
		local mage = {1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30}
		local paladin = {3, 7, 11, 15, 19, 23, 27, 31}
		local player = getPlayerByName(name)
			if getPlayerStorageValue(player, 70100) == 1 and getGlobalStorageValue(player, 80050) == 5 then
				doTeleportThing(player, {x = 1343, y = 1424, z = 7})
				doChangeSpeed(player, getPlayerStorageValue(player, 70101))
				setPlayerStorageValue(player, 70100, 0)
				doPlayerLearnInstantSpell(player, "utani hur")
				if isInArray(mage,getPlayerVocation(player)) then
				doPlayerLearnInstantSpell(player, "utani gran hur")
				end
				if isInArray(paladin,getPlayerVocation(player)) then
				doPlayerLearnInstantSpell(player, "utani hur")
				end
			end
		end
	return true
end
globalevents.xml
Code:
	<globalevent name="Race" interval="1" event="script" value="race.lua"/>
	<globalevent name="RaceTP" interval="3600" event="script" value="raceTP.lua"/>

actions
race.lua -- modified anni, have 4 spots for players to stand, then lever.
Lua:
local config = {
	daily = "no", -- allow only one enter per day? (like in global Tibia)
	level = 100,
	storage = 30015,
	entry =
	{
		{x = 875, y = 1201, z = 7},
		{x = 875, y = 1203, z = 7},
		{x = 875, y = 1205, z = 7},
		{x = 875, y = 1207, z = 7}
	},
	destination =
	{
		{x = 892, y = 1197, z = 7},
		{x = 892, y = 1202, z = 7},
		{x = 892, y = 1207, z = 7},
		{x = 892, y = 1212, z = 7}
	}
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1946) then
		if(config.daily) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end

		return true
	end

	if(item.itemid ~= 1945) then
		return true
	end

	local players = {}
	for _, position in ipairs(config.entry) do
		local pid = getTopCreature(position).uid
		if(pid == 0 or not isPlayer(pid)) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end

		table.insert(players, pid)
	end

	for i, pid in ipairs(players) do
	local mage = {1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30}
	local paladin = {3, 7, 11, 15, 19, 23, 27, 31}
		doSendMagicEffect(config.entry[i], CONST_ME_POFF)
		doTeleportThing(pid, config.destination[i], false)
		doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "The race has begun! GO!")
		setPlayerStorageValue(pid, 70101, getCreatureSpeed(pid))
		doChangeSpeed(pid, 220 - getCreatureBaseSpeed(pid))
		setPlayerStorageValue(pid, 70100, 1)
		doPlayerUnlearnInstantSpell(pid, "utani hur")
			if isInArray(mage,getPlayerVocation(pid)) then
				doPlayerUnlearnInstantSpell(pid, "utani gran hur")
			end
			if isInArray(paladin,getPlayerVocation(pid)) then
				doPlayerUnlearnInstantSpell(pid, "utani hur")
			end
		setGlobalStorageValue(cid, 80050, 0)
		doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
	end

	doTransformItem(item.uid, item.itemid + 1)
	return true
end

actions.xml
Code:
<action uniqueid="15500-15503" event="script" value="other/race.lua"/>
movements

finishRace.lua -- put underneath the TP at end of race (dont actually put any co-ordinates in TP.. just for look)
Lua:
local t = {
prize = 2159,
name = "epic donation coin",
amount = 1,
temple = {x = 1343, y = 1424, z = 7},
}
function onStepIn(cid, item, position, fromPosition)
	if getGlobalStorageValue(cid, 80050) ~= 5 then
		doPlayerAddItem(cid, t.prize, t.amount)
		doPlayerSendTextMessage(cid, 19, "Congratulations! Youve won "..t.amount.." "..t.name.."!")
		local name = getCreatureName(cid)
		doBroadcastMessage(name.." won the race!")
		setGlobalStorageValue(cid, 80050, 5)
		doTeleportThing(cid, t.temple)
	else
		doPlayerSendTextMessage(cid, 19, "Sorry you lost the race.")
		doTeleportThing(cid, t.temple)
	end
return true
end
movements.xml
Code:
<movevent type="StepIn" uniqueid="14500-14503" event="script" value="finishRace.lua"/>
heres a sample map
View attachment racemap.zip
enjoy, REP++ if you like ^_^
 
Last edited:
Good thing you made use of doChangeSpeed's delta behavior
 
so what unique id i have to use in the lever??
 
mm i don't understad how it will work with any unique id...and could this lever be pulled by the god? away from the 4 players?
 
just make a lever and put uniqueid = 5002 and put it in actions but make sure the lever id = 1945
 
mm i don't understad how it will work with any unique id...and could this lever be pulled by the god? away from the 4 players?

This is a auto-maintaining event, meaning you dont have to be online or anything for the players to play, this one is set up so that it executes once every hour, which in my opinion will make players happier (expecially ones that are in different time zones then yourself)
 
mmm ok, but if i don't want it to be auto-maintaining...i just don't use the first script right? everything else should work fine right? and could the god pull the lever? becaue when i (god) try it, it says you are not a paladin >.<
 
mmm ok, but if i don't want it to be auto-maintaining...i just don't use the first script right? everything else should work fine right? and could the god pull the lever? becaue when i (god) try it, it says you are not a paladin >.<

Well youll still need a script to teleport the players into the race,
post the script you are using
 
global event
Lua:
function onThink(cid, interval, lastExecution)
		for _, name in ipairs(getOnlinePlayers()) do
		local mage = {1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30}
		local paladin = {3, 7, 11, 15, 19, 23, 27, 31}
		local player = getPlayerByName(name)
			if getPlayerStorageValue(player, 70100) == 1 and getGlobalStorageValue(player, 80050) == 5 then
				doTeleportThing(player, {x = 1319, y = 391, z = 7})
				doChangeSpeed(player, getPlayerStorageValue(player, 70101))
				setPlayerStorageValue(player, 70100, 0)
				doPlayerLearnInstantSpell(player, "utani hur")
				if isInArray(mage,getPlayerVocation(player)) then
				doPlayerLearnInstantSpell(player, "utani gran hur")
				end
				if isInArray(paladin,getPlayerVocation(player)) then
				doPlayerLearnInstantSpell(player, "utani hur")
				end
			end
		end
	return true
end

- - - Updated - - -

actions

Lua:
local config = {
	daily = "no", -- allow only one enter per day? (like in global Tibia)
	level = 100,
	storage = 30015,
	entry =
	{
		{x = 1178, y = 390, z = 7},
		{x = 1179, y = 390, z = 7},
		{x = 1180, y = 390, z = 7},
		{x = 1181, y = 390, z = 7}
	},
	destination =
	{
		{x = 1193, y = 383, z = 7},
		{x = 1193, y = 387, z = 7},
		{x = 1193, y = 391, z = 7},
		{x = 1193, y = 395, z = 7}
	}
}
 
config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1946) then
		if(config.daily) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end
 
		return true
	end
 
	if(item.itemid ~= 1945) then
		return true
	end
 
	local players = {}
	for _, position in ipairs(config.entry) do
		local pid = getTopCreature(position).uid
		if(pid == 0 or not isPlayer(pid)) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end
 
		table.insert(players, pid)
	end
 
	for i, pid in ipairs(players) do
	local mage = {1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30}
	local paladin = {3, 7, 11, 15, 19, 23, 27, 31}
		doSendMagicEffect(config.entry[i], CONST_ME_POFF)
		doTeleportThing(pid, config.destination[i], false)
		doPlayerSendTextMessage(pid, MESSAGE_STATUS_WARNING, "The race has begun! GO!")
		setPlayerStorageValue(pid, 70101, getCreatureSpeed(pid))
		doChangeSpeed(pid, 220 - getCreatureBaseSpeed(pid))
		setPlayerStorageValue(pid, 70100, 1)
		doPlayerUnlearnInstantSpell(pid, "utani hur")
			if isInArray(mage,getPlayerVocation(pid)) then
				doPlayerUnlearnInstantSpell(pid, "utani gran hur")
			end
			if isInArray(paladin,getPlayerVocation(pid)) then
				doPlayerUnlearnInstantSpell(pid, "utani hur")
			end
		setGlobalStorageValue(cid, 80050, 0)
		doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
	end
 
	doTransformItem(item.uid, item.itemid + 1)
	return true
end
 
what is that entrys

PHP:
	entry =
	{
		{x = 1178, y = 390, z = 7},
		{x = 1179, y = 390, z = 7},
		{x = 1180, y = 390, z = 7},
		{x = 1181, y = 390, z = 7}
	},
	destination =
	{
		{x = 1193, y = 383, z = 7},
		{x = 1193, y = 387, z = 7},
		{x = 1193, y = 391, z = 7},
		{x = 1193, y = 395, z = 7}
	}
}
 
1-(entry)the place where people should stand to start
2-(destination)will be teleported to
 
Back
Top