Qwe
Banned User
Hi, I created a simple script, allowing us to save the item, and then teleport to the item using the stored name. Nice for Gamemasters
* Commands *
- /savepos POS_NAME
- /tp POS_NAME
!! EASY INSTALLATION !!
in data/talkactions/scripts/ create file tpsys.lua and paste this code:
and in talkactions.xml add:
!! If GM XXX save position by name: "lolnoob", GM ZZZ can save other position with this name, and both saves are useable.
* Commands *
- /savepos POS_NAME
- /tp POS_NAME
!! EASY INSTALLATION !!
in data/talkactions/scripts/ create file tpsys.lua and paste this code:
PHP:
local config = {
GroupID = 3,
}
local function getPosition(cid, posName)
local result = db.getResult("SELECT `pos_x`, `pos_y`, `pos_z` FROM `teleports` WHERE `pos_name` = '" .. db.escapeString(posName) .. "' and `pos_player`= " .. getPlayerGUID(cid) ..";")
local ret = (result:getID() == -1) and false or {
x = result:getDataInt("pos_x"),
y = result:getDataInt("pos_y"),
z = result:getDataInt("pos_z")
}
result:free()
return ret
end
local function savePosition(cid, posName)
if (not getPosition(cid, name)) then
local pos = getCreaturePosition(cid)
local query = db.executeQuery("INSERT INTO `teleports` (`pos_name`, `pos_player`, `pos_x`, `pos_y`, `pos_z`) VALUES ('" .. db.escapeString(posName) .. "', " .. getPlayerByGUID(cid) .. ", ".. pos.x ..", ".. pos.y ..", ".. pos.z ..");")
if query then
doPlayerSendTextMessage(cid, 22, "Position " .. posName .. " has been saved on position [x="..pos.x.." y="..pos.y..", z="..pos.z.."]!")
else
doPlayerSendCancel(cid, "Error in saving position.")
end
else
doPlayerSendCancel(cid, "Position with this name is already saved for you.")
end
end
function onSay(cid, words, param, channel)
if(param == "")then
doPlayerSendCancel(cid, "This command require param.")
return true
end
if(getConfigValue("sqlType") == "mysql")then
db.executeQuery("CREATE TABLE IF NOT EXISTS `"..(getConfigValue("sqlDatabase") or "").."`.`teleports` (`id` INT( 11 ) NOT NULL, `pos_name` VARCHAR( 255 ) NOT NULL ,`pos_player` INT( 11 ) NOT NULL ,`pos_x` INT( 11 ) NOT NULL , `pos_y` INT( 11 ) NOT NULL ,`pos_z` INT( 11 ) NOT NULL ,INDEX ( `id` ))")
elseif(getConfigValue("sqlType") == "sqlite")then
db.executeQuery("CREATE TABLE IF NOT EXISTS `teleports` (id INTEGER, pos_name VARCHAR, pos_player INTEGER, pos_x INTEGER, pos_y INTEGER, pos_z INTEGER );");
end
if(getPlayerGroupId(cid) >= config.GroupID)then
if(words == "/tp")then
local pos = getPosition(cid, posName)
if pos then
doTeleportThing(cid, pos, true)
else
doPlayerSendCancel(cid, "Position not found.")
end
elseif(words == "/savepos")then
savePosition(cid, param)
end
else
doPlayerSendCancel(cid, "You cannot execute this command.")
end
return true
end
and in talkactions.xml add:
PHP:
<talkaction log="yes" words="/tp;/savepos" access="3" event="script" value="tpsys.lua"/>
!! If GM XXX save position by name: "lolnoob", GM ZZZ can save other position with this name, and both saves are useable.
Last edited: