Demo:
You can see the source changes here: https://gist.github.com/Mkalo/32f7b36931f4992fa131252b51fbbeb9
Install this lib in your server: http://pastebin.com/3p1DU2Qa
(All the config is in the lib)
Now to events and shit: (The tags are commented inside the code.)
Creaturescript:
Talkaction:
Now to the event changes (data/events):
Change events.xml where:
To enabled="1"
And add this:
Edit events/scripts/creature.lua replacing the onTargetCombat function to this:
And add this function to events/scripts/player.lua:
Put this in your logout.lua under "function onLogout(player)":
Its done, it should be working. Requested in the topic:
Free Scripting. TFS [1.2]
Tomorrow I will add a video, but its pretty simple, certain mounts have the ability to fly (like in pokemon otservers and shit.). The pvp stuff may have bugs, please report if you spot any.
You can see the source changes here: https://gist.github.com/Mkalo/32f7b36931f4992fa131252b51fbbeb9
Install this lib in your server: http://pastebin.com/3p1DU2Qa
(All the config is in the lib)
Now to events and shit: (The tags are commented inside the code.)
Creaturescript:
Code:
-- <event type="move" name="FlyEvent" script="flyevent.lua" />
function onMove(player, fromPosition, toPosition)
if PvpRestrictions:lower() == "high" and player:isPzLocked() then
return true
end
if player:isFlying() then
local fromTile = Tile(fromPosition)
local fromItem = fromTile:getItemById(460)
if fromItem then
fromItem:remove()
end
toPosition:createFlyFloor()
end
return true
end
Talkaction:
Code:
-- <talkaction words="!down" script="fly.lua" />
-- <talkaction words="!up" script="fly.lua" />
local exhauststorage = 16500
function onSay(player, words)
if not player:isFlying() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are not flying.")
return false
end
if player:isPzLocked() and PvpRestrictions:lower() == "high" then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot use this command in fight.")
return false
end
local last = player:getStorageValue(exhauststorage)
local interval = ChangeFloorInterval
if PvpRestrictions:lower() == "medium" and player:isPzLocked() then
interval = ChangeFloorIntervalPZ
end
if last+interval > os.time() then
player:sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED)
return false
end
if words == "!up" then
local ret = player:flyUp()
if ret == false then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot fly up.")
else
player:setStorageValue(exhauststorage, os.time())
end
elseif words == "!down" then
local ret = player:flyDown()
if ret == false then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot fly down.")
else
player:setStorageValue(exhauststorage, os.time())
end
end
return false
end
Now to the event changes (data/events):
Change events.xml where:
Code:
<event class="Creature" method="onTargetCombat" enabled="0" />
And add this:
Code:
<event class="Player" method="onToggleMount" enabled="1" />
Edit events/scripts/creature.lua replacing the onTargetCombat function to this:
Code:
function Creature:onTargetCombat(target)
if self and target then
if PvpRestrictions:lower() == "high" then
if self:isPlayer() and self:isFlying() then
local pos = self:getPosition()
local tile = Tile(pos)
if tile:getItemById(460) then
return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
end
end
if target:isPlayer() and target:isFlying() then
local pos = target:getPosition()
local tile = Tile(pos)
if tile:getItemById(460) then
return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
end
end
end
end
return true
end
And add this function to events/scripts/player.lua:
Code:
function Player:onToggleMount(mountid, mount)
if mount then
if isInArray(FlyingMounts, mountid) then
if isInArray({"high", "medium"}, PvpRestrictions:lower()) and self:isPzLocked() then
self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot start flying now.")
return false
end
self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are now flying.")
self:activateFly()
end
elseif self:isFlying() then
local ret = self:deactivateFly()
if ret then
self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are no longer flying.")
else
self:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can't deactivate fly now.")
end
return ret
end
return true
end
Put this in your logout.lua under "function onLogout(player)":
Code:
if player:isFlying() then
player:sendCancelMessage("You cannot logout while flying.")
return false
end
Its done, it should be working. Requested in the topic:
Free Scripting. TFS [1.2]
Tomorrow I will add a video, but its pretty simple, certain mounts have the ability to fly (like in pokemon otservers and shit.). The pvp stuff may have bugs, please report if you spot any.
Last edited: