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

Action ghettobird's tp scroll, tps u to to temple!

Do you think ghettobird's scripting is good/useful?


  • Total voters
    28

ghettobird

LUA newbie
Joined
Aug 17, 2013
Messages
679
Reaction score
132
Location
OTland
Hey otlanders, i had some free time today (again :p) so i made a scroll that teleports you to temple.

@OFF TOPIC: a lot of people have been asking me where i learn lua while it's right in front of their eyes, so just to avoid any other question of that kind, here is what i DO WHEN I SCRIPT :-

1st: open http://otland.net/f481/scripting-guide-74030/
2nd: open lua functions (docs -> lua functions)
3rd: i just put them together... it's really easy if you try!
-------------------------------------------------------------------------------------------------


now since that's out of the way we can get back to track,

in your actions/scripts put this
Lua:
local newpos = {x=1000, y=1000, z=7} 
function onUse(cid, item, frompos, item2, topos)
local inFight = hasCondition(cid, CONDITION_INFIGHT)
if not inFight then
      doSendMagicEffect(getPlayerPosition(cid), 2)
      doTeleportThing(cid,newpos)
      doCreatureSay(cid, "TELEPORTED!!" ,25)
	 
else
doPlayerSendTextMessage(cid,25,"You can't use the teleport scroll if you are PZ LOCKED!!")
end
return true
end


now go to actions.xml and post this
Lua:
 <action itemid="itemidyouwant" event="script" value="yourscriptname.lua"/>

i really hope you guys like it, it really takes time (or at least for me) to make these scripts :)


anyway, ENJOY! :peace:
 
You should use constant names instead of numbers for magic effects and text messages. :p

Anyway, good work.
 
Change to
Lua:
doCreatureSay(cid, "TELEPORTED!!", TALKTYPE_ORANGE_1)
and
Lua:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can't use the teleport scroll if you are PZ LOCKED!!")
Else people (can) get debugged.
 
TIP: Never add a poll in such threads
I always love to click the opposite of the ^good^ answer (most of the time)
 
@limos: thanks, ill use that in my future scripts

@amiroslo: thanks for the tip :peace:
 
Why is
Lua:
local inFight = hasCondition(cid, CONDITION_INFIGHT)
a local variable? Use
Lua:
if(not(hasCondition(cid, CONDITION_INFIGHT))) then
instead.
 
instead of
Lua:
local newpos = {x=1000, y=1000, z=7}

Use

Lua:
getTownTemplePosition(getPlayerTown(cid))

Thats Better for me :) you can use it if you want or keep on using the x,y,z
 
instead of
Lua:
local newpos = {x=1000, y=1000, z=7}

Use

Lua:
getTownTemplePosition(getPlayerTown(cid))

Thats Better for me :) you can use it if you want or keep on using the x,y,z
what if they want to make it a teleport for quests or something? :p
 
I edited your script a bit:
My version will leave a portal behind for 5 seconds so your party members or even enemies have a chance to follow you.
Lua:
local newpos = {x=1000, y=1000, z=7} 

function onUse(cid, item, frompos, item2, topos)
	local inFight = hasCondition(cid, CONDITION_INFIGHT)
	if not inFight then
		doSendMagicEffect(getPlayerPosition(cid), 2)
		doTeleportThing(cid,newpos)
		local tele = doCreateTeleport(1387, newpos, frompos) -- Creates teleport
		addEvent(doRemoveItem, 5000, tele.uid) -- Removes teleport after 5 seconds
		doCreatureSay(cid, "TELEPORTED!!" ,25)
	else
		doPlayerSendTextMessage(cid,25,"You can't use the teleport scroll if you are PZ LOCKED!!")
	end
	return true
end
 
@Flatlander: i could have made that :p, but thanks
@azzkaban: thanks, i'm glad you like my scripts :peace:
 
@Flatlander: i could have made that :p, but thanks
@azzkaban: thanks, i'm glad you like my scripts :peace:

Anyone can make any script.
The biggest challenge is thinking of a fun way to use the script in-game.
 
Code:
local newpos = {x=1000, y=1000, z=7}
local time = 50--in second
function onUse(cid, item, frompos, item2, topos)
local inFight = hasCondition(cid, CONDITION_INFIGHT)
if exhaustion.check(cid, 1605) then
return doPlayerSendCancel(cid, "Please Wait "..exhaustion.get(cid,1605)..".") and doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
end

if not inFight then
doSendMagicEffect(getPlayerPosition(cid), 2)
doTeleportThing(cid,newpos)
doCreatureSay(cid, "TELEPORTED!!" ,25)
exhaustion.set(cid, 1605, time)

else
doPlayerSendTextMessage(cid,25,"You can't use the teleport scroll if you are PZ LOCKED!!")
end
return true
end
 
Thanks :)
I have one more question.

I want that when a player enter a Area that a Text appear
 
When a player walk on a SQM a Message appear.

You know what i mean ??
 
Code:
function onStepIn(cid, item, frompos, itemEx, topos)
local message = "Hi"
if isPlayer(cid) then
doPlayerSendTextMessage(cid, 25, message)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
return true
end

Code:
<movevent type="StepIn" itemid="5550" event="script" value="your script.lua"/>
 
Back
Top