Zyntax
*WannaBe Scripter*
Hey guys!
Updates:
v2.0
I thought the community could use some inspiration about some
RPG stuff.
I would like to introduce the Magic Mirror to you.
I thought to give you some ideas on how to put a different feeling to your
server (except for the "ueSpam, r0xing x99999 exp, hanting" servers).
Well then, let's start!
What's up with this tutorial?
Easy explained: You're stuck in your path and you can only continue if you use the Magic Mirror to port into another time.
Activate something there and port back to see what happend!
A little picture story:
Oh Noes! I can't pass! But I got my Magic Mirror! Help me!
Haha! GO Mirror GO!
*Poff* Wooah! There's a switch! I'll use it!
No kidding! There's a bridge! I can continue!
Well, that's the end of the story and the lucky player can continue
on his mission.
Setup & Scripts
As I said in the beginning, we will only need 2 scripts for this.
But first off all we should prepare our location:
The idea is very simple:
Draw a specific location in "light-style"
(for example, a good looking house, naturefilled mountains, ...)
Copy the area (or create a new one) which looks exact the same, just in "dark-style"
(for example, broken walls, rotten mountains, ...)
Now write down every position I marked in the picture above:
fromPos1 = {x= , y= }
fromPos2 = {x= , y= }
LeverID, Bridge and so on...
Sidenote: if you don't want to map a lever and move a bridge, then be original
and think of something else, you're free to do that
If you have all those positions, adjust them in the scripts below:
%data/actions/scripts/tools create a new file called mirror.lua
IMPORTANT:
The script checks all AREAS which you defined in the array in the script.
Make sure to write down the correct fromPos and toPos coordinates!
TARGETARRAY: If your starting position = area1 and you want to teleport to your
second area (fromPos2,toPos2) then edit targetarray = 2!
If you want to port from area1 to area3 edit targetarray = 3!
If you want to teleport between different z coordinates just edit
the z = value.
Another feature:
If you port from area1 square 2,4 then you will be ported to
area2 square 2,4
You can also draw 10 areas and adjust the script to check all those
areas if the user = Player who stands in the specific area.
%data/actions/action.xml add this line:
Sidenote: You have to put the same actionId to your Item which
you want to be used in order to teleport!
I took a mirror because it reminds me at Zelda - A Link to the past!
Creating & Removing the Bridge
That's an easy one aswell.
Write down the positions where the bridge should be created
and add them in the config:
[1] = first position
[2] = second position
and so on...
%data/actions/scripts/tools create a new file and name it bridge.lua
And now for the last part,
%data/actions/action.xml add this line:
You successfully implemented RPG feeling! eace:
Sidenote:
If you find any bugs, mistakes, undeclared sections or any
other failures then post them right away!
I'm not perfect so mistakes are common :$
Credits:
Credits goes to -> Zakius (thanks for your great help with the script!)
So far, I hope that I inspired some scripters/mappers out there!
Regards,
Zyntax
Updates:
v2.0
Code:
Updated the whole tutorial to TFS0.3.5pl1
Advanced the script (Thanks to zakius!)
Added new screenshots
Minor bug fixing
I thought the community could use some inspiration about some
RPG stuff.
I would like to introduce the Magic Mirror to you.
I thought to give you some ideas on how to put a different feeling to your
server (except for the "ueSpam, r0xing x99999 exp, hanting" servers).
Well then, let's start!
What's up with this tutorial?
Easy explained: You're stuck in your path and you can only continue if you use the Magic Mirror to port into another time.
Activate something there and port back to see what happend!
A little picture story:
Oh Noes! I can't pass! But I got my Magic Mirror! Help me!
Haha! GO Mirror GO!
*Poff* Wooah! There's a switch! I'll use it!
No kidding! There's a bridge! I can continue!
Well, that's the end of the story and the lucky player can continue
on his mission.
Setup & Scripts
As I said in the beginning, we will only need 2 scripts for this.
But first off all we should prepare our location:
The idea is very simple:
Draw a specific location in "light-style"
(for example, a good looking house, naturefilled mountains, ...)
Copy the area (or create a new one) which looks exact the same, just in "dark-style"
(for example, broken walls, rotten mountains, ...)
Now write down every position I marked in the picture above:
fromPos1 = {x= , y= }
fromPos2 = {x= , y= }
LeverID, Bridge and so on...
Sidenote: if you don't want to map a lever and move a bridge, then be original
and think of something else, you're free to do that
If you have all those positions, adjust them in the scripts below:
%data/actions/scripts/tools create a new file called mirror.lua
Lua:
----------------------------------------------------
---------<<< Area Teleportation Script >>>----------
-----------------<<< made by >>>--------------------
-------------<<< zakius & Zyntax >>>----------------
--------------<<< @ OTLand.net >>>-----------------
----------------------------------------------------
local config ={
array={
[1]={
frompos={x=589, y=583},
topos={x=594, y=586},
z = 7,
targetarray=2
},
[2]={
frompos={x=615, y=584},
topos={x=620, y=587},
z = 7,
targetarray=1
},
--EXAMPLE AREA:
--[3]={
-- frompos={x=XXX, y=XXX},
-- topos={x=XXX, y=XXX},
-- z=X,
-- targetarray=X
-- },
},
actionID = 2020, --Write your actionID of your Item
teletime = 5 --Time in seconds when the player gets teleportet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- DO NOT EDIT THE LINES BELOW (unless you know what you're doing)--
local failure = true
local user = getPlayerName(cid)
if item.actionid == config.actionID then
for i = 1, #config.array do
local z = config.array[i].z
local ax = 0
for x = config.array[i].frompos.x, config.array[i].topos.x do
local ay = 0
for y = config.array[i].frompos.y, config.array[i].topos.y do
if (isPlayer(getThingFromPos({x=x, y=y, z=z, stackpos=253}).uid)) then
if(user == getPlayerName(getThingFromPos({x=x, y=y, z=z, stackpos=253}).uid)) then
doPlayerSay(cid, 'Mirror, mirror in my hand\nbring me to the other land!', 19)
failure = false
addEvent(tele, config.teletime * 1000, cid, user, ax, ay, i)
break
end
end
ay = ay + 1
end
ax = ax + 1
end
end
end
if (failure) then
doPlayerSendCancel(cid, 'You cannot use the mirror here.')
end
return true
end
function tele(cid, user, ax, ay, i)
local target=config.array[i].targetarray
local topos={x=config.array[target].frompos.x+ax , y=config.array[target].frompos.y+ay, z=config.array[target].z}
doTeleportThing(cid, topos)
doSendMagicEffect(topos, CONST_ME_ENERGYAREA)
doPlayerSendTextMessage(cid, 21, 'Your wish is my order, Master '..user..'.')
end
IMPORTANT:
The script checks all AREAS which you defined in the array in the script.
Make sure to write down the correct fromPos and toPos coordinates!
TARGETARRAY: If your starting position = area1 and you want to teleport to your
second area (fromPos2,toPos2) then edit targetarray = 2!
If you want to port from area1 to area3 edit targetarray = 3!
If you want to teleport between different z coordinates just edit
the z = value.
Another feature:
If you port from area1 square 2,4 then you will be ported to
area2 square 2,4
You can also draw 10 areas and adjust the script to check all those
areas if the user = Player who stands in the specific area.
%data/actions/action.xml add this line:
Lua:
<action actionid="2020" event="script" value="tools/mirror.lua"/>
Sidenote: You have to put the same actionId to your Item which
you want to be used in order to teleport!
I took a mirror because it reminds me at Zelda - A Link to the past!
Creating & Removing the Bridge
That's an easy one aswell.
Write down the positions where the bridge should be created
and add them in the config:
[1] = first position
[2] = second position
and so on...
%data/actions/scripts/tools create a new file and name it bridge.lua
Lua:
local config = {
bridgeId = 3764, --ID of the bridge
reset = 30, --ResetTime in seconds
pos = {
[1]= {x=591, y=588, z=7, stackpos=1},
[2]= {x=591, y=589, z=7, stackpos=1},
[3]= {x=591, y=590, z=7, stackpos=1},
[4]= {x=591, y=591, z=7, stackpos=1},
[5]= {x=591, y=592, z=7, stackpos=1}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == 4011 then
for i = 1, #config.pos do
doSendMagicEffect(config.pos[i], CONST_ME_ENERGYAREA)
doCreateItem(config.bridgeId, config.pos[i])
end
doPlayerSendTextMessage(cid, 22, 'Something happend in the light world!\nCheck it out!')
doTransformItem(item.uid, item.itemid + 1)
addEvent(resetbridge, config.reset * 1000, item)
elseif item.itemid == 1946 then
doPlayerSendCancel(cid, 'Sorry not possible')
end
return 1
end
function resetbridge(item)
for i = 1, #config.pos do
doRemoveItem(getTileItemById(config.pos[i], config.bridgeId).uid)
doSendMagicEffect(config.pos[i], CONST_ME_ENERGYAREA)
end
doTransformItem(item.uid, item.itemid)
end
And now for the last part,
%data/actions/action.xml add this line:
Lua:
<action uniqueid="4011" event="script" value="tools/bridge.lua"/>
You successfully implemented RPG feeling! eace:
Sidenote:
If you find any bugs, mistakes, undeclared sections or any
other failures then post them right away!
I'm not perfect so mistakes are common :$
Credits:
Credits goes to -> Zakius (thanks for your great help with the script!)
So far, I hope that I inspired some scripters/mappers out there!
Regards,
Zyntax
Last edited: