Jump to content
Home

Anti Dupe 2.0

Recommended Posts

 

 

Explanation

It just consists of checking if there's a cloned character around the game servers, and them automatically remove's it, without the necessity of punishing the player...

 

HOW TO USE

  1 - Make folder called players resource/script/

     resource/script/players

  2 - Add the fellowing functions in anywhere of your functions.lua


function GetCurrentGameServer()
  local ret, npc = GetEudemon()

  return GetChaDefaultName(npc)
end


function SaveFile (path, name, extension, content)
  local file = io.open (path .. name .. extension, "w")

  file:write (content)
  file:close ()
end

function ReadFile (path, name, extension)
  local file = io.open (path .. name .. extension, "r")
  local content = file:read ()

  file:close ()

  return content
end

function SaveGameServer (role)
  SaveFile(PLAYERS_DIR, GetRoleID(role), '.txt', GetCurrentGameServer())
end


function AfterEnter(role)
  SaveGameServer(role)
end


function RemoveClonedCha(role)
  local RoleID = GetRoleID(role)
  local SavedGameServer = ReadFile(PLAYERS_DIR, RoleID, '.txt')
  local CurrentGameServer = GetCurrentGameServer()

  if SavedGameServer ~= CurrentGameServer then
    MoveCity(role, 'Prison Island')
  end
end

 

3 - Add the fellowing inside of cha_timer()

if Cha_Num >= 1 and Cha_Num <= 4 then
    RemoveClonedCha(role)
  end

 

4 - Add the fellowing inside of every map ctrl.lua, after_enter_mapname function.. ( if there's not ctrl.lua for the map of even the after_enter_* function so create it one

AfterEnter(role)

5 - Add the fellowing CONSTANT to variables.lua

PLAYERS_DIR = "resource/script/players/"

 

 

And its done... thanks for PKODEV members tips.

 

ATTENTION DONT USE &updateall COMMAND, cuz it'll bug the anti dupe system...

  • Like 2

Share this post


Link to post
Share on other sites

@Home how does it break when you use &updateall?

 

and, does &misreload work then? O.o 

 

cha_timer might take a lot of memory also. 

 

Also, you can do this and add to extensions


 

function RemoveCloneCha ( role )
if Cha_Num >= 1 and Cha_Num <= 4 then
    RemoveClonedCha(role)
  end

                               
  

and then in cha_timer ()

just put in

function cha_timer ( role , freq , time)
RemoveCloneCha ( role )
end

it works the same, but saves memory, i think.

 

Edited by Shako
  • Like 1

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Maybe instead of teleporting the cha to prison island, u can use

 

KickCha function?

I'm not sure..


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

I see, i'll try to improve it, and update...

 

The problem with &updateall is that changes the name of the current server to "guardian" turning the anti dupe obsolete...

Share this post


Link to post
Share on other sites

@Home

 

function KickCha(character)

	local pkt = GetPacket()
	
	WriteCmd(pkt, 1505)
	SendPacket(character,pkt)
	
end

 

  • Like 1

Share this post


Link to post
Share on other sites

Hello @V3ct0r! i would like to know if..

 

~Context function KickCha

 

Is this packet is sent to gateserver in order to disconnect it?
If it does, gateserver also send a packet back to gameserver? do you know if it does a db update?
In case of a cloned character, I think gateserver lost the character reference.

But, do you know how is being applied this packet, into that case?

 

Edit --

@Home, i'm trying to understand how reliable can be the packet behavior under a cloned character.

Edited by Totoka
  • Like 1

Discord: andresc

Share this post


Link to post
Share on other sites
On 19/09/2016 at 11:21 AM, Shako said:

@Home how does it break when you use &updateall?

 

and, does &misreload work then? O.o 

 

cha_timer might take a lot of memory also. 

 

Also, you can do this and add to extensions


 


function RemoveCloneCha ( role )
if Cha_Num >= 1 and Cha_Num <= 4 then
    RemoveClonedCha(role)
  end

                               
  

and then in cha_timer ()

just put in


function cha_timer ( role , freq , time)
RemoveCloneCha ( role )
end

it works the same, but saves memory, i think.

 

It's the same thing >_>. If anything, it'll take up more time (minuscule though, probably won't notice) since it'll have to search for the function and then send it the params etc etc. 

Edited by Perseus
  • Like 1

Share this post


Link to post
Share on other sites

Maybe often memory io using cha_timer is a bad idea, even with lua. So i did another solution that is triggered only onLeaveMap and onEnterMap and uses the currentMapName instead of gameServerName avoiding updateall problems...

Edited by Home

Share this post


Link to post
Share on other sites
1 hour ago, Home said:

Maybe often memory io using cha_timer is a bad idea, even with lua. So i did another solution that is triggered only onLeaveMap and onEnterMap and uses the currentMapName instead of gameServerName avoiding updateall problems...

In the PKO 1.38 base files that I released, there is a player_timer function. Try using that one. 

function player_timer(role)
end

function map_timer(ignore, map_copy)
	DealAllPlayerInMap(map_copy, 'player_timer')
end

function initTimer()
	Hook:SetHookPattern("^map_copy_run_.*$", "POST", map_timer, 2)
end
initTimer() -- for updateall

function initTicks()
	for i,v in pairs(MapsLists) do
		if(_G["map_copy_run_"..v] == nil)then
			_G["map_copy_run_"..v] = function(role, map_copy) 
			end
		end
	end
end

do
  (function(file, str)
      local index = (function(file)
          local f = io.open(file, "r")
          local arr = {}
          for line in f:lines() do
              table.insert(arr, line)
          end
          return arr
      end)(file);
      local r = 0
      for i = 1, table.getn(index) do
          if index[i] ~= tostring(str) then
              r = r + 1;
          end
      end
      if r == table.getn(index) then 
          local f = io.open(file, 'a');
          f:write('\n');
          f:write(tostring(str));
          f:close();
      end
  end)(GetResPath('/script/help/AddHelpNPC.lua'), 'initTicks();')
end

 

  • Like 1

kong.png

a2.png

Share this post


Link to post
Share on other sites
On 9/23/2016 at 9:06 PM, KONG said:

In the PKO 1.38 base files that I released, there is a player_timer function. Try using that one. 


function player_timer(role)
end

function map_timer(ignore, map_copy)
	DealAllPlayerInMap(map_copy, 'player_timer')
end

function initTimer()
	Hook:SetHookPattern("^map_copy_run_.*$", "POST", map_timer, 2)
end
initTimer() -- for updateall

function initTicks()
	for i,v in pairs(MapsLists) do
		if(_G["map_copy_run_"..v] == nil)then
			_G["map_copy_run_"..v] = function(role, map_copy) 
			end
		end
	end
end

do
  (function(file, str)
      local index = (function(file)
          local f = io.open(file, "r")
          local arr = {}
          for line in f:lines() do
              table.insert(arr, line)
          end
          return arr
      end)(file);
      local r = 0
      for i = 1, table.getn(index) do
          if index[i] ~= tostring(str) then
              r = r + 1;
          end
      end
      if r == table.getn(index) then 
          local f = io.open(file, 'a');
          f:write('\n');
          f:write(tostring(str));
          f:close();
      end
  end)(GetResPath('/script/help/AddHelpNPC.lua'), 'initTicks();')
end

 

 

When I tried to use this, the timer doesn't run when the GS is opened, but only when I did a &updateall afterwards. Is this meant to happen? @KONG


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
14 hours ago, Shako said:

 

When I tried to use this, the timer doesn't run when the GS is opened, but only when I did a &updateall afterwards. Is this meant to happen? @KONG

thats not suppose to happen.
Because maps are only loaded once only. Hooks need to apply after the initialization of maps, that is why
a hook was placed in AddHelpNpc.lua, thus when GS starts the timer should run.
It should work even after updateall, because initTimer() also exist outside of AddHelpNpc.
The first call to initTimer() is really a dummy for set up should updateall be called.

  • Like 1

kong.png

a2.png

Share this post


Link to post
Share on other sites

@KONG

 

Thanks for the clarification. It's fixed! :)


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

@Home hey bro i added all but when i add function

RemoveCloneCha ( role ) if Cha_Num >= 1 and Cha_Num <= 4 then RemoveClonedCha(role) end

 

My All glows get bug. Hmm?? any idea how to fix?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...