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:
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
teleporter.lua
Credits
I did all the script, so, credits to me
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
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" />
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