zup
New Member
- Joined
- Mar 13, 2008
- Messages
- 187
- Reaction score
- 2
advise me how to arrive please:
I have a dynamic IP->to no-ip.org
but anyway my provider is suxx... and changing IP every 24 hours...
So i scripted one of alot NPCs
here is my script:
As you can see: os.execute("ping -n 1 -w 20 google.com") returns 1 when server is not response and returns 0 when all is ok with a ping
So that script works VERY GOOD: When ping is lost NPC kicks all players and saving server=offline to file where pinger.bat do taskkill if server offline i can show my bat file, BUT
sometimes my ip is changing VERY FAST like 300~400 msec and npc do ping from new ip and its good to response and server will not shutting down, but players can't login because server was resolved on old IP.. So i don't know the best way how to make NPC know what ip on his server where he works
i thinking about au3 or bat but it will take 30~50 MBytes from RAM..
By the way io.open and all io procedures is not aviable in my lua. So i must get new way to make npc get smarter
P.S. SORRY FOR ENGLISH!!!
I have a dynamic IP->to no-ip.org
but anyway my provider is suxx... and changing IP every 24 hours...
So i scripted one of alot NPCs
here is my script:
PHP:
local storage = 545646
local online = 545645
local ip = 545644
local startup = 545643
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()
npcHandler:onThink()
setGlobalStorageValue(storage, getGlobalStorageValue(storage) + 1)
setGlobalStorageValue(online, getGlobalStorageValue(online) + 1)
if getGlobalStorageValue(storage) > 15 then
doSendAnimatedText(getCreaturePosition(getNpcCid()), "Trainers!", 215)
setGlobalStorageValue(storage, 0)
local ping = os.execute("ping -n 1 -w 20 google.com")
local ping2 = os.execute("ping -n 1 -w 20 google.com")
local ping3 = os.execute("ping -n 1 -w 20 google.com")
local ping4 = os.execute("ping -n 1 -w 20 google.com")
os.execute("start /MIN [COLOR="#00FF00"]pinger.bat[/COLOR]")
os.execute("cls")
if (ping+ping2+ping3+ping4 == 4) then
local players = getPlayersOnlineList()
for i = 1, table.maxn(players) do
doRemoveCreature(players[i])
end
os.execute("echo server=offline>status.dll")
else
os.execute("echo server=online>status.dll")
end
end
end
-- OTServ event handling functions end
local travelNode = keywordHandler:addKeyword({'trainers'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to get teleportation to Trainer room for 1000 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 10, cost = 1000, destination = {x = 32539, y = 32414, z = 7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
keywordHandler:addKeyword({'hi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can send you to trainers.'})
npcHandler:addModule(FocusModule:new())
As you can see: os.execute("ping -n 1 -w 20 google.com") returns 1 when server is not response and returns 0 when all is ok with a ping
So that script works VERY GOOD: When ping is lost NPC kicks all players and saving server=offline to file where pinger.bat do taskkill if server offline i can show my bat file, BUT
sometimes my ip is changing VERY FAST like 300~400 msec and npc do ping from new ip and its good to response and server will not shutting down, but players can't login because server was resolved on old IP.. So i don't know the best way how to make NPC know what ip on his server where he works
i thinking about au3 or bat but it will take 30~50 MBytes from RAM..
By the way io.open and all io procedures is not aviable in my lua. So i must get new way to make npc get smarter
P.S. SORRY FOR ENGLISH!!!