Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • Need help?

    Create a topic in the appropriate section
    Don't write everything in the chat!
  • Take a look at the marketplace

    There you can buy
    everything related to game servers
  • Don't want a ban?

    Please read our rules
    Don't disturb the order!
  • Sell or buy?

    Use services of the guarantor
    We will make your deal safe
  • 0
Sign in to follow this  
dOOmcLiF

Спавн предметов по прицелу

Всем доброго времени суток. Есть мод на промокоды, который позволяет спавнить предметы при вводе определенного промокода. Однако вещь появляется под персонажем. Как я понимаю процесс спавна описан в этом методе: 

private static ItemBase CreateItem( string class_name, bool on_ground, PlayerBase player )
	{
		ItemBase item;
		if ( on_ground ) 
		{
			item = ItemBase.Cast( GetGame().CreateObject( class_name, player.GetPosition() ) );
		} 
		else 
		{
			item = ItemBase.Cast( player.GetInventory().CreateInInventory( class_name ) );
		}
		if ( item != NULL ) 
		{
			item.SetQuantity(item.GetQuantityMax());
		}
		return item;
	}

Я попытался немного изменить код, чтобы вещи появлялись по прицелу персонажа, но всё равно ничего не получилось - вещи так и спавнятся по координатам персонажа.

private static ItemBase CreateItem( string class_name, bool on_crosshair, PlayerBase player )
	{
		float distance = vector.Distance( pos_player, hitPos );
		float dist = vector.Distance( player.GetPosition(), player.GetAimPosition() )
		Print(dist);
		Print(player.GetAimPosition());
		vector position = player.GetPosition() + ( player.GetAimPosition() * distance );
		Print(position)
		ItemBase item;
		if ( on_crosshair ) 
		{
			item = ItemBase.Cast( GetGame().CreateObject( class_name, position ));
			vector pos = item.GetPosition();
			Print(pos);
		} 
		else 
		{
			item = ItemBase.Cast( player.GetInventory().CreateInInventory( class_name ) );
		}
		if ( item != NULL ) 
		{
			item.SetQuantity(item.GetQuantityMax());
		}
		return item;
	}

При дебаге, в логи выводились огромные значения vector dist, однако персонаж смотрел в пол в нескольких метрах от себя

Может кто подсказать в какую сторону копать?

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

hitPos не вижу где сетится может в нем проблема
player.GetPosition() - это точка в ногах
player.GetAimPosition() - это направление прицеливания, перед тем как умножать её на дистанцию хорошо бы её нормализовать на всякий пожарный
если ты точку откладываешь от свои ног то очень вероятно что hitPos окажется опять же в ногах

Share this post


Link to post
Share on other sites



  • 0

Пробовал не «on crosshair» прописать, а «At crosshair», просто как я помню даже в админке пишется через at

 

In inventory - в инвентаре
On Ground - под игроком (на земле)
At crosshair - в прицеле 

 

по сути даже от такой ошибки может не работать

Edited by Maksik180597 (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you automaticly agree to our Guidelines and Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.