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

CreatureEvent AutoTP

Maniucza

~Lua~ Noob
Joined
Aug 2, 2009
Messages
86
Reaction score
6
Location
Poland / Rzeszów
Hello.I decided to write a script which is that as a player pockets the 10 lvl is automatically teleported to the data coordinates

Data/creaturescripts/autotp.lua
PHP:
local lvl = 10 -- level players
local pos = {x=100, y=100, z=7} -- where teleport player

function onAdvance(cid, skill, oldLevel, newLevel)
local pPos = getPlayerPosition(cid)
	if getPlayerLevel(cid) == lvl then
		doTeleportThing(cid, pos)
		doSendMagicEffect(pPos, 28)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations you have been teleports!")
	return TURE
	end
end

Data/creaturescripts.xml
PHP:
<event type="advance" name="AutoTP" script="autotp.lua"/>


And yet login.lua at the bottom of the "return true"
PHP:
registerCreatureEvent(cid, "AutoTP")

Bye. ;)
 
If you don't include

if newLevel > 0 then

It will teleport the player on every advance as long as the players level is 10 :p
 
If you don't include

if newLevel > 0 then

It will teleport the player on every advance as long as the players level is 10 :p

ah! first I didn't got it but now I understand what u mean.

If the player is already teleported and gains for example magiclevel he gets teleported again XD.

he forgot to make a check if the advance = leveladvance.
 
Wont work. This will work
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local lvl = 10
local pos = {x=100, y=100, z=7}

    if(newlevel >= lvl and getPlayerStorageValue(cid, 5555) ~= 1) then
        doTeleportThing(cid, pos)
        doSendMagicEffect(getPlayerPosition(cid), 28)
	setPlayerStorageValue(cid, 5555)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations you have been teleported!")
    end
	return true
end
 
Teleport Player to Random Town

Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local level = 10
local storage = 33112
local towns = { 
	{x=100, y=100, z=7}, -- Town 1
	{x=100, y=100, z=7}, -- Town 2
	{x=100, y=100, z=7}, -- Town 3
	{x=100, y=100, z=7} -- Town 4
}

local rand = math.random(1, #towns)
    if (skill == SKILL__LEVEL) and (newLevel == level) then
	if (getPlayerStorageValue(cid, storage) == -1) then
	    doTeleportThing(cid, towns[rand])
	    doSendMagicEffect(CONST_ME_TELEPORT, towns[rand])
	    setPlayerStorageValue(cid, storage, 1)
	    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! You have been teleported to your new town.")
	else
	    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have achieved level ".. level .." before.")
	end
    end
    return true
end
 
Wont work. This will work
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local lvl = 10
local pos = {x=100, y=100, z=7}

    if(newlevel >= lvl and getPlayerStorageValue(cid, 5555) ~= 1) then
        doTeleportThing(cid, pos)
        doSendMagicEffect(getPlayerPosition(cid), 28)
	setPlayerStorageValue(cid, 5555)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations you have been teleported!")
    end
	return true
end

Why do you use storagevalues for this?:O
Also you didn't specify which storagevalue the player gets. And what if the player is killed or dies and looses his level. Then he won't get teleported anymore once advanced again.

Can't it work with just:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local lvl = 10
local pos = {x=100, y=100, z=7}

    if(newLevel == lvl and oldLevel ~= lvl) then
        doTeleportThing(cid, pos)
        doSendMagicEffect(getPlayerPosition(cid), 28)
	setPlayerStorageValue(cid, 5555)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations you have been teleported!")
    end
	return true
end

or maybe better
if (skill == SKILL__LEVEL) and (newLevel == lvl) then
 
Why do you use storagevalues for this?:O
Also you didn't specify which storagevalue the player gets. And what if the player is killed or dies and looses his level. Then he won't get teleported anymore once advanced again.

Can't it work with just:
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local lvl = 10
local pos = {x=100, y=100, z=7}

    if(newLevel == lvl and oldLevel ~= lvl) then
        doTeleportThing(cid, pos)
        doSendMagicEffect(getPlayerPosition(cid), 28)
	setPlayerStorageValue(cid, 5555)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations you have been teleported!")
    end
	return true
end

or maybe better
if (skill == SKILL__LEVEL) and (newLevel == lvl) then

If player become lvl 10(get teleported) and die, he is level 9.. If he reach lvl 10 again, he'll teleported again..
Because this JDB using storage.
 
If player become lvl 10(get teleported) and die, he is level 9.. If he reach lvl 10 again, he'll teleported again..
Because this JDB using storage.

Yeah but it should be like that I think. I think this is some kind of rook function. When you don't leave rook at lvl 8 you get automaticly teleported to mainland. But if you get rooked again and you use storagevalues you can bypass this. That is why I think you should not use that.

It just depends on the user's needs. Would be better to make a small config for it then.
 
Yeah but it should be like that I think. I think this is some kind of rook function. When you don't leave rook at lvl 8 you get automaticly teleported to mainland. But if you get rooked again and you use storagevalues you can bypass this. That is why I think you should not use that.

It just depends on the user's needs. Would be better to make a small config for it then.

I forget skill :(

@JDB - Sucks random towns, lol.
 
Then change it, I think it is good, so Thais for example, isn't full of noobs.
 
Back
Top