• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Master Teleporter

Nostradamus

Member
Joined
Jun 2, 2007
Messages
219
Reaction score
6
Introduction

This is a system that consists in a managment of places, so it will be more simple to teleport to an especific place that you don't know the coordenates. You will only need the description that you can set.

Instructions

The scripts is a talkaction and the commands are:

  • !set "name of the place
  • !unset "name of the place
  • !teleport "name of the place
And you will have to edit your database creating a new table with two fields:

Table: teleports
Fields: pos, name

DROP TABLE IF EXISTS `teleports`;
CREATE TABLE `teleports` (
`pos` varchar(45) NOT NULL,
`name` text unsigned NOT NULL,
PRIMARY KEY (`pos`));

Observations

The script only works in TFS since it uses LuaSQL.

The script wasn't tested, any bugs, post here.
I am releasing that script because it sucks (can be easily made not using LuaSQL).

Code

talkactions.xml

HTML:
<talkaction words="!set" script="teleporter.lua" />
<talkaction words="!unset" script="teleporter.lua" />
<talkaction words="!teleport" script="teleporter.lua" />
teleporter.lua

Code:
local ITEM_TELEPORT = 1387

dofile('./config.lua')
env = assert(luasql.mysql())
connect = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))

Waypoint =
{

    -- pos here should be a table (e.g: {x = 10, y = 10, z = 10}
    set = function (pos, name)
        if (string.find(name, '^[a-zA-Z0-9 -_]+$')) then
            debugPrint('[Waypoint System] Wrong characteres to the name of waypoint.')
            return FALSE
        end
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `pos` = " .. pos .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("UPDATE `teleports` SET `pos` = " .. pos .. " WHERE `name` = " .. name .. ");"))
            return TRUE
        else
            local query = assert(connect:execute("INSERT INTO `teleports` (`pos`, `name`) VALUES (" .. pos .. ", " .. name .. ");"))
            return TRUE
        end
    end,

    unset = function (pos)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `pos` = " .. pos .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("DELETE FROM `teleports` WHERE `pos ` = " .. pos ";"))
            return TRUE
        else
            return FALSE
        end
    end,

    get = function (name)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `name` = " .. name .. ";"))
        local arr = {}
        
        if (cursor:numrows() > 0) then
            cursor:fetch(arr)
            position = arr[1]
            return position
        else
            return FALSE
        end
    end
}

onSay = function (cid, words, param)
    local playerPos, playerDir = getCreaturePosition(cid), getPlayerLookDir(cid)

    if (string.find(param, '^[a-zA-Z0-9 -_]+$')) then
        if (words == "!set") then
            Waypoint.set(playerPos, param)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New waypoint: " .. param .. " ( " .. playerPos .. ").")
        elseif (words == "!unset") then
            Waypoint.unset(playerPos)
        else
            local posTo = Waypoint.get(param)
            local pos
            
            if (playerDir == NORTH) then 
                pos = {x = playerPos.x , y = playerPos.y + 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == SOUTH) then
                pos = {x = playerPos.x, y = playerPos.y - 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == EAST) then
                pos = {x = playerPos.x + 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            elseif (playerDir == WEST) then
                pos = {x = playerPos.x - 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            else
                debugPrint('[Waypoint System] Wrong direction spoted.')
            end
            
            local doCreateTeleport(ITEM_TELEPORT, pos, posTo)
            --doTeleportThing(cid, position)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Teleported to waypoint " .. param .. " ( " .. posTo .. ").")
        end
    end
end

Credits

I did all the script, so, credits to me :p
 
So,

1. Never tried the doCreateTeleport, but won't it exists untill server restart? Thats quite sucky :D
2. !unset should go by name imho.
3. !teleport should be named !createteleport, and use !teleport for 'doTeleportThing' ;)
 
@FightingElf

1. No, you will create it.
2. I am not very well in english ;D
3. I've made one line commented if you with to change teleport creation to simple teleport.
 
Nice piece of script! Very nice work, I like your scripting. Keep it up and we'll all be very glad. xD
 
1. I'm asking if I'll create a teleport, it will exists on the map till restart, right?
2. Here I mean, that !unset should go by waypoint. Ex: !unset "Teleport 1, instead of standing on a tile and typing !unset.
3. Well, yeah, but that would be better.

Ok, I've decided to modify the code a bit, check it out:

Code:
local ITEM_TELEPORT = 1387

dofile('./config.lua')
env = assert(luasql.mysql())
connect = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))

Waypoint =
{

    -- pos here should be a table (e.g: {x = 10, y = 10, z = 10}
    set = function (pos, name)
        if (string.find(name, '^[a-zA-Z0-9 -_]+$')) then
            debugPrint('[Waypoint System] Wrong characteres to the name of waypoint.')
            return FALSE
        end
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `pos` = " .. pos .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("UPDATE `teleports` SET `pos` = " .. pos .. " WHERE `name` = " .. name .. ");"))
            return TRUE
        else
            local query = assert(connect:execute("INSERT INTO `teleports` (`pos`, `name`) VALUES (" .. pos .. ", " .. name .. ");"))
            return TRUE
        end
    end,

    unset = function (name)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `name` = " .. name .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("DELETE FROM `teleports` WHERE `pos ` = " .. name ";"))
            return TRUE
        else
            return FALSE
        end
    end,

    get = function (name)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `name` = " .. name .. ";"))
        local arr = {}
        
        if (cursor:numrows() > 0) then
            cursor:fetch(arr)
            position = arr[1]
            return position
        else
            return FALSE
        end
    end
}

onSay = function (cid, words, param)
    local playerPos, playerDir = getCreaturePosition(cid), getPlayerLookDir(cid)

    if (string.find(param, '^[a-zA-Z0-9 -_]+$')) then
        if (words == "!set") then
            Waypoint.set(playerPos, param)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New waypoint: " .. param .. " ( " .. playerPos .. ").")
        elseif (words == "!unset") then
            Waypoint.unset(param)
		elseif (words == "!teleport") then
            local posTo = Waypoint.get(param)
			doTeleportThing(cid, position)
			doSendMagicEffect(getPlayerPosition(cid,CONST_ME_MAGIC_BLUE)
        else
            local posTo = Waypoint.get(param)
            local pos
            
			if (playerDir == NORTH) then 
                pos = {x = playerPos.x , y = playerPos.y + 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == SOUTH) then
                pos = {x = playerPos.x, y = playerPos.y - 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == EAST) then
                pos = {x = playerPos.x + 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            elseif (playerDir == WEST) then
                pos = {x = playerPos.x - 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            else
                debugPrint('[Waypoint System] Wrong direction spoted.')
            end
            
			doSendMagicEffect(getPlayerPosition(cid,CONST_ME_MAGIC_BLUE)
            local doCreateTeleport(ITEM_TELEPORT, pos, posTo)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Created a waypoint named " .. param .. " ( " .. posTo .. ").")
        end
    end
end

connect:close()
env:close()

talkactions.xml
Code:
<talkaction words="!set" script="teleporter.lua" />
<talkaction words="!unset" script="teleporter.lua" />
<talkaction words="!teleport" script="teleporter.lua" />
<talkaction words="!createteleport" script="teleporter.lua" />
 
Introduction

This is a system that consists in a managment of places, so it will be more simple to teleport to an especific place that you don't know the coordenates. You will only need the description that you can set.

Instructions

The scripts is a talkaction and the commands are:

  • !set "name of the place
  • !unset "name of the place
  • !teleport "name of the place
And you will have to edit your database creating a new table with two fields:

Table: teleports
Fields: pos, name

DROP TABLE IF EXISTS `teleports`;
CREATE TABLE `teleports` (
`pos` varchar(45) NOT NULL,
`name` text unsigned NOT NULL,
PRIMARY KEY (`pos`));

Observations

The script only works in TFS since it uses LuaSQL.

The script wasn't tested, any bugs, post here.
I am releasing that script because it sucks (can be easily made not using LuaSQL).

Code

talkactions.xml

HTML:
<talkaction words="!set" script="teleporter.lua" />
<talkaction words="!unset" script="teleporter.lua" />
<talkaction words="!teleport" script="teleporter.lua" />
teleporter.lua

Code:
local ITEM_TELEPORT = 1387

dofile('./config.lua')
env = assert(luasql.mysql())
connect = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))

Waypoint =
{

    -- pos here should be a table (e.g: {x = 10, y = 10, z = 10}
    set = function (pos, name)
        if (string.find(name, '^[a-zA-Z0-9 -_]+$')) then
            debugPrint('[Waypoint System] Wrong characteres to the name of waypoint.')
            return FALSE
        end
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `pos` = " .. pos .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("UPDATE `teleports` SET `pos` = " .. pos .. " WHERE `name` = " .. name .. ");"))
            return TRUE
        else
            local query = assert(connect:execute("INSERT INTO `teleports` (`pos`, `name`) VALUES (" .. pos .. ", " .. name .. ");"))
            return TRUE
        end
    end,

    unset = function (pos)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `pos` = " .. pos .. ";"))
        if (cursor:numrows() > 0) then
            local query = assert(connect:execute("DELETE FROM `teleports` WHERE `pos ` = " .. pos ";"))
            return TRUE
        else
            return FALSE
        end
    end,

    get = function (name)
        local cursor = assert(connect:execute("SELECT * FROM `teleports` WHERE `name` = " .. name .. ";"))
        local arr = {}
        
        if (cursor:numrows() > 0) then
            cursor:fetch(arr)
            position = arr[1]
            return position
        else
            return FALSE
        end
    end
}

onSay = function (cid, words, param)
    local playerPos, playerDir = getCreaturePosition(cid), getPlayerLookDir(cid)

    if (string.find(param, '^[a-zA-Z0-9 -_]+$')) then
        if (words == "!set") then
            Waypoint.set(playerPos, param)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "New waypoint: " .. param .. " ( " .. playerPos .. ").")
        elseif (words == "!unset") then
            Waypoint.unset(playerPos)
        else
            local posTo = Waypoint.get(param)
            local pos
            
            if (playerDir == NORTH) then 
                pos = {x = playerPos.x , y = playerPos.y + 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == SOUTH) then
                pos = {x = playerPos.x, y = playerPos.y - 1, z = playerPos.z, stackpos = 253}
            elseif (playerDir == EAST) then
                pos = {x = playerPos.x + 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            elseif (playerDir == WEST) then
                pos = {x = playerPos.x - 1, y = playerPos.y, z = playerPos.z, stackpos = 253}
            else
                debugPrint('[Waypoint System] Wrong direction spoted.')
            end
            
            local doCreateTeleport(ITEM_TELEPORT, pos, posTo)
            --doTeleportThing(cid, position)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Teleported to waypoint " .. param .. " ( " .. posTo .. ").")
        end
    end
end

Credits

I did all the script, so, credits to me :p
This is an awesome idea, and an awesome scripting :thumbup:. I really liked it!
 
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned NOT NULL,
PRIMARY KEY (`pos`))' at line 3

=zz
 
I just don't understand it, and as an OT'er I think many OT players would just be confused, and those that CAN figure it out would be awed. The idea of this to be used on any OT is quite horrifying. I wouldn't like the thought of a bunch of teleportals lying around. They should disappear (maybe decay?) The idea that this is a talkaction instead of a spell is also scary. Would there be any way that this could, perhaps, be turned around into an instant spell? If not, which I am pretty sure you can't, there's not much use for this.

The other alternative: this should cost money. These teleportals should cost money and poof after a specific amount of time. (15 - 20 minutes)
 
Last edited:
Back
Top