Jump to content
Shako

[LUA] Auto Respawn Script

Recommended Posts

 

Download

 

Preview:

--[[ 

/////// Map Auto-revive Players by ShaKo \\\\\\\\
				::Public Release::
	!!!!!! Please don't remove credits! !!!!!!!

###########################################################################################
###                                                                                     ###
### How to Use:                                                                         ###
### 		function map_copy_run_[YOUR MAP] -- Inside Ctrl.lua of your desired map     ###
### 			DealAllPlayerInMap(map_copy, 'Map_AutoRevive_Players')                  ###
###                                                                                     ###
###########################################################################################

]]--

AutoRevive_Players = {}

function Map_AutoRevive_Players ( role )

	local cha_ID = GetRoleID ( role )
	local Alive = IsChaLiving ( role )
	local Revive_Time = 20

		if Alive ~= 1 then

			if AutoRevive_Players[cha_ID] == nil then

				AutoRevive_Players[cha_ID] = 1

			elseif AutoRevive_Players[cha_ID] == Revive_Time then

				MoveCity ( role , "" )
				HelpInfo ( role , 0 , "You were dead for too long revived by the system!" )
				AutoRevive_Players[cha_ID] = nil

			elseif AutoRevive_Players[cha_ID] ~= nil then

	local Revive_Timer = Revive_Time - AutoRevive_Players[cha_ID]

					AutoRevive_Players[cha_ID] = AutoRevive_Players[cha_ID] + 1
					BickerNotice ( role , "You have been slain. Reviving in "..Revive_Timer.." seconds..." )

			end

		else
		end

		if Alive == 1 and AutoRevive_Players[cha_ID] ~= nil then

			AutoRevive_Players[cha_ID] = nil -- Reset the Timer

		end

end
Edited by Shako
  • Like 2

logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites
8 hours ago, Indestructible said:

I Dont Think This Will Be Good In All Maps

the idea is to have players remove from Chaos Argent after x seconds so that

cleric's does not revive them after portal is closed. 


kong.png

a2.png

Share this post


Link to post
Share on other sites
2 hours ago, KONG said:

the idea is to have players remove from Chaos Argent after x seconds so that

cleric's does not revive them after portal is closed. 

I think clerics can't revive them as they aren't determined "friendly", regardless if they are in same party/guild. That's if the person has setup the correct type of map. 

 

This should work, haven't been tested.

--[[
DealAllPlayerInMap(map_copy, "AutoMapRevive")
]]
function AutoMapRevive(Player)
	local MapReviveTimer = 20
	if MapRevive == nil then
		MapRevive = {}
	end
	if MapRevive[GetRoleID(Player)] == nil or IsChaLiving(Player) == 1 then
		MapRevive[GetRoleID(Player)] = MapReviveTimer
	end
	if IsChaLiving(Player) ~= 1 then
		if MapRevive[GetRoleID(Player)] == 0 then
			MoveCity(Player, "")
			MapRevive[GetRoleID(Player)] = MapReviveTimer
		else
			SystemNotice(Player, "You're being revived in "..MapRevive[GetRoleID(Player)].." second(s).")
			MapRevive[GetRoleID(Player)] = MapRevive[GetRoleID(Player)] - 1
		end
	end
end

 

Edited by Angelix

Share this post


Link to post
Share on other sites
4 hours ago, KONG said:

the idea is to have players remove from Chaos Argent after x seconds so that

cleric's does not revive them after portal is closed. 

 

Why not just edit skillinfo and say if map = garner2 then systemnotice "you cant do that in CA" and then return 0 then?  Much easier. My idea was in case someone is dead and they use their dead body and vision as a spy / ward for the guild.


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

I think script that provide @Shako will do that job.

 

But, what about creating a map copy to store these dead players, instead of move them out,

*IF were possible, in where the player can't be noticed about the fact that they has been moved.

*Without changing its state/info, coords etc.

The purpose of this, is to let them think that they can spy, but if were possible that won't happen.

 

**I never use before a map copy,

Also by looking at the script, by changing it's map I think they character turns alive, but maybe if they are moved within a copy, that may work different.

Someone knows?

 

I'm pretty sure that @Angelix can be good at that point.


Discord: andresc

Share this post


Link to post
Share on other sites
4 minutes ago, Totoka said:

I think script that provide @Shako will do that job.

 

But, what about creating a map copy to store these dead players, instead of move them out,

*IF were possible, in where the player can't be noticed about the fact that they has been moved.

*Without changing its state/info, coords etc.

The purpose of this, is to let them think that they can spy, but if were possible that won't happen.

 

**I never use before a map copy,

Also by looking at the script, by changing it's map I think they character turns alive, but maybe if they are moved within a copy, that may work different.

Someone knows?

 

I'm pretty sure that @Angelix can be good at that point.

I haven't tried, but possibly moving a player from one copy to another still counts as a move, which essentially revives them. If you want me to script something, give me good details. :P

Share this post


Link to post
Share on other sites
4 minutes ago, KONG said:

@Angelix
yes, by now everyone should have party check at portal, and even in map ticks of CA...

Speaking of mapcopies, this reminds me abit, what happen to your RUSH map? discontinued?

 

A bit off-topic.

 

I still have to scripts! Back then when I made it I didn't know how to work with map copies and was a one-instance player-triggered PK event. I initially made to work with 10 players per round. It's a script based on a mode from S4 League, can't remember which one. It was working fine when you actually get all players to register and start the event at the same time. I was using a variable to store player's role to send them, that was the bugged part. Now that I know how map copies work, I need to adjust the script to work with map copies and see how I can fix the player registering  process (maybe limiting it to five per instance).

Share this post


Link to post
Share on other sites
3 hours ago, Angelix said:

A bit off-topic.

 

I still have to scripts! Back then when I made it I didn't know how to work with map copies and was a one-instance player-triggered PK event. I initially made to work with 10 players per round. It's a script based on a mode from S4 League, can't remember which one. It was working fine when you actually get all players to register and start the event at the same time. I was using a variable to store player's role to send them, that was the bugged part. Now that I know how map copies work, I need to adjust the script to work with map copies and see how I can fix the player registering  process (maybe limiting it to five per instance).

I think for registration, you can implement a "stack"-like interface and use it...
- every time a player registers, push them on the "stack". array in this case.
- once the map is ready to roll, pop 5 people off the stack... continue to do so until there are no more on the stack
or there is not enough for an instance of 5.

Stack = {}

Stack.new = function()
    local self = {}
    size, stack = size or 0, stack or {}
    self.push = function(player)
        stack[size+1] = player
        size = size + 1
    end
    self.pop = function()
        local a = stack[size]
        stack[size] = nil;
        size = size - 1
        return a
    end
    self.peek = function()
        return stack[size]
    end
    self.getSize = function()
        return size
    end
    self.isEmpty = function()
        return size == 0
    end
    return self
end

local a = Stack.new()
a.push("KONG")
a.push("HELLO")
print(a.getSize())
a.push("Angelix")
a.push("Wrexor")
a.push("Billy")
a.push("Fox")
a.push("angelix")
print(a.peek()) -- prints the top of the stack
a.push("Vector")
a.push("totoka")
print(a.pop()) -- removes totaka and returns him

Tested on lua's interpreter. https://www.lua.org/cgi-bin/demo

 

EDIT:

NO.PNG

Sorry for pushing people !

  • Like 2

kong.png

a2.png

Share this post


Link to post
Share on other sites
7 minutes ago, KONG said:

I think for registration, you can implement a "stack"-like interface and use it...
- every time a player registers, push them on the "stack". array in this case.
- once the map is ready to roll, pop 5 people off the stack... continue to do so until there are no more on the stack
or there is not enough for an instance of 5.

 


Stack = {}

Stack.new = function()
    local self = {}
    size, stack = size or 0, stack or {}
    self.push = function(player)
        stack[size+1] = player
        size = size + 1
    end
    self.pop = function()
        local a = stack[size]
        stack[size] = nil;
        size = size - 1
        return a
    end
    self.peek = function()
        return stack[size]
    end
    self.getSize = function()
        return size
    end
    self.isEmpty = function()
        return size == 0
    end
    return self
end

local a = Stack.new()
a.push("KONG")
a.push("HELLO")
print(a.getSize())
a.push("Angelix")
a.push("Wrexor")
a.push("Billy")
a.push("Fox")
a.push("angelix")
print(a.peek()) -- prints the top of the stack
a.push("Vector")
a.push("totoka")
print(a.pop()) -- removes totaka and returns him


Tested on lua's interpreter. https://www.lua.org/cgi-bin/demo

The thing is, I though of doing something similar. Putting people on a variable table and keep sending them as soon as it reaches 10 people. The problem I though (never tested or proved), what happens if a player registers and suddenly disconnects? The player's data is stored and it will count as 1 of the 10 players that will be sent, but the player isn't online anymore. I didn't know how to deal with that, that's why I though of trying to use a whole party (5 players) as a requisite to register, the same logic used from the creator of the instanced "Lone Tower".

Share this post


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

The thing is, I though of doing something similar. Putting people on a variable table and keep sending them as soon as it reaches 10 people. The problem I though (never tested or proved), what happens if a player registers and suddenly disconnects? The player's data is stored and it will count as 1 of the 10 players that will be sent, but the player isn't online anymore. I didn't know how to deal with that, that's why I though of trying to use a whole party (5 players) as a requisite to register, the same logic used from the creator of the instanced "Lone Tower".

ahh yes, im the creator of Lone Tower.
if IsPlayer(GetPlayerByName(a.peek())) ~= 1 or IsPlayer(GetPlayerByName(a.peek())) == nil then -- player is offline
    a.pop() -- removes him from stack and do nothing with him...
end
Ok, kinda throwing codes without too much thinking. 

  • Like 1

kong.png

a2.png

Share this post


Link to post
Share on other sites
7 minutes ago, KONG said:

ahh yes, im the creator of Lone Tower.
if IsPlayer(GetPlayerByName(a.peek())) ~= 1 or IsPlayer(GetPlayerByName(a.peek())) == nil then -- player is offline
    a.pop() -- removes him from stack and do nothing with him...
end
Ok, kinda throwing codes without too much thinking. 

That's something I never thought off back then, hahah. To actually re-check the player's role when trying to send players into the map. Does the "IsPlayer" or "IsLivingCha" work to check if a player is online?

 

Might as well start a new thread for this, too much off-topic.

Share this post


Link to post
Share on other sites
52 minutes ago, Lucky said:

using move function to revive players will not bug the character?(ya it will revive but the character will not move)

Yes. In order to revive them with "MoveCity" or "GoTo", you'd have to move them twice, maybe even give them some HP I guess. 

 

It's like applying "&call" or "&goto". 

Edited by Angelix

Share this post


Link to post
Share on other sites
54 minutes ago, Lucky said:

using move function to revive players will not bug the character?(ya it will revive but the character will not move)

 

It works when I tested it.


logo-big.png   logo.png

                                   Sunny Go! Online                                                                    pko.host                                                 

Share this post


Link to post
Share on other sites

Wouldnt it be much easier to just revive instantly in After_Player_Kill_Player, and not worry about timing the 20 seconds?

 

Something like: (untested)

 

AutoRevive= {
	MapsList = {
		['garner2'] = true,
		['puzzleworld'] = true,
		['puzzleworld2'] = true,
	},
	PKFunc = after_player_kill_player,
}

function AutoRevive.CheckRevive( ATKER, role )
	if AutoRevive.MapsList[GetChaMapName ( role )] == true then
		MoveCity(role, "")
		MoveCity(role, "")
	end
	AutoRevive.PKFunc(ATKER,role)
end

after_player_kill_player = AutoRevive.CheckRevive

 

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...