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

same speed floor event

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hii people of otland, here is the thing, i have an event that consist in running, is a race event. but always wins the high lvl because he has more speed. so what i want to do is to set the floor a speed. that everybody runs at the same speed in the speedtrack. if this is possible i would be really thankful if you could give me som script :D thanks
 
Hii people of otland, here is the thing, i have an event that consist in running, is a race event. but always wins the high lvl because he has more speed. so what i want to do is to set the floor a speed. that everybody runs at the same speed in the speedtrack. if this is possible i would be really thankful if you could give me som script :D thanks

check scripts form an Underwater area and implent tham into the mapping piece, set the reduction to an %tage amount that will force everyone to run in the same speed.

happy finding
 
doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))

swap 220 for desired speed and disable haste spells. might also wanna take away inventory items, send them to depot or i don't know :p
 
Code:
doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))
yes use this.
simply put a movement script for when they enter the event it changes their storage value to a certian value;
and a global event script that checks if any player has that storage then to change the speed.
 
yes use this.
simply put a movement script for when they enter the event it changes their storage value to a certian value;
and a global event script that checks if any player has that storage then to change the speed.

is not as simple it sounds for me :( i'm not a skilled scripter, i don't think i can create a script :C!!!!
 
okay give me a few minutes i will create.

enter race; place this on the tile that everyone must step on to enter.

enterrace.lua
Lua:
function onStepIn(cid, item, position, fromPosition)
local storage = 5890
	if getPlayerStorageValue(cid, storage) < 1 then
		setPlayerStorageValue(cid, storage, 1)
	end
return true
end
where they all get tp when event is over

exitrace.lua
Lua:
function onStepIn(cid, item, position, fromPosition)
local storage = 5890
	if getPlayerStorageValue(cid, storage) >= 1 then
		setPlayerStorageValue(cid, storage, 0)
	end
return true
end
movements.xml
Code:
<movevent type="StepIn" uniqueid="8000" event="script" value="enterrace.lua"/>
<movevent type="StepIn" uniqueid="8001" event="script" value="exitrace.lua"/>
make sure to add the uniqueid ^ onto tile in mapeditor.

In global events
checkrace.lua
Lua:
function onThink(cid, item, fromPosition, toPosition)
	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
			if getPlayerStorageValue(player, 5890) == 1 then
				doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))
			end
	end
return true
end
globalevents.xml
Code:
<globalevent name="checkrace" interval="1" event="script" value="checkrace.lua"/>
 
Last edited:
wooooow man you just made my day! thanks! +rep


what happens if the event doesn't "end" if they just get to a final teleport to lead then to the temple? :/

- - - Updated - - -

what happens if the event doesn't "end" if they just get to a final teleport to lead then to the temple? :/
race.jpg
 
Last edited:
wooooow man you just made my day! thanks! +rep


what happens if the event doesn't "end" if they just get to a final teleport to lead then to the temple? :/

- - - Updated - - -

what happens if the event doesn't "end" if they just get to a final teleport to lead then to the temple? :/
View attachment 21235

Okay so now that i see your picture im trying to get a better understanding of how it works, so each person starts on one of those gray square and they take their own path; first one there gets the prize and everyone else get tp'd to temple?
 
yeah exactly, when i pull the lever the rocks dissapear and the go to the teleport and start running, then the first that reach the saloon gets the prize and the go to tp to the temple :D
 
Okay so not sure how you wanna do this so i made two different ways, just use the one you want.
in movements

first -- this one automatically adds the winners item and teleports all to temple
winner.lua
Lua:
local t = {
temple = {x= , y= , z= },
prize = 2160, -- item id
prizeN = "", -- name of prize
amount = 1, -- how many
storage = 5890, 
gStorage = 10050,
count = 0
}
function onStepIn(cid, item, position, fromPosition)
local v = t.tiles[item.uid]
	if getPlayerStorageValue(cid, t.storage) == 1 and getGlobalStorageValue(cid, t.gStorage) ~= 5 then
		t.count++
		setPlayerStorageValue(cid, t.storage, 2)
		setGlobalStorageValue(cid, t.gStorage, 5)
		doPlayerSendTextMessage(cid, 19, "Congratulations! Youve won the race! Youve been awarded with "..t.amount.." "..t.prizeN.."!")
		doPlayerAddItem(cid, t.prize, t.amount)
		doTeleportThing(cid, t.temple)
	else
		t.count++
		doPlayerSendTextMessage(cid, 19, "Sorry you lost the race")
		doTeleportThing(cid, t.temple)
	end
		if count >= 5 then
			setGlobalStorageValue(cid, t.gStorage, 0) 
		end
return true
end
second; this one teleports to prize area for winner and temple for loser
winner.lua
Lua:
local t = {
temple = {x= , y= , z= },
winner = {x= , y= , z= },
storage = 5890, 
gStorage = 10050,
count = 0
}
function onStepIn(cid, item, position, fromPosition)
local v = t.tiles[item.uid]
	if getPlayerStorageValue(cid, t.storage) == 1 and getGlobalStorageValue(cid, t.gStorage) ~= 5 then
		t.count++
		setPlayerStorageValue(cid, t.storage, 2)
		setGlobalStorageValue(cid, t.gStorage, 5)
		doPlayerSendTextMessage(cid, 19, "Congratulations! Youve won the race!")
		doTeleportThing(cid, t.winner)
	else
		t.count++
		doPlayerSendTextMessage(cid, 19, "Sorry you lost the race")
		doTeleportThing(cid, t.temple)
	end
		if count >= 5 then
			setGlobalStorageValue(cid, t.gStorage, 0) 
		end
return true
end

movements.xml
Code:
<movevent type="StepIn" uniqueid="8780-8784" event="script" value="winner.lua"/>
put the uniqueids 8780 - 8784 under the tps at the end

make sure the teleports at the end dont actually have a set location cause the scripts handle that
 
damn, i got this error :/

Lua:
[16/06/2013 21:02:11] [Error - LuaScriptInterface::loadFile] data/movements/scripts/winner.lua:11: '=' expected near '+'
[16/06/2013 21:02:11] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/winner.lua)
[16/06/2013 21:02:11] data/movements/scripts/winner.lua:11: '=' expected near '+'
 
use this
Lua:
local t = {
temple = {x= , y= , z= },
winner = {x= , y= , z= },
storage = 5890, 
gStorage = 10050,
count = 0
}
function onStepIn(cid, item, position, fromPosition)
	if getPlayerStorageValue(cid, t.storage) == 1 and getGlobalStorageValue(cid, t.gStorage) ~= 5 then
		t.count = t.count + 1
		setPlayerStorageValue(cid, t.storage, 2)
		setGlobalStorageValue(cid, t.gStorage, 5)
		doPlayerSendTextMessage(cid, 19, "Congratulations! Youve won the race!")
		doTeleportThing(cid, t.winner)
	else
		t.count = t.count + 1
		doPlayerSendTextMessage(cid, 19, "Sorry you lost the race")
		doTeleportThing(cid, t.temple)
	end
		if t.count >= 5 then
			setGlobalStorageValue(cid, t.gStorage, 0) 
		end
return true
end
 
the thing of teleportation works fine, but still the people isn't running at the same speed :C

- - - Updated - - -

sorry, the problem is that everyone who gets to the final teleport (no coordenades just the unique id in the floor) gets teleported to the temple, the first, the middle ones and the last one :/
 
okay i realized its a bad idea to use globalevent to change speed as it can cause lag,
so if you look back at the first page of this thread youll see the enter script; change it to this
Lua:
local t = {
[5500] = {x= ,y= ,z= },
[5501] = {x= ,y= ,z= },
[5502] = {x= ,y= ,z= },
[5503] = {x= ,y= ,z= },
[5504] = {x= ,y= ,z= },
}
function onStepIn(cid, item, position, fromPosition)
local v = t[item.uid]
local storage = 5890
	if getPlayerStorageValue(cid, storage) < 1 then
		setPlayerStorageValue(cid, storage, 1)
		setPlayerStorageValue(pid, 80070, getCreatureSpeed(cid))
		doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))
		doTeleportThing(cid, v[1])
	end
return true
end
and thats odd, are you sure they are stepping overtop of the script that makes them enter ^ as in above.
once again dont actually use TPS that have locations otherwise it will TP and not run the script.
which i think you are doing as they are entering the event..
so use the one above i configured it to TP also.
and youll have to change your movements.xml for entering
Code:
<movevent type="StepIn" uniqueid="5500-5504" event="script" value="enterrace.lua"/>

now for the exit code use this so it restores their previous speed
Lua:
function onStepIn(cid, item, position, fromPosition)
local storage = 5890
	if getPlayerStorageValue(cid, storage) >= 1 then
		setPlayerStorageValue(cid, storage, 0)
		doChangeSpeed(cid, getPlayerStorageValue(cid, 80070)
	end
return true
end
 
woo i'm so confused right now D:
soo what i have to do here:
Lua:
local t = {
[5500] = {x= ,y= ,z= },
[5501] = {x= ,y= ,z= },
[5502] = {x= ,y= ,z= },
[5503] = {x= ,y= ,z= },
[5504] = {x= ,y= ,z= },
}
function onStepIn(cid, item, position, fromPosition)
local v = t[item.uid]
local storage = 5890
	if getPlayerStorageValue(cid, storage) < 1 then
		setPlayerStorageValue(cid, storage, 1)
		setPlayerStorageValue(pid, 80070, getCreatureSpeed(cid))
		doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))
		doTeleportThing(cid, v[1])
	end
return true
end

what do i have to do there? what are those positions? entering teleports or exiting teleports? and those 5500-5504 are uniques ids?

also how do i run this?
Lua:
function onStepIn(cid, item, position, fromPosition)
local storage = 5890
	if getPlayerStorageValue(cid, storage) >= 1 then
		setPlayerStorageValue(cid, storage, 0)
		doChangeSpeed(cid, getPlayerStorageValue(cid, 80070)
	end
return true
end

and the exiting unique ids i have under the teleports, should i leave them just like the way they are?? (8780-8784)

sorry man, besides english is not my first languaje D:
 
okay so go to your movements and change your
enterrace.lua to this
Lua:
local t = {
[5500] = {x= ,y= ,z= },
[5501] = {x= ,y= ,z= },
[5502] = {x= ,y= ,z= },
[5503] = {x= ,y= ,z= },
[5504] = {x= ,y= ,z= },
}
function onStepIn(cid, item, position, fromPosition)
local v = t[item.uid]
local storage = 5890
	if getPlayerStorageValue(cid, storage) < 1 then
		setPlayerStorageValue(cid, storage, 1)
		setPlayerStorageValue(pid, 80070, getCreatureSpeed(cid))
		doChangeSpeed(cid, 220 - getCreatureBaseSpeed(cid))
		doTeleportThing(cid, v[1])
	end
return true
end
now for your TPS for the players to start the race, there is co-ordinates in there for them to be teleported.. erase those co-ordinates so that the TPs are just there for looks and put the co-ordinates in this script; with the unique ids of 5500 - 5504 underneath the Tps.

Then change exitrace.lua to this
Lua:
function onStepIn(cid, item, position, fromPosition)
local storage = 5890
	if getPlayerStorageValue(cid, storage) >= 1 then
		setPlayerStorageValue(cid, storage, 0)
		doChangeSpeed(cid, getPlayerStorageValue(cid, 80070))
	end
return true
end
and you can delete the global event called checkrace.lua
 
Last edited:
and the xml for the exitrace.lua would be this?
XML:
<movevent type="StepIn" uniqueid="8001" event="script" value="exitrace.lua"/>

- - - Updated - - -

Lua:
[17/06/2013 00:53:59] [Error - LuaScriptInterface::loadFile] data/movements/scripts/exitrace.lua:6: ')' expected (to close '(' at line 5) near 'end'
[17/06/2013 00:53:59] [Warning - Event::loadScript] Cannot load script (data/movements/scripts/exitrace.lua)
[17/06/2013 00:53:59] data/movements/scripts/exitrace.lua:6: ')' expected (to close '(' at line 5) near 'end'

:( console error
 
Back
Top