RevScript movement waypoints

neowtwo

Miembro
LV
19
 
Awards
18
Creador: POX - otland.net
----------------------------------------------


data/scripts/waypoints.lua

Código Lua:
local waypointList = {

[1] = {
name = "Ahola Forest",
actionId = 2000,
position = Position(1045, 1132, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
cost = {check = false, itemId = 16101, amount = 1}
},
[2] = {
name = "Ahola Forest2",
actionId = 2001,
position = Position(1050, 1128, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
cost = {check = true, itemId = 16101, amount = 1}
},
[3] = {
name = "Ahola Forest3",
actionId = 2003,
position = Position(1041, 1128, 7),
requireQuest = {check = false, storage = 5000, value = 5000},
cost = {check = false, itemId = 16101, amount = 1}
}
}



local cooldowns = {}



local waypoints = MoveEvent()
function waypoints.onStepIn(player,item,position,fromPosition)
if not player:isPlayer() then
return false
end
if cooldowns[player:getName()] ~= nil then
if cooldowns[player:getName()] > os.time() - 2 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need to wait ".. cooldowns[player:getName()] - (os.time() - 2) .."seconds before traveling again.")
return false
end
end
local waypoint = false

for i=1,#waypointList do
if waypointList.actionId == item.actionid then
waypoint = waypointList
end
end



if waypoint then
if waypoint.requireQuest.Check then
if player:getStorageValue(waypoint.requireQuest.storage) < waypoint.requireQuest.value then
player:teleportTo(fromPosition)
player:say("You have not completed the prerequisite quest to unlock waypoint to ".. waypoint.name ..".", TALKTYPE_MONSTER_SAY)
return false
end
end
if player:getStorageValue(waypoint.actionId) ~= 1 then
player:setStorageValue(waypoint.actionId,1)
player:say("You have unlocked waypoint to ".. waypoint.name ..".", TALKTYPE_MONSTER_SAY)
return true
end



player:registerEvent("revWaypoints")
local window = ModalWindow(5000, "Waypoints", "Waypoint: " .. waypoint.name .. "\n")



local unlockedWps = 0

for i=1,#waypointList do
if player:getStorageValue(waypointList.actionId) == 1 then
if waypointList.actionId ~= item.actionid then
unlockedWps = unlockedWps+1
window:addChoice(i, waypointList.name)
end
end
end
window:addButton(110,"Select")
window:addButton(111,"Cancel")
window:setDefaultEnterButton(110)
window:setDefaultEscapeButton(111)
if unlockedWps ~= 0 then
window:sendToPlayer(player)
end
return true
end
end
for j=1,#waypointList do
waypoints:aid(waypointList[j].actionId)
end
waypoints:type("stepin")
waypoints:register()



local wpWindow = CreatureEvent("revWaypoints")
wpWindow:type("modalwindow")



function wpWindow.onModalWindow(player,modalWindowId,buttonId,choiceId)
if modalWindowId == 5000 then
if buttonId == 110 then
local travel = true
if waypointList[choiceId].cost.check then
if not player:removeItem(waypointList[choiceId].cost.itemId,waypointList[choiceId].cost.amount) then
travel = false
print("test")
end
end
if travel then
cooldowns[player:getName()] = os.time()
player:unregisterEvent("revWaypoints")
player:teleportTo(waypointList[choiceId].position)
player:getPosition():sendMagicEffect(15)
else
player:say("You cant afford to travel to ".. waypointList[choiceId].name ..".",TALKTYPE_MONSTER_SAY)
end

return true
end
end
end



wpWindow:register()

se usa con el action id, que se lo pones en el suelo que quieres que cuando pisen te salga en la lista, con 2 ya si pisas de nuevo en el mismo, sale la ventanita donde saldran los lugares conseguidos para teletransportarte....
 
Última edición por un moderador:

Miku

Miembro
LV
7
 
Awards
5
para un 13.10 canary no me sirvio o al menos eso intento y no sale nada mi bro
 
Arriba