• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC NPC kick all players when IP changed or lost INTERNET

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:
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 :D

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!!!
 
cmon guys 44 views and 0 replies..???? Bump!
 
I don't know whether this is thread a question or not (Tutorial section and 0 question marks), but bear in mind this script is not going to work if the ISP had blocked ICMP packets (like mine did) - it would just not work properly. I think calling your ISP and asking for a static IP might be a good way of solving your problem.
 
ICMP opened lol :D as i said on post it works perfect but i don't know what to do with NPC to make him know his IP of OT where him Living (OMG ROFL)

Sorry for my english.. But there is a problem not in packets.. just my OT don't have included lua "io" library you know-->"io.open" to read file by the way, a type command from CMD in any ways returns just 1(TRUE), cuz type was executted correctly, so im just need help from professionals

P.S. Sorry for English.
 
Back
Top