• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Easy script: Check action id and teleport [SOLVED]

Xapuur

New Member
Joined
Sep 15, 2009
Messages
157
Reaction score
0
Location
Chile
Hello. I need a simple script:

When a player enters in a sqm with an action id X (OnStepIn), it must check if a player is in a sqm with action id Y is in it. If it isn't a player in the sqm with action id Y, the player will be teleport there (to the sqm with action id Y), if there is a player, the player will be teleport to Z pos with a text message.

The zone is no-pvp.

Regards

EDIT: Best explained: When a player enter a sqm meter he is teleported to another sqm just if this other sqm is empty, and if is not empty, the player is teleported to another pos with a text message. (Thanks Doggynub xd)
 
Last edited:
you can't locate items by action ID, use unique ID for Y

or even better — the position, as shown below
LUA:
local pY = {x=100, y=100, z=7}
local pZ = {x=100, y=100, z=7}

function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		local p = getTopCreature(pY).type == 1 and pZ or pY
		doTeleportThing(cid, p)
		doSendMagicEffect(p, CONST_ME_TELEPORT)
		if p == pZ then
			doCreatureSay(cid, 'Msg', TALKTYPE_ORANGE_1)
		end
	end
end
 
Last edited:
you can't locate items by action ID, use unique ID for Y

or even better — the position, as shown below
LUA:
local pY = {x=100, y=100, z=7}
local pZ = {x=100, y=100, z=7}

function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		local p = getTopCreature(pY).type == 1 and pZ or pY
		doTeleportThing(cid, p)
		doSendMagicEffect(p, CONST_ME_TELEPORT)
		if p == pZ then
			doCreatureSay(cid, 'Msg', TALKTYPE_ORANGE_1)
		end
	end
end

It works, but i must changed the function "onStepIn" for "onUse", because appears this error in console:
Code:
[03/01/2012 12:52:07] Warning: [Event::checkScript] Event onUse not found. /scripts/trainers/trainer.lua

And how i can make a table to add more posY? Because are much more xd..

Thanks Cykotitan, i needed this, really.

King Regards
 
Now I changed. Thanks Bogart ;).

The script works, but i need add more posY, i tried with:
Code:
local pY = {
{x = 1123, y = 996, z = 7}, {x = 1123, y = 996, z = 7}
}

And not works, any idea?
 
LUA:
local t = {
	a = { --"posY"
		[1] = {x="982", y="1002", z="7"},
		[2] = {x="983", y="1002", z="7"},
		[3] = {x="984", y="1002", z="7"}
	},
	b = 0,
	c = {x="981", y="1006", z="7"} --"posZ"
	}
	
function onStepIn(cid, item, fromPosition, itemEx)
	if isPlayer(cid) then
		repeat
			t.b = t.b+1
		until t.b >= #t.a or getTopCreature(t.a[t.b]).type ~= 1
			if getTopCreature(t.a[t.b]).type == 1 then
					doTeleportThing(cid, t.c)
					doCreatureSay(cid, "Sorry, all the training rooms are occupied", TALKTYPE_ORANGE_1)
				else
					doTeleportThing(cid, t.a[t.b])
					doCreatureSay(cid, "Training...", TALKTYPE_ORANGE_1)
			end
	end
	t.b = 0
end
 
Last edited:
Not works :S. Look, this script is for trainer: When a player enter in a teleport with uniqueid (or actionid) he is teleported to a trainer empty. If the trainer isn't empty, he is teleported to Z position with a text message. All the trainers position are in the Y table. Do you unsterdand? I ask this because i don't have good english xd

Thanks anyway :)
 
Back
Top