Doggynub
LUA / C++
- Joined
- Sep 28, 2008
- Messages
- 2,541
- Reaction score
- 186
Text Changes
-
*simple is up , advanced is down.
Here is a little script for beginners
-my first script (lol):-
*first of all lets add this tiny line to your movment.xml in data-->movement-->movement.xml
just to let the sevrer know that when u stepon this item it do the stuff the script
in the place where it says itemid="9445" this is the id of the item you need to use as a teleport
then
make a new lua file name it tele.lua (to fast edit and saving files as lua and organizing use notepad++
Download Notepad++ from SourceForge.net
then add this:
what is in it:
1-you can select whatever item u want to act s a teleporter
u change this in the map editor by clicking double click on whatever item u chose and right the number in the action id field so if u put other item like that u want to act like a tp it doesnt tp ppl
and this if u want a message (orange one) to be sent to player if u dont delete this line if u want to change color go to your global file and search for (message) u will find many types if u dont have global file got to lib>constant
uyou see the part where , 10) is written this makes a teleport effect when player is teleported u can also change it if u want by going to same folder i saif before but search for (const_me)
A bit advanced if you want:
1-you can config it for if you want like (gm's,cm's,gods) can only enter
and if they dont have the required acess item will auto push them and send a cancel msg
in this part
u musn't edit any thing it is the thing that push player accordin to their direction
here in the part of getPlayerGroupId >= 4 , <4> refers to player group u cn see the player groups in xml>groups so if 4=gm then gm or more higher acess can use the tp . If u want like only gms can use u change (>= 4) to (== 4) if u want lesser player acess than gm use you change (>= 4) to (<=4) and also dont forget to change here if u have changed the group number or the signs
this what will appear to player if he dont have the required stuff always dont forget to add like that "words here"
this make is to make players be pushed back when they donat have the required stuff
this to send a puff(it is the white effect that apear when u cant use this spell or somthng) effect when player is pushed back ,if u want to change also go to the same folders as up according to ur server version and search for (const_me) to change magic effect.
For those who want to put more than on eof the same item but ea to tp diffrnt places(instructions inside):
what if you want to do more tps:
just cope these lines
now beginig of script will be like this :
*you must add comma at end of each block after the closing bracket },(if there is another block after it) except the last block its end will be like that } .Hope you got it.
*I know that seems like too long for a noob script like that but i just wanted to explain every thing for you begginers to know what you are doin so not be confused.
If i helped plz,REP++.
-
*simple is up , advanced is down.
Here is a little script for beginners
-my first script (lol):-
*first of all lets add this tiny line to your movment.xml in data-->movement-->movement.xml
Code:
<movevent type="StepIn" itemid="9445" event="script" value="tele.lua"/>
in the place where it says itemid="9445" this is the id of the item you need to use as a teleport
then
make a new lua file name it tele.lua (to fast edit and saving files as lua and organizing use notepad++
Download Notepad++ from SourceForge.net
then add this:
what is in it:
1-you can select whatever item u want to act s a teleporter
Code:
[SIZE=1]local id = 5578 --this is the action id u need to edit to the item in map editor[/SIZE]
[SIZE=1]local place = {x=1000, y=1000, z=7} --location where player will be tped[/SIZE]
[SIZE=1]function onStepIn(cid, item, position, fromPosition)[/SIZE]
[SIZE=1]if item.actionid == id then[/SIZE]
[SIZE=1]doTeleportThing(cid, place)[/SIZE]
[SIZE=1]doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_YELL, "You are teleported to temple!")[/SIZE]
[SIZE=1]doSendMagicEffect(getPlayerPosition(cid), 10)[/SIZE]
[SIZE=1]elseif item.actionid ~= id then[/SIZE]
[SIZE=1]end [/SIZE]
[SIZE=1]end[/SIZE]
Code:
[SIZE=1]local id = 5578 [/SIZE]
Code:
[SIZE=1]doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_YELL, "You are teleported to temple!")[/SIZE]
Code:
[SIZE=1]doSendMagicEffect(getPlayerPosition(cid), 10)[/SIZE]
A bit advanced if you want:
1-you can config it for if you want like (gm's,cm's,gods) can only enter
and if they dont have the required acess item will auto push them and send a cancel msg
Code:
local id = 5579
local place = {x=1000, y=1000, z=7}
function onStepIn(cid, item, position, fromPosition)
if getPlayerLookDir(cid) == 0 then
newdir = 2
elseif getPlayerLookDir(cid) == 1 then
newdir = 3
elseif getPlayerLookDir(cid) == 2 then
newdir = 0
else
newdir = 1
end
if item.actionid == id and getPlayerGroupId(cid) >= 4 then
doTeleportThing(cid, place)
doPlayerSendTextMessage(cid, TALKTYPE_MONSTER_YELL, "You are teleported to temple!")
doSendMagicEffect(getPlayerPosition(cid), 10)
elseif item.actionid ~= id and getPlayerGroupId(cid) >= 4 then
else
doPlayerSendCancel(cid, "You Don't Have The Required GroupId!")
doMoveCreature(cid, newdir)
doSendMagicEffect(getPlayerPosition(cid), 2)
end
end
in this part
Code:
if getPlayerLookDir(cid) == 0 then
newdir = 2
elseif getPlayerLookDir(cid) == 1 then
newdir = 3
elseif getPlayerLookDir(cid) == 2 then
newdir = 0
else
newdir = 1
end
Code:
if item.actionid == id and getPlayerGroupId(cid) >= 4 then
here in the part of getPlayerGroupId >= 4 , <4> refers to player group u cn see the player groups in xml>groups so if 4=gm then gm or more higher acess can use the tp . If u want like only gms can use u change (>= 4) to (== 4) if u want lesser player acess than gm use you change (>= 4) to (<=4) and also dont forget to change here if u have changed the group number or the signs
Code:
elseif item.actionid ~= id and getPlayerGroupId(cid) >= 4 then
Code:
doPlayerSendCancel(cid, "You Don't Have The Required GroupId!")
Code:
doMoveCreature(cid, newdir)
Code:
doSendMagicEffect(getPlayerPosition(cid), 2)
For those who want to put more than on eof the same item but ea to tp diffrnt places(instructions inside):
Code:
local teleports = {
-- uid = {position={}, level=x, effect=x}
[1000] = { -- this is the item unique id
position = {x= 94, y=123, z=7}, --- th eplace where the item with this unique id will send players to
level = 30, -- make it 1 if you want like all lvs to eneter
effect = 10, -- remove this line to ignore effect
group = 6 -- set to 1 if you want all kinds of player use the tp ( check groups numbers in group.xml)
},
[2000] = {
position = {x= 101, y=123, z=7},
level = 50,
effect = 10,
group = 3
},
}
function onStepIn(cid, item, position, fromPosition)
-- get table with attributes from 'teleports' table by unique id
local options = teleports[item.uid]
if(not options) then -- check if positions exists (this is not really required - just in case you declare something wrong in movements.xml)
return TRUE -- just exit script, it won't continue executing
end
if getPlayerLookDir(cid) == 0 then
newdir = 2
elseif getPlayerLookDir(cid) == 1 then
newdir = 3
elseif getPlayerLookDir(cid) == 2 then
newdir = 0
else
newdir = 1
end
if(getPlayerLevel(cid) < options.level) then -- check if player have level
doPlayerSendCancel(cid, "Sorry, your level is to low for this teleport.")
doMoveCreature(cid, newdir)
return TRUE
end
if(getPlayerGroupId(cid) < options.group) then -- check if player have level
doPlayerSendCancel(cid, "Sorry, your group is to low for this teleport.")
doMoveCreature(cid, newdir)
return TRUE
end
doTeleportThing(cid, options.position) -- teleport player to dest
if(options.effect) then -- check if effect is specified
doSendMagicEffect(getCreaturePosition(cid), options.effect)
end
return TRUE
end
what if you want to do more tps:
just cope these lines
Code:
[2000] = { ---- change this
position = {x= 1002, y=1001, z=7}, --- and this
level = 50, --and this
effect = 10, -and this
group = 3 --and this
}
now beginig of script will be like this :
Code:
local teleports = {
-- uid = {position={}, level=x, effect=x}
[1000] = { -- this is the item unique id
position = {x= 94, y=123, z=7}, --- th eplace where the item with this unique id will send players to
level = 30, -- make it 1 if you want like all lvs to eneter
effect = 20, -- remove this line to ignore effect
group = 9 -- set to 1 if you want all kinds of player use the tp ( check groups numbers in group.xml)
},
[2000] = {
position = {x= 1002, y=1001, z=7},
level = 50,
effect = 10,
group = 3
}[B][SIZE=4][COLOR=#000000], --- this comma here is the change[/COLOR][/SIZE][/B]
[3000] = {
position = {x= 1062, y=1071, z=8},
level = 90,
effect = 12,
group = 4
}
}
*you must add comma at end of each block after the closing bracket },(if there is another block after it) except the last block its end will be like that } .Hope you got it.
*I know that seems like too long for a noob script like that but i just wanted to explain every thing for you begginers to know what you are doin so not be confused.
If i helped plz,REP++.
Last edited: