Jump to content
mastaZz

pvp zone

Recommended Posts

 

who knows how to make two pvp zones by the example of this script?
 

	static vector zonepvp_pos = {5231.25, 0, 9820.31};// point
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist = vector.Distance(player.GetPosition(),zonepvp_pos);
				if(dist > 346) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

Share this post


Link to post
Share on other sites

This should work (not testet)

	static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// point1
	static vector zonepvp_pos1 = {2321.25, 0, 8452.31};// point2
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if(dist1 > 346 && dist2 > 346) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

Share this post


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

This should work (not testet)


	static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// point1
	static vector zonepvp_pos1 = {2321.25, 0, 8452.31};// point2
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if(dist1 > 346 && dist2 > 346) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

 

static vector zonepvp_pos1 = {2321.25, 0, 8452.31};// point2 

on line error

Share this post


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

Это должно работать (не testet)



	

		
		
		
	

 

override void OnInit() //показывает сколько играков и пвп
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
    static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// Координаты для центра зоны
	static vector zonepvp_pos2 = {5180.73, 0, 9907.51};
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if(dist > 350) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

only 1 zone works

Share this post


Link to post
Share on other sites

Sorry...

static vector zonepvp_pos1 = {2321.25, 0, 8452.31};// point2 

should be

static vector zonepvp_pos2 = {2321.25, 0, 8452.31};// point2 

Share this post


Link to post
Share on other sites

 

37 minutes ago, ZombieCooKie said:

Sorry...

static vector zonepvp_pos1 = {2321.25, 0, 8452.31};// point2 

should be

static vector zonepvp_pos2 = {2321.25, 0, 8452.31};// point2 

yes I fixed it but only 1 zone works

Share this post


Link to post
Share on other sites

which code do you use?
The code you posted below my code only checks 1 zone.

EDIT: Wait a moment. this couldn't work. I'll be back soon.

Edited by ZombieCooKie

Share this post


Link to post
Share on other sites

try this

static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// point1
static vector zonepvp_pos2 = {2321.25, 0, 8452.31};// point2
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
		bool in_zone1 = true;
		bool in_zone2 = true;
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if (dist1 > 346) in_zone1 = false;
				if (dist2 > 346) in_zone2 = false;
				if(!in_zone1 && !in_zone2) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

  • Like 1

Share this post


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

try this


static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// point1
static vector zonepvp_pos2 = {2321.25, 0, 8452.31};// point2
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 1000, true); //pvp
		
	}
	
	void CheckPVPZone()//pvp
	{
		bool in_zone1 = true;
		bool in_zone2 = true;
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if (dist1 > 346) in_zone1 = false;
				if (dist2 > 346) in_zone2 = false;
				if(!in_zone1 && !in_zone2) //дистанция от центра к игроку, откуда игрок будет получать предупреждения и урон
				{
					float newHeal = player.GetHealth("", "") - 1; //1 - это урон для игрока
					player.SetHealth("", "", newHeal);
					string messPlayers = "эй ты (" + player.GetIdentity().GetName() + ") пиздуй обратно, а то здохнеш!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

line error float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);

 

 

Share this post


Link to post
Share on other sites

Ok, sorry I'm out.
Can't see the error :(
If nobody can help you I will try it again next  weekend.

 

Edited by ZombieCooKie
  • Like 1

Share this post


Link to post
Share on other sites
16 часов назад, ZombieCooKie сказал:

Хорошо, извините, что я вышел. Невозможно провести
ошибку :(
Если никто не сможет вам помочь, я попробую еще раз в следующие выходные.

 

thanks for the effort

Share this post


Link to post
Share on other sites

I would like to try but can you change the comments to english?

Also does the ingame command player.GetPosition() get 3 value's or 2? X en Z? (the Y axis is not important anyway)

Share this post


Link to post
Share on other sites

So, I installed it on my server and it works as expected.

Please note the added COMMENTS

(Translation by google)

static vector zonepvp_pos1 = {5231.25, 0, 9820.31};// point1
static vector zonepvp_pos2 = {2321.25, 0, 8452.31};// point2
	
	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min // DOES NOT BELONG TO PVP ZONE!!!
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 5000, true); //pvp //CHANGED TO 5 SECONDS TO AVOID SERVER STRESS
		
	}
	
	void CheckPVPZone()//pvp
	{
		bool in_zone1 = true;
		bool in_zone2 = true;
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				if (dist1 > 346) in_zone1 = false; //DISTANCE ZONE 1
				if (dist2 > 346) in_zone2 = false;// DISTANCE ZONE 2
				if(!in_zone1 && !in_zone2) //distance from the center to the player, from where the player will receive warnings and damage
				{
					float newHeal = player.GetHealth("", "") - 5; //5 - this is damage to the player //CHANGED TO 5 BECAUSE OF TIME-CHANGE ABOVE
					player.SetHealth("", "", newHeal);
					string messPlayers = "Hey, you (" + player.GetIdentity().GetName() + ") go back, and then is healthy!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

  • Like 1

Share this post


Link to post
Share on other sites

Question, where do I put this file, so it launches on server start? and what do I name this file?

Edited by kmiles1990

Share this post


Link to post
Share on other sites
On 26/10/2018 at 10:29 PM, kmiles1990 said:

Got it, thanks.

did you get this to work and dose it tp players back inside if they leave or just damage them

Share this post


Link to post
Share on other sites
43 minutes ago, SaarPlayTV said:

Hey Guys

In the zone no dmg, outside the zone dmg, what's wrong ??

Nothing is wrong. This is a pvp zone, so you have to stay there. If you leave the zone you get damage.

Share this post


Link to post
Share on other sites

Now I understand that, people have to go to the area to do PvP ... but would it be possible to turn that around and be hurt only in the area? Sorry for my english

Edited by SaarPlayTV

Share this post


Link to post
Share on other sites
On 25.10.2018 at 15:16, ZombieCooKie said:

Итак, я установил его на свой сервер, и он работает так, как ожидалось.

Обратите внимание, что добавленные комментарии

(Перевод Google)



	

		
		
		
	

 

 

 

I play 1 everything is clear. play 3 starts working 3 random zones


	override void OnInit() 
	{

		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(NumPLayersOnServer, 60000, true);		// 10 min // DOES NOT BELONG TO PVP ZONE!!!
		
		super.OnInit();
		
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(CheckPVPZone, 5000, true); //pvp //CHANGED TO 5 SECONDS TO AVOID SERVER STRESS
		
	}
	
	void CheckPVPZone()//pvp
	{
static vector zonepvp_pos1 = {5217.25, 0, 9786.31};// point1
static vector zonepvp_pos2 = {5217, 0, 9834};// point2
static vector zonepvp_pos3 = {5182, 337.198, 9900};
static vector zonepvp_pos4 = {5295, 337.198, 9847};
static vector zonepvp_pos5 = {5224.25, 0, 9786.31};
		
		bool in_zone1 = true;
		bool in_zone2 = true;
		bool in_zone3 = true;
		bool in_zone4 = true;
		bool in_zone5 = true;
		ref array<Man> players = new array<Man>; 
		GetGame().GetPlayers( players );
		if ( players.Count() > 0 )
		{
			for ( int i = 0; i < players.Count(); i++ ) 
			{
				PlayerBase player; 
				Class.CastTo(player, players.Get(i));
				float dist1 = vector.Distance(player.GetPosition(),zonepvp_pos1);
				float dist2 = vector.Distance(player.GetPosition(),zonepvp_pos2);
				float dist3 = vector.Distance(player.GetPosition(),zonepvp_pos3);
				float dist4 = vector.Distance(player.GetPosition(),zonepvp_pos4);
				float dist5 = vector.Distance(player.GetPosition(),zonepvp_pos5);
				if (dist1 > 345) in_zone1 = false; //DISTANCE ZONE 1
				if (dist2 > 345) in_zone2 = false;// DISTANCE ZONE 2
				if (dist3 > 23) in_zone3 = false;//гаражи
				if (dist4 > 23) in_zone4 = false;//красные контейнера
				if (dist5 > 345) in_zone5 = false;//у бараков
				if(!in_zone1 && !in_zone2 && !in_zone3 && !in_zone4 && !in_zone5) //distance from the center to the player, from where the player will receive warnings and damage
				{
					float newHeal = player.GetHealth("", "") - 5; //5 - this is damage to the player //CHANGED TO 5 BECAUSE OF TIME-CHANGE ABOVE
					player.SetHealth("", "", newHeal);
					string messPlayers = "Эй! " + player.GetIdentity().GetName() + " вернись или умрёшь!";
					Param1<string> m_MessageParam = new Param1<string>(messPlayers); 
					GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, m_MessageParam, true, player.GetIdentity()); 
				}
			}
		}
	}

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×